@tocca-systems/twp-cli 0.32.0 → 0.32.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.public.md +4 -0
- package/dist/{agent-loop-ZJWMWB24.js → agent-loop-ADP6AOWX.js} +1 -1
- package/dist/{ai-dispatch-YADG7BDD.js → ai-dispatch-KXRNV4UZ.js} +2 -2
- package/dist/{api-command-OXFQL6OQ.js → api-command-TJFXCLPS.js} +1 -1
- package/dist/{app-HDUWKPFQ.js → app-6ULNAHKL.js} +1 -1
- package/dist/{chunk-Y2XAWM2X.js → chunk-AEJHDFXB.js} +11 -11
- package/dist/{chunk-RDS6IJDZ.js → chunk-D72V6QGN.js} +1 -1
- package/dist/{chunk-JXIIXUAO.js → chunk-QVPU4HHG.js} +1 -1
- package/dist/{chunk-5PU5QU5U.js → chunk-T4QZO6RQ.js} +1 -1
- package/dist/{chunk-VDP6DKOM.js → chunk-VBX44RKP.js} +1 -1
- package/dist/{chunk-KAP6IM5C.js → chunk-WEKECDTT.js} +1 -1
- package/dist/cli.js +7 -7
- package/dist/{commands-EVWYBQEK.js → commands-4DNJTCOG.js} +1 -1
- package/dist/{commands-YQTCGNDN.js → commands-MW7XRREL.js} +5 -5
- package/dist/{logout-guard-I3YHI2VW.js → logout-guard-XYVKR47G.js} +1 -1
- package/dist/{registry-ZYCO5S5Z.js → registry-RTZUE4RG.js} +1 -1
- package/dist/{run-TBGMRJ4P.js → run-PI7VMII2.js} +1 -1
- package/dist/{server-settings-OE6Q77RE.js → server-settings-MVZEW2QI.js} +1 -1
- package/dist/{setup-FREKDQVC.js → setup-CVXGKBTY.js} +1 -1
- package/package.json +1 -1
package/CHANGELOG.public.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
2
|
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
-
import{stepToItem}from"./chunk-VCZVITWG.js";import{loadLocalConfig}from"./chunk-
|
|
3
|
+
import{stepToItem}from"./chunk-VCZVITWG.js";import{loadLocalConfig}from"./chunk-QVPU4HHG.js";import"./chunk-N2UVRM3Z.js";import{loadAiConfig}from"./chunk-AEJHDFXB.js";import"./chunk-GY7KI5E5.js";import{LIST_FLAGS,LIST_PAGING_HELP,envelopePaging,nonEmpty,positiveInteger}from"./chunk-G4OO4M44.js";import"./chunk-II5RVJQN.js";import{requireResolved,singleRef,withResolved}from"./chunk-ZN5EFDH7.js";import{acknowledgement,isRecord,pick}from"./chunk-ZWVYVS2A.js";
|
|
4
4
|
import{ApiResponseError,UsageError}from"./chunk-7WSNIXTQ.js";import"./chunk-PMOUHEJQ.js";import"./chunk-5WGOHFAS.js";import"./chunk-RZVI6PMW.js";import"./chunk-VSJBJXZO.js";var LABEL="\u30A8\u30FC\u30B8\u30A7\u30F3\u30C8\u30EB\u30FC\u30D7\u306E\u30A2\u30A4\u30C6\u30E0";var STATUSES=["pending","processing","completed","failed"];var AI_TYPES=["claude","gemini","codex","copilot"];var EFFORTS=["low","medium","high","xhigh","max"];var PRIORITIES=["P0","P1","P2","P3"];var LIST_COLUMNS=["item_id","status","task_key","label","ai_type","ai_effort","runner_id","created_at"];var GET_COLUMNS=["item_id","status","task_key","label","prompt","ai_type","ai_model","ai_effort","runn\
|
|
5
5
|
er_id","attempt_count","reclaim_count","error_message","created_by_name","created_at","started_at","completed_at"];var HISTORY_COLUMNS=["item_id","status","task_key","skill","ai_type","runner_id","duration_ms","cost_usd","created_at"];var PROJECT_FLAG={name:"--project",summary:"\u30AD\u30E5\u30FC\u306E\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\uFF08\u30B3\u30FC\u30C9\u307E\u305F\u306F ID\u3002\u7701\u7565\u6642\u306F TWP_PROJECT / .twp/config.json / ~/.twp/config.json\uFF09",takesValue:true,placeholder:"\
|
|
6
6
|
<\u30B3\u30FC\u30C9|ID>"};var ITEM_FLAG={name:"--item",summary:"\u30A2\u30A4\u30C6\u30E0\u306E ID\uFF08item_id\uFF09\u3002\u4F4D\u7F6E\u5F15\u6570\u3068\u540C\u3058\u610F\u5473\uFF08\u4E21\u65B9\u6307\u5B9A\u306F\u30A8\u30E9\u30FC\uFF09",takesValue:true,placeholder:"<\u30A2\u30A4\u30C6\u30E0ID>"};var FORBIDDEN_CORE="\u30C6\u30CA\u30F3\u30C8\u306E\u7BA1\u7406\u8005\uFF08admin \u30ED\u30FC\u30EB\uFF09\u306E\u6A29\u9650\u304C\u5FC5\u8981\u3067\u3059\uFF08\u500B\u4EBA\u30AD\u30E5\u30FC\u3092\u9664\u304F\uFF09";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
2
|
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
-
import{failureHint,isAuthError,isCliFatalText,isRateLimited,isServerAiType,isUntrusted,maxTurnsReached,rateLimitWaitSeconds,tailForScan}from"./chunk-ZOOEH7ZE.js";import{expandServerSkills,prepareSkillOverlay}from"./chunk-ONTK2FR4.js";import"./chunk-VK2Z4QGC.js";import{detectAiClis}from"./chunk-
|
|
4
|
-
import{isForceOnly,killProcessTree,system32}from"./chunk-N2UVRM3Z.js";import{DEFAULT_CLAUDE_LAUNCHER,activeSlotPath,detectClaudeAutoSwitch,isClaudeAi,isUsableModelId,modelFitsRoute,resolveSpawnTarget,usesBedrock,wrapWithAutoSwitch}from"./chunk-
|
|
3
|
+
import{failureHint,isAuthError,isCliFatalText,isRateLimited,isServerAiType,isUntrusted,maxTurnsReached,rateLimitWaitSeconds,tailForScan}from"./chunk-ZOOEH7ZE.js";import{expandServerSkills,prepareSkillOverlay}from"./chunk-ONTK2FR4.js";import"./chunk-VK2Z4QGC.js";import{detectAiClis}from"./chunk-T4QZO6RQ.js";import"./chunk-P4AEFKLM.js";import"./chunk-VRBI2NPI.js";import"./chunk-QWSXHHFT.js";import"./chunk-J7QYPKVK.js";import{stripTerminalControls}from"./chunk-NHYMHCAT.js";
|
|
4
|
+
import{isForceOnly,killProcessTree,system32}from"./chunk-N2UVRM3Z.js";import{DEFAULT_CLAUDE_LAUNCHER,activeSlotPath,detectClaudeAutoSwitch,isClaudeAi,isUsableModelId,modelFitsRoute,resolveSpawnTarget,usesBedrock,wrapWithAutoSwitch}from"./chunk-AEJHDFXB.js";import"./chunk-GY7KI5E5.js";import"./chunk-7WSNIXTQ.js";import{findExecutable,isWindowsDriveAbsolute}from"./chunk-PMOUHEJQ.js";import"./chunk-5WGOHFAS.js";import"./chunk-VSJBJXZO.js";import{spawnSync}from"child_process";import fs2 from"fs";import path2 from"path";import{spawn}from"child_process";import fs from"fs";import path from"path";var FINAL_REPORT_BEGIN="<<<AI_FINAL_REPORT>>>";var FINAL_REPORT_END="<<<END_AI_FINAL_REPORT>>>";var ClaudeStreamRenderer=class{constructor(now=()=>new Date){this.now=now}now;toolNames=new Map;toolCount=0;result={subtype:null,isError:null,numTurns:null,costUsd:null,durationMs:null,tokensIn:null,tokensOut:null,rateLimited:false,resetsAt:null,finalText:""};push(line){const trimmed=line.trim();if(trimmed==="")return[];let event;try{const parsed=JSON.parse(trimmed);if(parsed===null||typeof parsed!=="\
|
|
5
5
|
object"||Array.isArray(parsed)){return[line]}event=parsed}catch{return[line]}switch(event["type"]){case"rate_limit_event":return this.onRateLimit(event);case"assistant":return this.onAssistant(event);case"user":return this.onUser(event);case"result":return this.onResult(event);default:return event["type"]==="system"?[]:[line]}}sawRateLimit(){return this.result.rateLimited}lastRateLimitNote="";onRateLimit(event){const info=event["rate_limit_info"];if(info===null||typeof info!=="object")return[];const rec=info;
|
|
6
6
|
const status=typeof rec["status"]==="string"?rec["status"]:"";const resets=typeof rec["resetsAt"]==="number"?rec["resetsAt"]:null;if(status==="")return[];const at=isSaneEpochSec(resets)?` resets=${new Date(resets*1e3).toISOString()}`:"";if(status.startsWith("allowed")){if(status==="allowed")return[];const seen=`${status}|${resets??""}`;if(seen===this.lastRateLimitNote)return[];this.lastRateLimitNote=seen;return[this.line(`\u2139\uFE0F \u4E0A\u9650\u306B\u63A5\u8FD1\uFF08status=${status}${at}\uFF09\u2014 \u5B9F\
|
|
7
7
|
\u884C\u306F\u7D99\u7D9A\u3057\u307E\u3059`)]}if(resets!==null)this.result.resetsAt=resets;this.result.rateLimited=true;return[this.line(`\u26A0\uFE0F \u30EC\u30FC\u30C8\u30EA\u30DF\u30C3\u30C8\u901A\u77E5: status=${status}${at}`)]}onAssistant(event){const out=[];for(const block of contentBlocks(event)){if(block.type==="tool_use"){const name=typeof block.name==="string"?block.name:"tool";if(typeof block.id==="string")this.toolNames.set(block.id,name);this.toolCount+=1;out.push(this.line(`>> ${name}${toolDetail(
|
|
@@ -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-NZ7WI4RZ.js";import{NO_REDACT_FLAG,NO_REDACT_NOTICE,exitCodeFor,fetchAllPages,reportError}from"./chunk-
|
|
3
|
+
import{CommandModelMissingError,MAX_REPORTED_VIOLATIONS,loadCommandModelDomain,loadCommandModelRoutes,validateBody,validateQuery}from"./chunk-NZ7WI4RZ.js";import{NO_REDACT_FLAG,NO_REDACT_NOTICE,exitCodeFor,fetchAllPages,reportError}from"./chunk-D72V6QGN.js";import"./chunk-WEKECDTT.js";import{evaluateQuery}from"./chunk-GDM2QUBL.js";import{renderOutput}from"./chunk-5Q2CH4E7.js";import{redactSecretValues,withDebug}from"./chunk-YVAN3H5W.js";import{readBody}from"./chunk-HGTG5XQ7.js";
|
|
4
4
|
import{parseOperationArgs,repeatedValues}from"./chunk-IOGVQVGD.js";import"./chunk-LON7FN5A.js";import{ApiError,TwpApiClient,appendQuery}from"./chunk-FTYJZFEK.js";import"./chunk-GMBJTG6A.js";import{GLOBAL_OPTIONS_HELP}from"./chunk-TAN5I2DP.js";import{AuthSession,NotLoggedInError,SessionExpiredError,loadCredentials}from"./chunk-XNLIEUAW.js";import{httpFetch}from"./chunk-J7QYPKVK.js";import{effectiveApiUrl,resolveConfiguredOutput,resolveProfile}from"./chunk-4VZKNEVN.js";
|
|
5
5
|
import{HELP_TOKEN}from"./chunk-WBAEUHJB.js";import"./chunk-QQRJLH6B.js";import{OUTPUT_FORMATS,resolveOutputFormat}from"./chunk-K2ONOH3L.js";import"./chunk-WVS4W5FY.js";import{stripTerminalControls}from"./chunk-NHYMHCAT.js";import{DEFAULT_MAX_ITEMS,DEFAULT_MAX_PAGES,envelopePaging,positiveInteger,readEnvelopeCursor,shellQuote}from"./chunk-G4OO4M44.js";import"./chunk-II5RVJQN.js";import{EXIT_OK,NetworkError,UsageError}from"./chunk-7WSNIXTQ.js";import"./chunk-RZVI6PMW.js";
|
|
6
6
|
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: ${parsed.unknown.join(" ")}
|
|
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-
|
|
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-PI7VMII2.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",
|
|
@@ -21,17 +21,17 @@ fromEntries(Object.entries(inline??{}).filter(([k])=>CHAIN_KEYS.includes(k)));re
|
|
|
21
21
|
"updated":"unchanged",hashBefore,hashAfter:target.hash(),warnings:[]}}if(server!==null)target.replace(mergeAiConfig(target.fileLayer,inline,server));return{status:"kept",hashBefore,hashAfter:target.hash(),warnings:[server===null?`${read.problem}
|
|
22
22
|
\u73FE\u5728\u306E\u8A2D\u5B9A\uFF08AI\u5272\u5F53\u30CF\u30C3\u30B7\u30E5 ${hashBefore}\uFF09\u306E\u307E\u307E\u8D70\u308A\u307E\u3059\u3002\u78BA\u8A8D: python3 -m json.tool <file>`:`${read.problem}
|
|
23
23
|
\u6700\u5F8C\u306B\u8AAD\u3081\u305F\u5185\u5BB9\u306B\u30B5\u30FC\u30D0\u5024\u3092\u91CD\u306D\u3066\u8D70\u308A\u307E\u3059\uFF08AI\u5272\u5F53\u30CF\u30C3\u30B7\u30E5 ${target.hash()}\uFF09\u3002\u78BA\u8A8D: python3 -m json.tool <file>`]}}target.setFileLayer(read.file);const changed=target.replace(mergeAiConfig(read.file,inline,server));return{status:changed?"updated":"unchanged",hashBefore,hashAfter:target.hash(),warnings:[]}}function stableJson(value){return JSON.stringify(value,(_key,v)=>v!==
|
|
24
|
-
null&&typeof v==="object"&&!Array.isArray(v)?Object.fromEntries(Object.entries(v).sort(([a],[b])=>a
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
24
|
+
null&&typeof v==="object"&&!Array.isArray(v)?Object.fromEntries(Object.entries(v).sort(([a],[b])=>a<b?-1:a>b?1:0)):v)}var CHAIN_KEYS=["primary_rotation","fallback_chains"];var AiConfig=class _AiConfig{rotation=new Map;limitedUntil=new Map;unusableUntil=new Map;highRiskSkills;raw;fileLayerValue;constructor(raw,fileLayer=null){this.raw=raw;this.highRiskSkills=_AiConfig.highRiskSet(raw);this.fileLayerValue=fileLayer}get fileLayer(){return this.fileLayerValue}static highRiskSet(raw){return new Set((raw.
|
|
25
|
+
high_risk_skills??[]).filter(v=>typeof v==="string"&&v!==""))}setFileLayer(file){this.fileLayerValue=file}replace(next){if(stableJson(next)===stableJson(this.raw))return false;this.raw=next;this.highRiskSkills=_AiConfig.highRiskSet(next);return true}hash(){const significant=Object.fromEntries(Object.entries(this.raw).filter(([k])=>!k.startsWith("_")&&!CHAIN_KEYS.includes(k)));return createHash("sha256").update(stableJson(significant)).digest("hex").slice(0,16)}categoryForSkill(skill){const name=stripPrefix2(
|
|
26
|
+
skill);return this.raw.skill_category?.[name]??DEFAULT_CATEGORY}usesAi(ai){const rotations=this.raw.primary_rotation??BUILTIN.primary_rotation;const chains=this.raw.fallback_chains??BUILTIN.fallback_chains;const categories=new Set([DEFAULT_CATEGORY,...Object.keys(rotations),...Object.keys(chains),...Object.values(this.raw.skill_category??{})]);const matches=name=>isClaudeAi(ai)?isClaudeAi(name):name===ai;for(const category of categories){const rotation=rotations[category]??rotations[DEFAULT_CATEGORY]??
|
|
27
|
+
BUILTIN.primary_rotation[DEFAULT_CATEGORY]??[];const chain=chains[category]??chains[DEFAULT_CATEGORY]??BUILTIN.fallback_chains[DEFAULT_CATEGORY]??["claude"];for(const name of[...rotation,...chain]){if(matches(name))return true}}return false}probeCategoryFor(ai){const rotations=this.raw.primary_rotation??BUILTIN.primary_rotation;const chains=this.raw.fallback_chains??BUILTIN.fallback_chains;const categories=new Set([DEFAULT_CATEGORY,...Object.keys(rotations),...Object.keys(chains),...Object.values(
|
|
28
|
+
this.raw.skill_category??{})]);const matches=name=>isClaudeAi(ai)?isClaudeAi(name):name===ai;for(const category of categories){if(!this.isAllowed(ai,category,""))continue;const rotation=rotations[category]??rotations[DEFAULT_CATEGORY]??BUILTIN.primary_rotation[DEFAULT_CATEGORY]??[];const chain=chains[category]??chains[DEFAULT_CATEGORY]??BUILTIN.fallback_chains[DEFAULT_CATEGORY]??["claude"];if([...rotation,...chain].some(matches))return category}return null}chainFor(category){const chains=this.raw.
|
|
29
|
+
fallback_chains??BUILTIN.fallback_chains;return chains[category]??chains[DEFAULT_CATEGORY]??BUILTIN.fallback_chains[DEFAULT_CATEGORY]??["claude"]}primaryFor(category,skill){const rotations=this.raw.primary_rotation??BUILTIN.primary_rotation;const entries=rotations[category]??rotations[DEFAULT_CATEGORY]??BUILTIN.primary_rotation[DEFAULT_CATEGORY]??[];if(entries.length===0)return"";const start=this.rotation.get(category)??0;for(let i=0;i<entries.length;i+=1){const ai=entries[(start+i)%entries.length];
|
|
30
|
+
if(ai!==void 0&&this.isAllowed(ai,category,skill)){this.rotation.set(category,(start+i+1)%entries.length);return ai}}return""}isHighRisk(category,skill,priority,label){if(["verify","security","support"].includes(category))return true;if(priority==="P0"||priority==="P0.5")return true;const name=stripPrefix2(skill);if(this.highRiskSkills.has(name))return true;return HIGH_RISK_LABEL.test(label)}selectPrimary(category,skill,priority,label){if(this.isHighRisk(category,skill,priority,label)&&this.chainFor(
|
|
31
|
+
category).includes("claude")){return"claude"}return this.primaryFor(category,skill)}isAllowed(ai,category,skill){if(ai!=="gemini")return true;if(["complex","verify","security","support"].includes(category))return false;return!this.requiresGitRemote(skill)}requiresGitRemote(skill){return(this.raw.git_remote_skills??[]).includes(stripPrefix2(skill))}exclusiveSkills(){const configured=(this.raw.exclusive_skills??[]).map(s=>stripPrefix2((s??"").trim())).filter(s=>s!=="");return new Set([...configured,
|
|
32
|
+
...EXCLUSIVE_SKILL_FLOOR])}isExclusiveSkill(skill){const name=stripPrefix2(skill.trim());return name!==""&&this.exclusiveSkills().has(name)}modelFor(ai,category,env=process.env){switch(ai){case"gemini":return this.raw.gemini_models?.[category]??"";case"codex":return this.raw.codex_models?.[category]??this.raw.codex_models?.[DEFAULT_CATEGORY]??"";case"claude":return this.claudeModelFor(category,env);default:return isClaudeAi(ai)?this.claudeModelFor(category,env):""}}claudeModelFor(category,env){const table=usesBedrock(
|
|
33
|
+
env)?this.raw.claude_models_bedrock:this.raw.claude_models;return table?.[category]??env.CLAUDE_MODEL??""}maxTurnsFor(category,env=process.env){const fallback=Number.parseInt(env.CLAUDE_MAX_TURNS??"",10);const base=Number.isInteger(fallback)&&fallback>0?fallback:200;const configured=this.raw.claude_max_turns?.[category];return Number.isInteger(configured)&&(configured??0)>0?configured:base}effortFor(category,skill,env=process.env,explicit){const name=stripPrefix2(skill);const item=(explicit??"").
|
|
34
|
+
trim();if(item!==""&&EFFORTS.has(item))return{value:item,warning:null};const itemWarning=item!==""?`\u4E0D\u6B63\u306A ai_effort '${item}'\uFF08\u30A2\u30A4\u30C6\u30E0\u6307\u5B9A\uFF09\u2192 \u30B9\u30AD\u30EB\uFF0F\u30AB\u30C6\u30B4\u30EA\u65E2\u5B9A\u3092\u4F7F\u3044\u307E\u3059`:null;const raw=(name!==""?this.raw.claude_effort_by_skill?.[name]:void 0)??this.raw.claude_effort?.[category]??env.CLAUDE_EFFORT??"";if(raw==="")return{value:"",warning:itemWarning};if(EFFORTS.has(raw))return{value:raw,
|
|
35
35
|
warning:itemWarning};return{value:"",warning:`\u4E0D\u6B63\u306A effort \u5024 '${raw}'\uFF08category=${category}, skill=${name||"none"}\uFF09\u2192 \u672A\u6307\u5B9A\u3068\u3057\u3066\u6271\u3044\u307E\u3059`}}fallbackDelaySec(ai,env=process.env){const fromEnv=Number.parseInt(env[`AI_FALLBACK_DELAY_${ai.toUpperCase()}`]??"",10);if(Number.isInteger(fromEnv)&&fromEnv>=0)return fromEnv;const cfg=this.raw.fallback_delay?.[ai];return Number.isInteger(cfg)&&(cfg??0)>=0?cfg:0}cooldownDefaultSec(ai,env=process.
|
|
36
36
|
env){const fromEnv=Number.parseInt(env[`AI_COOLDOWN_${ai.toUpperCase()}`]??"",10);if(Number.isInteger(fromEnv)&&fromEnv>0)return fromEnv;const cfg=this.raw.cooldown?.[ai];if(Number.isInteger(cfg)&&(cfg??0)>0)return cfg;const backoff=Number.parseInt(env.RATE_LIMIT_BACKOFF??"",10);return Number.isInteger(backoff)&&backoff>0?backoff:DEFAULT_COOLDOWN_SEC}limitKey(ai,slot){return slot===null||slot===void 0||slot===""?ai:`${ai}@${slot}`}hasCooldownFor(ai,now=Date.now()){for(const[key,until]of this.limitedUntil){
|
|
37
37
|
if(until<=now)continue;if(key===ai||key.startsWith(`${ai}@`))return true}return false}isRateLimited(ai,now=Date.now(),slot=null){return(this.limitedUntil.get(this.limitKey(ai,slot))??0)>now}markRateLimited(ai,seconds,now=Date.now(),slot=null){const capped=Math.min(Math.max(Math.trunc(seconds),1),MAX_COOLDOWN_SEC);this.limitedUntil.set(this.limitKey(ai,slot),now+capped*1e3);return capped}markAiUnusable(ai,now=Date.now()){this.unusableUntil.set(ai,now+AI_UNUSABLE_COOLDOWN_SEC*1e3);return AI_UNUSABLE_COOLDOWN_SEC}isAiUnusable(ai,now=Date.
|
|
@@ -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-
|
|
3
|
+
import{loadDomain}from"./chunk-WEKECDTT.js";import{evaluateQuery}from"./chunk-GDM2QUBL.js";import{renderOutput}from"./chunk-5Q2CH4E7.js";import{redactSecretValues,redactSecrets,withDebug}from"./chunk-YVAN3H5W.js";import{parseOperationArgs}from"./chunk-IOGVQVGD.js";import{Resolver,requireDefaultProject}from"./chunk-LON7FN5A.js";import{ApiError,TwpApiClient,appendQuery}from"./chunk-FTYJZFEK.js";import{ResolveError}from"./chunk-GMBJTG6A.js";import{GLOBAL_OPTIONS_HELP}from"./chunk-TAN5I2DP.js";
|
|
4
4
|
import{AuthSession,NotLoggedInError,SessionExpiredError,loadCredentials}from"./chunk-XNLIEUAW.js";import{httpFetch}from"./chunk-J7QYPKVK.js";import{effectiveApiUrl,loadUserConfig,resolveConfiguredOutput,resolveProfile}from"./chunk-4VZKNEVN.js";import{HELP_TOKEN}from"./chunk-WBAEUHJB.js";import{OUTPUT_FORMATS,resolveOutputFormat}from"./chunk-K2ONOH3L.js";import{stringWidth}from"./chunk-WVS4W5FY.js";import{stripTerminalControls}from"./chunk-NHYMHCAT.js";import{
|
|
5
5
|
DEFAULT_MAX_ITEMS,DEFAULT_MAX_PAGES,nextPageNotes,positiveInteger,shellQuote}from"./chunk-G4OO4M44.js";import{ApiRejectedError,ApiResponseError,EXIT_API_CLIENT,EXIT_API_SERVER,EXIT_AUTH,EXIT_FAILURE,EXIT_OK,EXIT_USAGE,NetworkError,UsageError}from"./chunk-7WSNIXTQ.js";import fs from"fs";import path from"path";var NO_REDACT_FLAG={name:"--no-redact",summary:"\u5FDC\u7B54\u306E\u4F0F\u5B57\u5316\u3092\u89E3\u9664\u3057\u3066\u751F\u306E\u5024\u3092\u51FA\u3059\uFF08\u9375\u306E\u53D7\u3051\u53D6\u308A\u7B49\uFF09",takesValue:false};var NO_REDACT_NOTICE="\u6CE8\u8A18: --no-redact \u306E\u305F\u3081\u51FA\u529B\u3092\u4F0F\u5B57\u5316\u3057\u307E\u305B\u3093\uFF08\u7AEF\u672B\u3068\u30ED\u30B0\u306B\u5E73\u6587\u3067\u6B8B\u308A\u307E\u3059\uFF09\u3002";function withCommonFlags(flags){return flags.some(flag=>flag.
|
|
6
6
|
name===NO_REDACT_FLAG.name)?flags:[...flags,NO_REDACT_FLAG]}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?"":`
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
2
|
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
-
import{killProcessTree}from"./chunk-N2UVRM3Z.js";import{DEFAULT_CLAUDE_LAUNCHER,loadAiConfig}from"./chunk-
|
|
3
|
+
import{killProcessTree}from"./chunk-N2UVRM3Z.js";import{DEFAULT_CLAUDE_LAUNCHER,loadAiConfig}from"./chunk-AEJHDFXB.js";import{projectFileKey}from"./chunk-GY7KI5E5.js";import{findExecutable,isWindowsDriveAbsolute}from"./chunk-PMOUHEJQ.js";import{isBoolishTrue}from"./chunk-5WGOHFAS.js";import{twpHomeDir}from"./chunk-RZVI6PMW.js";function stringField(value,key,fallback,warnings){if(value===void 0||value===null)return fallback;if(typeof value!=="string"||value.trim()===""){warnings.push(`claude_launcher.${key} \u306F\u7A7A\u3067\u306A\u3044\u6587\u5B57\u5217\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u65E2\u5B9A '${fallback}' \u3092\u4F7F\u3044\u307E\u3059\uFF09`);return fallback}return value.trim()}function argvField(value,key,fallback,warnings,allowEmpty){if(value===void 0||value===null)return fallback;
|
|
4
4
|
if(!Array.isArray(value)){warnings.push(`claude_launcher.${key} \u306F\u6587\u5B57\u5217\u306E\u914D\u5217\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u65E2\u5B9A [${fallback.join(", ")}] \u3092\u4F7F\u3044\u307E\u3059\uFF09`);return fallback}for(const v of value){if(typeof v!=="string"||v.trim()===""){warnings.push(`claude_launcher.${key} \u306E\u8981\u7D20\u306F\u7A7A\u3067\u306A\u3044\u6587\u5B57\u5217\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u65E2\u5B9A [${fallback.
|
|
5
5
|
join(", ")}] \u3092\u4F7F\u3044\u307E\u3059\uFF09`);return fallback}}if(value.length===0&&!allowEmpty){warnings.push(`claude_launcher.${key} \u306F1\u3064\u4EE5\u4E0A\u306E\u5F15\u6570\u304C\u8981\u308A\u307E\u3059\uFF08\u65E2\u5B9A [${fallback.join(", ")}] \u3092\u4F7F\u3044\u307E\u3059\uFF09`);return fallback}return value.map(v=>v.trim())}function probeMatchField(value,warnings){const raw=stringField(value,"probe_match",DEFAULT_CLAUDE_LAUNCHER.probeMatch,warnings);try{new RegExp(raw,"m")}catch(err){
|
|
6
6
|
warnings.push(`claude_launcher.probe_match \u306F\u6B63\u898F\u8868\u73FE\u3068\u3057\u3066\u89E3\u91C8\u3067\u304D\u307E\u305B\u3093\uFF08${err.message}\uFF09\u3002\u65E2\u5B9A '${DEFAULT_CLAUDE_LAUNCHER.probeMatch}' \u3092\u4F7F\u3044\u307E\u3059`);return DEFAULT_CLAUDE_LAUNCHER.probeMatch}return raw}var NOT_YET_APPLIED=[{key:"probe",get:c=>c.probe},{key:"probe_match",get:c=>c.probeMatch},{key:"exec_args",get:c=>c.execArgs},{key:"active_args",get:c=>c.activeArgs}];function sameAsDefault(key,parsed){
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
2
|
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
-
import{DEFAULT_CLAUDE_LAUNCHER,activeSlotPath,detectClaudeAutoSwitch,spawnSyncResolved}from"./chunk-
|
|
3
|
+
import{DEFAULT_CLAUDE_LAUNCHER,activeSlotPath,detectClaudeAutoSwitch,spawnSyncResolved}from"./chunk-AEJHDFXB.js";import{defaultIsExecutableFile,findOnPath,joinFor}from"./chunk-PMOUHEJQ.js";import{isBoolishTrue}from"./chunk-5WGOHFAS.js";import{spawnSync}from"child_process";import{createHash}from"crypto";import fs from"fs";import os from"os";import path from"path";var DETECTABLE_AIS=["claude","codex","gemini","copilot"];function isDetectableAi(value){return DETECTABLE_AIS.includes(value)}function isSelectable(d){return d.installed&&d.blockedReason===null&&d.auth!=="unauthenticated"}function resolveDetectDeps(deps={}){return resolve(deps)}function resolve(deps){const platform=deps.platform??process.platform;return{run:deps.run??spawnSync,env:deps.env??process.env,homedir:deps.homedir??os.homedir,isExecutableFile:deps.isExecutableFile??(p=>defaultIsExecutableFile(p,platform)),existsSync:deps.existsSync??fs.existsSync,readFileSync:deps.readFileSync??(p=>fs.readFileSync(p,"utf8")),platform,
|
|
4
4
|
now:deps.now??Date.now,launcherBin:nonEmptyBin(deps.launcherBin)??DEFAULT_CLAUDE_LAUNCHER.bin}}function nonEmptyBin(value){const t=value?.trim();return t===void 0||t===""?void 0:t}var PROBE_TIMEOUT_MS=1e4;function oneLine(text){return text.replace(/\s+/g," ").trim()}function claudeConfigDir(d){const lookup={env:d.env,platform:d.platform};const bin=nonEmptyBin(d.launcherBin)??DEFAULT_CLAUDE_LAUNCHER.bin;const cas=detectClaudeAutoSwitch(bin,d.run,lookup);if(cas!==null){const active=activeSlotPath(
|
|
5
5
|
cas,d.run,lookup);if(active!==null){return{dir:active,via:`${bin} ${DEFAULT_CLAUDE_LAUNCHER.activeArgs.join(" ")}`}}}const explicit=d.env.CLAUDE_CONFIG_DIR?.trim();if(explicit!==void 0&&explicit!=="")return{dir:explicit,via:"CLAUDE_CONFIG_DIR"};return{dir:joinFor(d.platform)(d.homedir(),".claude"),via:"\u65E2\u5B9A\uFF08~/.claude\uFF09"}}var CLAUDE_AUTH_ENV=[{key:"ANTHROPIC_API_KEY",label:"ANTHROPIC_API_KEY",boolish:false},{key:"ANTHROPIC_AUTH_TOKEN",label:"ANTHROPIC_AUTH_TOKEN",boolish:false},{
|
|
6
6
|
key:"CLAUDE_CODE_OAUTH_TOKEN",label:"CLAUDE_CODE_OAUTH_TOKEN",boolish:false},{key:"AWS_BEARER_TOKEN_BEDROCK",label:"AWS_BEARER_TOKEN_BEDROCK",boolish:false},{key:"CLAUDE_CODE_USE_BEDROCK",label:"CLAUDE_CODE_USE_BEDROCK\uFF08AWS \u8CC7\u683C\u60C5\u5831\u3067\u52D5\u304D\u307E\u3059\uFF09",boolish:true},{key:"CLAUDE_CODE_USE_VERTEX",label:"CLAUDE_CODE_USE_VERTEX\uFF08GCP \u8CC7\u683C\u60C5\u5831\u3067\u52D5\u304D\u307E\u3059\uFF09",boolish:true}];function envEnabled(raw,boolish){if(boolish)return isBoolishTrue(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
2
|
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
-
import{describeError}from"./chunk-QWSXHHFT.js";import{stripTerminalControls}from"./chunk-NHYMHCAT.js";import{CHAIN_KEYS,reloadAiConfig}from"./chunk-
|
|
3
|
+
import{describeError}from"./chunk-QWSXHHFT.js";import{stripTerminalControls}from"./chunk-NHYMHCAT.js";import{CHAIN_KEYS,reloadAiConfig}from"./chunk-AEJHDFXB.js";import{isPrivateProjectId}from"./chunk-GY7KI5E5.js";import fs from"fs";import path from"path";var PROMPT_KEYS=["charter","charter_prefix","charter_suffix","plan_preamble","step_budget","non_interactive_note","safe_mode_note"];function parseServerSettings(res){const json=res.json;if(json===null||typeof json!=="object"||Array.isArray(json))return null;const top=json;const data=top["data"];const b=data!==null&&typeof data==="object"&&!Array.isArray(data)&&"revision"in data?data:top;const revision=b["revision"];if(typeof revision!=="number"||!Number.isInteger(revision)||revision<0)return null;
|
|
4
4
|
const rawAi=b["ai"];const ai=rawAi!==null&&typeof rawAi==="object"&&!Array.isArray(rawAi)?Object.fromEntries(Object.entries(rawAi).filter(([,v])=>v!==null&&v!==void 0)):{};const prompts={};const rawPrompts=b["prompts"];if(rawPrompts!==null&&typeof rawPrompts==="object"&&!Array.isArray(rawPrompts)){for(const key of PROMPT_KEYS){const v=rawPrompts[key];if(typeof v==="string")prompts[key]=v}}return{revision,ai,prompts}}function formatConfigHash(aiHash,revision,ai,charter){return`${aiHash};r=${revision}\
|
|
5
5
|
;ai=${ai};charter=${charter}`}function renderStepBudget(template,vars){return template.replaceAll("{timeout_min}",String(vars.timeoutMin)).replaceAll("{soft_min}",String(vars.softMin)).replaceAll("{wrap_up_min}",String(vars.wrapUpMin))}var LoopSettingsApplier=class{constructor(deps){this.deps=deps}deps;last=null;lastWarning="";lastAiWarning="";lastSummary="";serverAiApplied=false;lastSafeWarning="";async apply(){const{config,log}=this.deps;const outcome=await this.fetch();const warning=outcome.warning??
|
|
6
6
|
"";if(warning!==""&&warning!==this.lastWarning)log(` \u26A0\uFE0F ${warning}`);else if(warning===""&&this.lastWarning!=="")log("\u30EB\u30FC\u30D7\u8A2D\u5B9A\u3092\u30B5\u30FC\u30D0\u304B\u3089\u518D\u3073\u53D6\u5F97\u3067\u304D\u308B\u3088\u3046\u306B\u306A\u308A\u307E\u3057\u305F");this.lastWarning=warning;const settings=outcome.settings;config.serverPrompts=settings?.prompts??{};const safeNote=config.serverPrompts.safe_mode_note;const safeWarning=config.safeMode&&safeNote!==void 0?safeNote===
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
2
|
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
-
var LOADERS={"agent-loop":async()=>(await import("./agent-loop-
|
|
3
|
+
var LOADERS={"agent-loop":async()=>(await import("./agent-loop-ADP6AOWX.js")).agentLoopDomain,attendance:async()=>(await import("./attendance-LM3Q4TAU.js")).attendanceDomain,backlog:async()=>(await import("./backlog-7BCJWAE2.js")).backlogDomain,department:async()=>(await import("./department-XVOQ254P.js")).departmentDomain,inquiry:async()=>(await import("./inquiry-EY5XY4UP.js")).inquiryDomain,"job-title":async()=>(await import("./job-title-QHIKTYLH.js")).jobTitleDomain,leave:async()=>(await import("./leave-C6K724AF.js")).
|
|
4
4
|
leaveDomain,media:async()=>(await import("./media-BFCZJMEU.js")).mediaDomain,notification:async()=>(await import("./notification-6T22IDIZ.js")).notificationDomain,position:async()=>(await import("./position-SBZD7AFE.js")).positionDomain,project:async()=>(await import("./project-RAYRR6JS.js")).projectDomain,shift:async()=>(await import("./attendance-lists-PR6NQDQB.js")).shiftDomain,storage:async()=>(await import("./storage-ANKKJJJO.js")).storageDomain,task:async()=>(await import("./task-GKHDJZLP.js")).
|
|
5
5
|
taskDomain,user:async()=>(await import("./user-GPAPJUHB.js")).userDomain,workchange:async()=>(await import("./attendance-lists-PR6NQDQB.js")).workchangeDomain,workflow:async()=>(await import("./workflow-UNOJLZ4I.js")).workflowDomain};async function loadDomain(name){return LOADERS[name]()}export{loadDomain};
|
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-TAN5I2DP.js";import{parseArgv}from"./chunk-AGEDFRUQ.js";import"./chunk-NAUH75MM.js";import"./chunk-WBAEUHJB.js";import"./chunk-QQRJLH6B.js";import"./chunk-VSJBJXZO.js";var VERSION=true?"0.32.
|
|
4
|
+
import{GLOBAL_OPTIONS_HELP}from"./chunk-TAN5I2DP.js";import{parseArgv}from"./chunk-AGEDFRUQ.js";import"./chunk-NAUH75MM.js";import"./chunk-WBAEUHJB.js";import"./chunk-QQRJLH6B.js";import"./chunk-VSJBJXZO.js";var VERSION=true?"0.32.1":"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
|
|
@@ -297,14 +297,14 @@ TUI \u5185:
|
|
|
297
297
|
\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
|
|
298
298
|
`;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
|
|
299
299
|
`);process.exit(1)}ignoreEpipe(process.stdout);ignoreEpipe(process.stderr);if(process.env["TWP_AUTO_UPDATE_WORKER"]==="1"){const{runAutoUpdateWorker}=await import("./auto-update-worker-Y44TD6FD.js");await runAutoUpdateWorker().catch(()=>void 0);return}const[first,...rest]=process.argv.slice(2);if(first==="__complete"||first==="completion"){const completion=await import("./completion-RGC3UZFI.js");if(first==="completion"){process.exitCode=completion.runCompletion(rest,process.stdout,process.stderr);return}
|
|
300
|
-
const[{loadDomain},{loadUserConfig}]=await Promise.all([import("./registry-
|
|
300
|
+
const[{loadDomain},{loadUserConfig}]=await Promise.all([import("./registry-RTZUE4RG.js"),import("./config-3CNEQ7KN.js")]);process.exitCode=await completion.runComplete(rest,process.stdout,{loadDomain,profileNames:()=>Object.keys(loadUserConfig().profiles??{})});return}if(first==="configure"){const autoUpdate2=await import("./auto-update-JNSBIQM6.js");autoUpdate2.registerRunning();autoUpdate2.onStartup(VERSION);const{runConfigure}=await import("./configure-PIOFJFL5.js");process.exitCode=
|
|
301
301
|
await runConfigure(rest);return}const args=parseArgv(process.argv.slice(2));if(args.command==="version"){process.stdout.write(`${VERSION}
|
|
302
302
|
`);return}if(args.command==="help"){process.stdout.write(HELP);return}if(args.unknown.length>0){process.stderr.write(`\u4E0D\u660E\u306A\u5F15\u6570: ${args.unknown.join(" ")}
|
|
303
303
|
|
|
304
|
-
${HELP}`);process.exitCode=2;return}const autoUpdate=await import("./auto-update-JNSBIQM6.js");autoUpdate.registerRunning();if(args.command==="task-loop"){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-
|
|
305
|
-
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},version:VERSION});return}if(args.command==="api"){const{runApiCommand}=await import("./api-command-
|
|
306
|
-
void 0?{output:args.output}:{},...args.query!==void 0?{query:args.query}:{},dryRun:args.dryRun,debug:args.debug,yes:args.yes},version:VERSION});return}if(args.command==="update"){const{runUpdate}=await import("./update-MAQJ6VWV.js");process.exitCode=await runUpdate({...args.profile!==void 0?{profile:args.profile}:{},version:VERSION});return}if(args.command==="login"||args.command==="logout"||args.command==="whoami"){const{runLogin,runLogout,runWhoami}=await import("./commands-
|
|
307
|
-
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}if(args.command==="task-loop"){const{runTaskLoop}=await import("./commands-
|
|
304
|
+
${HELP}`);process.exitCode=2;return}const autoUpdate=await import("./auto-update-JNSBIQM6.js");autoUpdate.registerRunning();if(args.command==="task-loop"){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-PI7VMII2.js");process.exitCode=await runDomain({domain:args.domain,...args.operation!==void 0?{operation:args.operation}:{},argv:args.domainArgv,help:args.
|
|
305
|
+
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},version:VERSION});return}if(args.command==="api"){const{runApiCommand}=await import("./api-command-TJFXCLPS.js");process.exitCode=await runApiCommand({argv:args.domainArgv,help:args.domainHelp,globals:{...args.profile!==void 0?{profile:args.profile}:{},...args.output!==
|
|
306
|
+
void 0?{output:args.output}:{},...args.query!==void 0?{query:args.query}:{},dryRun:args.dryRun,debug:args.debug,yes:args.yes},version:VERSION});return}if(args.command==="update"){const{runUpdate}=await import("./update-MAQJ6VWV.js");process.exitCode=await runUpdate({...args.profile!==void 0?{profile:args.profile}:{},version:VERSION});return}if(args.command==="login"||args.command==="logout"||args.command==="whoami"){const{runLogin,runLogout,runWhoami}=await import("./commands-4DNJTCOG.js");
|
|
307
|
+
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}if(args.command==="task-loop"){const{runTaskLoop}=await import("./commands-MW7XRREL.js");process.exitCode=await runTaskLoop(
|
|
308
308
|
{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,charterOp:args.charterOp,charterInput:args.charterFile,charterOutput:args.charterOut,charterRevision:args.charterRevision,
|
|
309
309
|
skillOp:args.skillOp,skillName:args.skillName,skillAll:args.skillAll,skillDir:args.skillDir,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-IZCRIJJJ.js");process.exitCode=await runOneShot({prompt:args.prompt??"",fromStdin:args.promptFromStdin,mode:args.mode??"dev",...args.permissionMode!==void 0?{permissionMode:args.permissionMode}:{},allowedTools:args.
|
|
310
|
-
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-
|
|
310
|
+
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-6ULNAHKL.js");await startTui({mode:args.mode,permissionMode:args.permissionMode,allowedTools:args.allowedTools,disallowedTools:args.disallowedTools,model:args.model,profile:args.profile,noTui:args.noTui||!process.stdout.isTTY,doctor:args.doctor,version:VERSION})}await main();
|
|
@@ -50,7 +50,7 @@ ${err.hint?`${err.hint}
|
|
|
50
50
|
`);return 1}writeErr(`\u30A8\u30E9\u30FC: ${err.message}
|
|
51
51
|
`);return 1}}async function runLogin(options){return run(async()=>{const profile=resolveProfile(options.profile);const io=makeIo(options.cliVersion);if(options.method==="password"){await passwordLogin(profile,{tenantCode:options.tenant??void 0},process.env,io)}else if(options.method==="token"){await tokenLogin(profile,process.env,io)}else{await browserLogin(profile,process.env,io,{noBrowser:options.noBrowser})}})}async function runLogout(options){return run(async()=>{const profile=resolveProfile(
|
|
52
52
|
options.profile);const creds=loadCredentials(profile.name);if(!creds){writeOut(`\u30D7\u30ED\u30D5\u30A1\u30A4\u30EB\u300C${profile.name}\u300D\u306F\u30ED\u30B0\u30A4\u30F3\u3057\u3066\u3044\u307E\u305B\u3093\u3002
|
|
53
|
-
`);return}const{describeLogoutImpact,findLoopsUsingProfile}=await import("./logout-guard-
|
|
53
|
+
`);return}const{describeLogoutImpact,findLoopsUsingProfile}=await import("./logout-guard-XYVKR47G.js");const found=findLoopsUsingProfile(profile.name,options.logoutGuard);if(found.users.length>0||found.undetermined.length>0){writeErr(describeLogoutImpact(profile.name,found,options.force===true));if(options.force!==true)throw new LogoutRefusedError}const apiUrl=effectiveApiUrl(profile,creds.api_url);const revoked=await httpFetch(`${apiUrl}/api/v2/auth/logout`,{method:"POST",headers:{Accept:"applic\
|
|
54
54
|
ation/json",Authorization:`Bearer ${creds.token}`}}).then(res=>res.ok,()=>false);await deleteCredentials(profile.name);writeOut(`\u2705 \u30ED\u30B0\u30A2\u30A6\u30C8\u3057\u307E\u3057\u305F\uFF08\u30D7\u30ED\u30D5\u30A1\u30A4\u30EB: ${profile.name} / \u30C8\u30FC\u30AF\u30F3: ${maskToken(creds.token)}\uFF09
|
|
55
55
|
`);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){
|
|
56
56
|
const{resolveOutputFormat,OUTPUT_FORMATS}=await import("./format-NMW6Y2E5.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(
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
2
|
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
-
import{LoopSettingsApplier,renderStepBudget}from"./chunk-
|
|
3
|
+
import{LoopSettingsApplier,renderStepBudget}from"./chunk-VBX44RKP.js";import{EngineNotConfiguredError,NoopEngine,UnknownEngineError,aiUnavailableLabel,assertKnownEngine,failureHint,isAiUnavailable,needsHumanToRestoreAi}from"./chunk-ZOOEH7ZE.js";import{ServerSkillCatalog,formatSkillOrigins}from"./chunk-ONTK2FR4.js";import"./chunk-VK2Z4QGC.js";import{claudeConfigDir,resolveDetectDeps}from"./chunk-T4QZO6RQ.js";import"./chunk-P4AEFKLM.js";import"./chunk-VRBI2NPI.js";
|
|
4
4
|
import{REQUIRE_ZERO_STATUS,ScheduleApi,collectDue,gateStatus,nowInZone,parseCounts,promptSection}from"./chunk-RFBFR567.js";import{AgentLoopApi,describeError,filterByStatus,isPermanent,pick,pickString}from"./chunk-QWSXHHFT.js";import{InstanceLock,buildLockOwner,defaultIsLoopProcess,writeLockOwner}from"./chunk-3WHC4FSG.js";import{resolveProjectRef,uuidProjectIdPolicy}from"./chunk-GMBJTG6A.js";import{AuthSession}from"./chunk-XNLIEUAW.js";import{httpFetch}from"./chunk-J7QYPKVK.js";
|
|
5
5
|
import{compareVersionCores,parseVersionCore}from"./chunk-DXXFUNYN.js";import{effectiveApiUrl,resolveProfile}from"./chunk-4VZKNEVN.js";import{stripTerminalControls}from"./chunk-NHYMHCAT.js";import{duplicateTaskKeyDropReason,excludedKeyInArgs,extractPlanJson,parseOpsCount,parsePlanExcludeKeys,placeholderTaskKey,releaseDeployDropReason,stepToItem,zeroTargetDropReasons}from"./chunk-VCZVITWG.js";import{CapacityReporter,buildLoopConfig,describeOperations,evaluateOwnership,formatHookIds,
|
|
6
|
-
formatHookWiring,localDate,loopStateDir,runHook,runPrefetch,runPreflight}from"./chunk-
|
|
6
|
+
formatHookWiring,localDate,loopStateDir,runHook,runPrefetch,runPreflight}from"./chunk-QVPU4HHG.js";import{killProcessTree}from"./chunk-N2UVRM3Z.js";import{exclusiveInflightEntries,formatExclusiveEntry,normalizeSkillName,skillOfItem,spawnSyncResolved}from"./chunk-AEJHDFXB.js";import{PRIVATE_PROJECT_REF,isPrivateProjectId,isPrivateProjectRef,privateProjectId,projectFileKey}from"./chunk-GY7KI5E5.js";import{isTaskKey}from"./chunk-II5RVJQN.js";import"./chunk-7WSNIXTQ.js";
|
|
7
7
|
import{joinFor}from"./chunk-PMOUHEJQ.js";import"./chunk-5WGOHFAS.js";import{twpHomeDir}from"./chunk-RZVI6PMW.js";import"./chunk-VSJBJXZO.js";import fs10 from"fs";import path8 from"path";import fs from"fs";import path from"path";var LoopLogger=class{constructor(runnerId,logFile,out=process.stdout,now=()=>new Date){this.runnerId=runnerId;this.out=out;this.now=now;if(logFile){fs.mkdirSync(path.dirname(logFile),{recursive:true});this.stream=fs.createWriteStream(logFile,{flags:"a"})}}runnerId;out;now;stream=null;log(message){const d=this.now();const ts=`${d.getFullYear()}-${pad(d.getMonth()+1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`;const line=`[${ts}] [${this.runnerId}] ${stripTerminalControls(
|
|
8
8
|
message)}
|
|
9
9
|
`;this.out.write(line);this.stream?.write(line)}separator(){this.log("=".repeat(60))}close(){this.stream?.end();this.stream=null}};function pad(n){return String(n).padStart(2,"0")}function rotateLogs(dir,retentionDays,now=Date.now()){if(retentionDays<=0)return;const cutoff=now-retentionDays*864e5;let entries;try{entries=fs.readdirSync(dir)}catch{return}for(const name of entries){if(!/^(agent-loop|task-loop|step|plan|schedule-enqueued)-.*\.(log|txt)$/.test(name))continue;const file=path.join(dir,
|
|
@@ -312,12 +312,12 @@ const startedAtMs=now();let warned="";let done=false;const check=()=>{if(done)re
|
|
|
312
312
|
decision.key)return;warned=decision.key;handlers.onWarn(decision.reason);return}done=true;const recorded=writeRestartAttempt(opts.stateDir,opts.projectKey,{from:decision.from,to:decision.to,at:new Date(now()).toISOString()},opts.store);if(!recorded){handlers.onWarn(`\u518D\u8D77\u52D5\u8A18\u9332\u3092\u66F8\u3051\u307E\u305B\u3093\u3067\u3057\u305F\uFF08${restartAttemptPath(opts.stateDir,opts.projectKey)}\uFF09\u3002\u540C\u3058\u7248\u30C9\u30EA\u30D5\u30C8\u304C\u89E3\u6D88\u3057\u306A\u3044\u5834\u5408\u3001\u518D\u8D77\u52D5\u3092\u7E70\u308A\u8FD4\u3059\u9632\u6CE2\u5824\u304C\u52B9\u304D\u307E\u305B\u3093`)}
|
|
313
313
|
handlers.onRestart({from:decision.from,to:decision.to})};const timer=setInterval(check,opts.intervalMs??DRIFT_POLL_MS);timer.unref?.();return{stop:()=>{done=true;clearInterval(timer)},check}}import fs9 from"fs";import path7 from"path";var POLL_MS=1e3;var MAX_STOP_BYTES=4096;var MAX_AT_LENGTH=64;function markerPath(lockDir2,kind){return path7.join(lockDir2,kind)}function requestMarker(lockDir2,kind,pid,deps={}){const target=markerPath(lockDir2,kind);const write=deps.writeFileSync??((p,d)=>fs9.writeFileSync(p,d,{flag:"wx",mode:384}));const now=deps.now??(()=>new Date);clearMarker(lockDir2,kind,deps);try{write(target,`${JSON.stringify({pid,at:now().toISOString()})}
|
|
314
314
|
`);return{ok:true}}catch(err){const e=err;return{ok:false,reason:e.code??"UNKNOWN"}}}function readMarker(lockDir2,kind,deps={}){const target=markerPath(lockDir2,kind);const read=deps.readFileSync??(p=>fs9.readFileSync(p,"utf8"));const size=deps.statSize??(p=>fs9.statSync(p).size);let raw;try{if(size(target)>MAX_STOP_BYTES)return null;raw=read(target)}catch{return null}if(raw.length>MAX_STOP_BYTES)return null;try{const parsed=JSON.parse(raw);if(typeof parsed!=="object"||parsed===null)return null;const pid=parsed.pid;const at=parsed.at;if(typeof pid!=="number"||!Number.isInteger(pid)||
|
|
315
|
-
pid<=0)return null;return{pid,at:sanitizeAt(at)}}catch{return null}}function sanitizeAt(at){if(typeof at!=="string")return"";return at.replace(/[\u0000-\u001f\u007f]/g," ").slice(0,MAX_AT_LENGTH)}function clearMarker(lockDir2,kind,deps={}){const rm=deps.rmSync??(p=>fs9.rmSync(p,{recursive:true,force:true}));try{rm(markerPath(lockDir2,kind))}catch{}}function watchMarker(lockDir2,kind,selfPid,onStop,deps={}){let fired=false;const timer=setInterval(()=>{if(fired)return;const req=readMarker(lockDir2,kind,deps);if(req===null||req.pid!==selfPid)return;fired=true;onStop(req)},deps.intervalMs??POLL_MS);timer.unref?.();return()=>{fired=true;clearInterval(timer)}}function safe(s){return stripTerminalControls(s)}function compactTimestamp(at=new Date){const p2=n=>String(n).padStart(2,"0");return`${at.getFullYear()}${p2(at.getMonth()+1)}${p2(at.getDate())}-${p2(at.getHours())}${p2(at.getMinutes())}${p2(at.getSeconds())}`}async function buildEngine(config,log){if(config.engine==="noop")return new NoopEngine;const{DispatchEngine}=await import("./ai-dispatch-
|
|
315
|
+
pid<=0)return null;return{pid,at:sanitizeAt(at)}}catch{return null}}function sanitizeAt(at){if(typeof at!=="string")return"";return at.replace(/[\u0000-\u001f\u007f]/g," ").slice(0,MAX_AT_LENGTH)}function clearMarker(lockDir2,kind,deps={}){const rm=deps.rmSync??(p=>fs9.rmSync(p,{recursive:true,force:true}));try{rm(markerPath(lockDir2,kind))}catch{}}function watchMarker(lockDir2,kind,selfPid,onStop,deps={}){let fired=false;const timer=setInterval(()=>{if(fired)return;const req=readMarker(lockDir2,kind,deps);if(req===null||req.pid!==selfPid)return;fired=true;onStop(req)},deps.intervalMs??POLL_MS);timer.unref?.();return()=>{fired=true;clearInterval(timer)}}function safe(s){return stripTerminalControls(s)}function compactTimestamp(at=new Date){const p2=n=>String(n).padStart(2,"0");return`${at.getFullYear()}${p2(at.getMonth()+1)}${p2(at.getDate())}-${p2(at.getHours())}${p2(at.getMinutes())}${p2(at.getSeconds())}`}async function buildEngine(config,log){if(config.engine==="noop")return new NoopEngine;const{DispatchEngine}=await import("./ai-dispatch-KXRNV4UZ.js");const{DEFAULT_PREFLIGHT_HOSTS}=await import("./ai-dispatch-KXRNV4UZ.js");const extraHosts=config.
|
|
316
316
|
operations.preflightHosts;return new DispatchEngine(config.ai,log,{workspace:config.workspace,charterFile:config.charterFile??void 0,charterEnabled:config.charterEnabled,...config.charterPrefix===null?{}:{charterPrefix:config.charterPrefix},...config.charterSuffix===null?{}:{charterSuffix:config.charterSuffix},serverPrompts:()=>config.serverPrompts??{},compileCommand:config.compileCommand??void 0,skillOverlayDir:path8.join(config.stateDir,"skill-overlay",projectFileKey(config.projectId)),launcherBin:config.
|
|
317
317
|
claudeLauncher.bin,...extraHosts.length>0?{preflightHosts:[...DEFAULT_PREFLIGHT_HOSTS,...extraHosts]}:{}})}function lockDir(config){return path8.join(config.stateDir,`task-loop-${projectFileKey(config.projectId)}.lock.d`)}async function runTaskLoop(opts){if(opts.action==="stop")return await stopLoop(opts);const profile=resolveProfile(opts.profile);let creds;try{creds=new AuthSession(profile.name,profile.apiUrl).loadOrThrow()}catch(err){process.stderr.write(`${err.message}
|
|
318
318
|
`);return 1}const apiUrl=effectiveApiUrl(profile,creds.api_url);const session=new AuthSession(profile.name,apiUrl);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");return 2}const projectApi=new ProjectApi(apiUrl,session);let project;try{project=await projectApi.resolve(projectRef)}catch(err){process.stderr.write(`${err.
|
|
319
319
|
message}
|
|
320
|
-
`);return 1}const projectId=project.id;if(opts.action==="setup"){const{runSetup,parseAiList}=await import("./setup-
|
|
320
|
+
`);return 1}const projectId=project.id;if(opts.action==="setup"){const{runSetup,parseAiList}=await import("./setup-CVXGKBTY.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(" / ")}
|
|
321
321
|
`);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.
|
|
322
322
|
write("charter \u306B\u306F push \u304B pull \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}const{runCharterCommand}=await import("./charter-command-ULFOEZWE.js");return runCharterCommand({api:new AgentLoopApi({apiUrl,projectId,session})},{op:opts.
|
|
323
323
|
charterOp,file:opts.charterInput,out:opts.charterOutput,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 \u304B pull \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\u30B9\u30AD\u30EB\u5B9A\u7FA9\u306E\u8A2D\u5B9A\u304C\u3042\u308A\u307E\u305B\u3093\n");
|
|
@@ -338,7 +338,7 @@ value:null};const shutdown=async()=>{if(shuttingDown)return;shuttingDown=true;st
|
|
|
338
338
|
once("SIGINT",onSignal);process.once("SIGTERM",onSignal);process.once("SIGHUP",onSignal);stopWatcher=watchMarker(lockDir(config),"stop",process.pid,req=>{log.log(`\u505C\u6B62\u8981\u6C42\u3092\u53D7\u3051\u53D6\u308A\u307E\u3057\u305F\uFF08${req.at||"\u6642\u523B\u4E0D\u660E"}\uFF09\u3002\u7D42\u4E86\u3057\u307E\u3059...`);stopWatcher?.();drainWatcher?.();driftWatcher?.();void shutdown().catch(()=>void 0).then(()=>process.exit(130))});drainWatcher=watchMarker(lockDir(config),"drain",process.pid,
|
|
339
339
|
req=>{drainWatcher?.();if(loop===null){pendingDrain.value={reason:`stop --drain\u30FB${req.at||"\u6642\u523B\u4E0D\u660E"}`,exitCode:0};log.log(`\u30C9\u30EC\u30A4\u30F3\u8981\u6C42\u3092\u53D7\u3051\u53D6\u308A\u307E\u3057\u305F\uFF08${req.at||"\u6642\u523B\u4E0D\u660E"}\uFF09\u3002\u8D77\u52D5\u51E6\u7406\u306E\u5B8C\u4E86\u5F8C\u306B\u53CD\u6620\u3057\u307E\u3059\u3002`);return}loop.requestDrain(`stop --drain\u30FB${req.at||"\u6642\u523B\u4E0D\u660E"}`)});if(installed!==null){const watch=watchVersionDrift(
|
|
340
340
|
{runningVersion:opts.version,stateDir:config.stateDir,projectKey:projectFileKey(config.projectId),supervised:autoRestart.supervised,disabled:autoRestart.disabled},{onWarn:reason=>log.log(`\u26A0\uFE0F ${reason}`),onRestart:({from,to})=>{driftWatcher?.();log.log(`\u7248\u30C9\u30EA\u30D5\u30C8\u3092\u691C\u51FA\u3057\u307E\u3057\u305F\uFF08${from} \u2192 ${to}\uFF09\u3002`);log.log(` \u5B9F\u884C\u4E2D\u306E\u30A2\u30A4\u30C6\u30E0\u3092\u5B8C\u8D70\u3055\u305B\u3066\u304B\u3089\u7D42\u4E86\u3057\u307E\u3059\uFF08\u7D42\u4E86\u30B3\u30FC\u30C9 ${EXIT_VERSION_DRIFT}\
|
|
341
|
-
\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-
|
|
341
|
+
\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-MVZEW2QI.js");const settings=new LoopSettingsApplier2(
|
|
342
342
|
{api,config,log:m=>log.log(m)});await settings.apply();const{ServerSkillCatalog:ServerSkillCatalog2}=await import("./server-skills-MW6YNLNT.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.
|
|
343
343
|
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()}
|
|
344
344
|
return exitCode}async function showStatus(api,config){const out={write:text=>process.stdout.write(stripTerminalControls(text))};out.write(`\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8: ${config.projectRef}\uFF08${config.projectId}\uFF09
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
2
|
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
-
import{defaultIsLoopProcess,readLockOwner,sameTwpHome}from"./chunk-3WHC4FSG.js";import{stripTerminalControls}from"./chunk-NHYMHCAT.js";import{loopStateDir}from"./chunk-
|
|
3
|
+
import{defaultIsLoopProcess,readLockOwner,sameTwpHome}from"./chunk-3WHC4FSG.js";import{stripTerminalControls}from"./chunk-NHYMHCAT.js";import{loopStateDir}from"./chunk-QVPU4HHG.js";import"./chunk-N2UVRM3Z.js";import"./chunk-AEJHDFXB.js";import"./chunk-GY7KI5E5.js";import"./chunk-PMOUHEJQ.js";import"./chunk-5WGOHFAS.js";import{twpHomeDir}from"./chunk-RZVI6PMW.js";import"./chunk-VSJBJXZO.js";import fs from"fs";import path from"path";var PIDLESS_GRACE_MS=6e4;function defaultStateDirs(env){const dirs=[loopStateDir(env),loopStateDir({})].map(d=>path.resolve(d));return[...new Set(dirs)]}function readPidFile(lockDir){try{const raw=fs.readFileSync(path.join(lockDir,"pid"),"utf8").split("\n")[0]?.trim()??"";const n=Number.parseInt(raw,10);return{pid:Number.isInteger(n)&&n>0?n:null,error:null}}catch(err){const code=err.code;return{pid:null,error:code==="ENOENT"?null:code??err.message}}}function findLoopsUsingProfile(profileName,deps={}){
|
|
4
4
|
const env=deps.env??process.env;const now=deps.now??Date.now;const isLoopProcess=deps.isLoopProcess??defaultIsLoopProcess;const myHome=twpHomeDir(env);const result={users:[],undetermined:[]};for(const stateDir of deps.stateDirs??defaultStateDirs(env)){let dirs;try{dirs=fs.readdirSync(stateDir).filter(d=>/^task-loop-.*\.lock\.d$/.test(d))}catch(err){if(err.code==="ENOENT")continue;result.undetermined.push({pid:null,lockDir:stateDir,reason:`\u30ED\u30C3\u30AF\u306E\u7F6E\u304D\u5834\u6240\u3092\u8AAD\u3081\u307E\u305B\u3093\uFF08${err.
|
|
5
5
|
code??err.message}\uFF09`});continue}for(const dir of dirs){const lockDir=path.join(stateDir,dir);const pidFile=readPidFile(lockDir);if(pidFile.error!==null){result.undetermined.push({pid:null,lockDir,reason:`pid \u3092\u8AAD\u3081\u307E\u305B\u3093\uFF08${pidFile.error}\uFF09`});continue}const owner=readLockOwner(lockDir);let pid=pidFile.pid;if(pid===null){if(owner.ok){pid=owner.owner.pid}else{let ageMs=null;try{ageMs=now()-fs.statSync(lockDir).mtimeMs}catch{}if(ageMs!==null&&ageMs>=PIDLESS_GRACE_MS)
|
|
6
6
|
continue;result.undetermined.push({pid:null,lockDir,reason:"\u30ED\u30C3\u30AF\u306B pid \u304C\u3042\u308A\u307E\u305B\u3093\uFF08\u8D77\u52D5\u76F4\u5F8C\u306E\u53EF\u80FD\u6027\uFF09"});continue}}if(!isLoopProcess(pid))continue;if(!owner.ok){result.undetermined.push({pid,lockDir,reason:owner.reason});continue}if(owner.owner.pid!==pid){result.undetermined.push({pid,lockDir,reason:`\u6240\u6709\u8005\u306E\u8A18\u9332\uFF08pid=${owner.owner.pid}\uFF09\u304C\u30ED\u30C3\u30AF\u306E pid \u3068\u4E00\u81F4\u3057\u307E\u305B\u3093`});
|
|
@@ -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-
|
|
3
|
+
import{loadDomain}from"./chunk-WEKECDTT.js";import"./chunk-VSJBJXZO.js";export{loadDomain};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
2
|
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
-
import{CURATED_PAGING_VOCABULARY,buildPrepareContext,exitCodeFor,fetchAllPages,outputValue,reportError,requiresYes,resolvePaging,runDomain}from"./chunk-
|
|
3
|
+
import{CURATED_PAGING_VOCABULARY,buildPrepareContext,exitCodeFor,fetchAllPages,outputValue,reportError,requiresYes,resolvePaging,runDomain}from"./chunk-D72V6QGN.js";import"./chunk-WEKECDTT.js";import"./chunk-GDM2QUBL.js";import"./chunk-5Q2CH4E7.js";import"./chunk-YVAN3H5W.js";import"./chunk-IOGVQVGD.js";import"./chunk-LON7FN5A.js";import"./chunk-FTYJZFEK.js";import"./chunk-GMBJTG6A.js";import"./chunk-TAN5I2DP.js";import"./chunk-XNLIEUAW.js";
|
|
4
4
|
import"./chunk-J7QYPKVK.js";import"./chunk-4VZKNEVN.js";import"./chunk-WBAEUHJB.js";import"./chunk-QQRJLH6B.js";import"./chunk-K2ONOH3L.js";import"./chunk-WVS4W5FY.js";import"./chunk-NHYMHCAT.js";import"./chunk-G4OO4M44.js";import"./chunk-II5RVJQN.js";import"./chunk-7WSNIXTQ.js";import"./chunk-RZVI6PMW.js";import"./chunk-VSJBJXZO.js";export{CURATED_PAGING_VOCABULARY,buildPrepareContext,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{LoopSettingsApplier,PROMPT_KEYS,formatConfigHash,parseServerSettings,renderStepBudget}from"./chunk-
|
|
3
|
+
import{LoopSettingsApplier,PROMPT_KEYS,formatConfigHash,parseServerSettings,renderStepBudget}from"./chunk-VBX44RKP.js";import"./chunk-QWSXHHFT.js";import"./chunk-J7QYPKVK.js";import"./chunk-NHYMHCAT.js";import"./chunk-AEJHDFXB.js";import"./chunk-GY7KI5E5.js";import"./chunk-PMOUHEJQ.js";import"./chunk-5WGOHFAS.js";import"./chunk-VSJBJXZO.js";export{LoopSettingsApplier,PROMPT_KEYS,formatConfigHash,parseServerSettings,renderStepBudget};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
2
|
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
-
import{detectAiClis,formatDetection,isDetectableAi,isSelectable}from"./chunk-
|
|
3
|
+
import{detectAiClis,formatDetection,isDetectableAi,isSelectable}from"./chunk-T4QZO6RQ.js";import{PromptAbortedError,promptText}from"./chunk-L37NS5L2.js";import{stripTerminalControls}from"./chunk-NHYMHCAT.js";import{localConfigPath,parseClaudeLauncher}from"./chunk-QVPU4HHG.js";import"./chunk-N2UVRM3Z.js";import{AiConfig}from"./chunk-AEJHDFXB.js";import"./chunk-GY7KI5E5.js";import"./chunk-PMOUHEJQ.js";import"./chunk-5WGOHFAS.js";import"./chunk-RZVI6PMW.js";
|
|
4
4
|
import"./chunk-VSJBJXZO.js";import fs from"fs";import path from"path";var RECOMMENDED_ROTATION={complex:["claude"],verify:["claude"],security:["claude"],support:["claude"],triage:["claude"],search:["claude"],simple:["claude"]};var RECOMMENDED_CHAINS={complex:["claude","codex"],verify:["claude","codex","copilot"],security:["claude","codex","copilot"],support:["claude","codex","copilot"],triage:["codex","gemini","copilot","claude"],search:["codex","gemini","copilot","claude"],simple:["codex","gemini","copilot","claude"]};var PREFERENCE=["claude","codex","gemini","co\
|
|
5
5
|
pilot"];function buildAiAssignment(selected){if(selected.length===0)throw new Error("\u9078\u629E\u3055\u308C\u305FAI\u304C\u7A7A\u3067\u3059");const fallbackOrder=PREFERENCE.filter(ai=>selected.includes(ai));for(const ai of selected)if(!fallbackOrder.includes(ai))fallbackOrder.push(ai);const chains={};const rotation={};for(const category of Object.keys(RECOMMENDED_CHAINS)){const filtered=(RECOMMENDED_CHAINS[category]??[]).filter(ai=>selected.includes(ai));const chain=filtered.length>0?filtered:
|
|
6
6
|
[...fallbackOrder];chains[category]=chain;const rot=(RECOMMENDED_ROTATION[category]??[]).filter(ai=>selected.includes(ai));const head=chain[0];rotation[category]=rot.length>0?rot:head===void 0?[...fallbackOrder]:[head]}return{primary_rotation:rotation,fallback_chains:chains}}var SETUP_EXIT_NO_CLI=3;var SETUP_EXIT_ABORTED=130;async function runSetup(opts){const env=opts.env??process.env;const rawOut=opts.out??(t=>void process.stdout.write(t));const rawErr=opts.err??(t=>void process.stderr.write(t));
|