@tocca-systems/twp-cli 0.81.0 → 0.83.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.public.md +8 -0
- package/README.md +1 -1
- package/dist/{agent-loop-ZGHJGHFQ.js → agent-loop-W2KS5JJV.js} +1 -1
- package/dist/{ai-dispatch-DJ5JT5BE.js → ai-dispatch-CE7RIQL6.js} +1 -1
- package/dist/{api-command-IKQCTKPH.js → api-command-KBH7ML2J.js} +1 -1
- package/dist/{app-JGYZPOH7.js → app-ORQBEJPS.js} +3 -3
- package/dist/{auto-update-worker-5J4XXQ6J.js → auto-update-worker-OIVQGG34.js} +1 -1
- package/dist/{chunk-YPULDSJ3.js → chunk-4DY3NU53.js} +2 -2
- package/dist/{chunk-5YJAT7HE.js → chunk-4FCPLEZN.js} +1 -1
- package/dist/{chunk-KRPJ4UFW.js → chunk-7KFX2TPV.js} +1 -1
- package/dist/{chunk-QGJYT4NH.js → chunk-7VMPEAAL.js} +1 -1
- package/dist/{chunk-XMPHGOW4.js → chunk-CVX2YWHC.js} +21 -17
- package/dist/{chunk-TH3NVRAU.js → chunk-DRERU42W.js} +1 -1
- package/dist/{chunk-ZOOEH7ZE.js → chunk-MBPJV745.js} +1 -1
- package/dist/{chunk-TVTJRNUC.js → chunk-VON6ODNL.js} +12 -3
- package/dist/{chunk-AK7CNRVB.js → chunk-WMIIFPXT.js} +1 -1
- package/dist/{chunk-RCUI6WWU.js → chunk-Y24FMUYU.js} +1 -1
- package/dist/{chunk-M6FZ62YR.js → chunk-ZPQZLUYY.js} +21 -21
- package/dist/cli.js +9 -9
- package/dist/{commands-D65LPET6.js → commands-X2FS3DN7.js} +75 -75
- package/dist/{commands-ZIRZVBH6.js → commands-XD25HOMA.js} +1 -1
- package/dist/{logout-guard-57LHDX6L.js → logout-guard-FCCJSF5V.js} +1 -1
- package/dist/{media-KWSFHGAQ.js → media-CTIY3IAB.js} +1 -1
- package/dist/{oneshot-TH4PFDWC.js → oneshot-R7BDYFEN.js} +2 -2
- package/dist/{plan-submit-4NT4OC7J.js → plan-submit-AZKVMJKV.js} +1 -1
- package/dist/{registry-QXXEYQZZ.js → registry-7ETH2NOG.js} +1 -1
- package/dist/{run-SUYWHFJS.js → run-OKRSGCIR.js} +1 -1
- package/dist/{server-settings-OB7JF757.js → server-settings-GFWQ5ERV.js} +1 -1
- package/dist/{setup-FMSAHRGZ.js → setup-DW2H7BDN.js} +1 -1
- package/dist/{skill-check-CKLMW2AJ.js → skill-check-JBRUAUID.js} +1 -1
- package/dist/{update-ZKZGDGMC.js → update-XUIOLVEL.js} +1 -1
- package/package.json +1 -1
package/CHANGELOG.public.md
CHANGED
|
@@ -11,6 +11,14 @@
|
|
|
11
11
|
`CHANGELOG.md` に残してあります。顧客向けの履歴は public 公開以降を対象とします。
|
|
12
12
|
-->
|
|
13
13
|
|
|
14
|
+
## 0.83.0
|
|
15
|
+
|
|
16
|
+
ループの「本番反映」系スキルに対する特別な後処理が、スキルの名前ではなく設定(`operations.release_hooks`)で有効になるようになりました。設定していない環境では、どのスキル名でも特別扱いされません。
|
|
17
|
+
|
|
18
|
+
## 0.82.0
|
|
19
|
+
|
|
20
|
+
対応するリレーと組み合わせると、`/model` で Gemini のモデル(例: `gemini-3-pro`・`gemini-3.7-flash`)を選んで対話・`-p` で使えるようになりました(ファイルの読み書き等のツール実行を含みます)。Gemini のモデルへ切り替えるときは、新しい会話から始まります。
|
|
21
|
+
|
|
14
22
|
## 0.81.0
|
|
15
23
|
|
|
16
24
|
`twp project member create` / `update` の `--wiki-role admin|member` で、プロジェクトごとの Wiki 権限(そのプロジェクトの Wiki だけで管理者にするか)を設定できるようになりました。`twp project members` の一覧に Wiki 権限(`wiki_role`)の列が加わり、誰がそのプロジェクトの Wiki 管理者かを確かめられます。
|
package/README.md
CHANGED
|
@@ -1837,7 +1837,7 @@ twp configure --profile dev # プロファイルを指定して設定
|
|
|
1837
1837
|
|
|
1838
1838
|
**モデルはモードと直交する。** 業務モードに切り替えてもモデルは変わらない(`/model` で別に切り替える)。
|
|
1839
1839
|
|
|
1840
|
-
**`/model` で接続先の異なるモデル(例: Anthropic 直 `claude
|
|
1840
|
+
**`/model` で接続先の異なるモデル(例: Anthropic 直 `claude-*`・Bedrock `bedrock:*`・Gemini `gemini-*`)を選ぶと、会話中なら確認のうえ新しい会話から始める**(前の会話は引き継がない)。同じ接続先のモデル同士は会話を保ったまま次のターンから切り替わる。
|
|
1841
1841
|
|
|
1842
1842
|
#### モードを自分で調整する
|
|
1843
1843
|
|
|
@@ -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-
|
|
3
|
+
import{stepToItem}from"./chunk-7VMPEAAL.js";import"./chunk-JUJSF5ZG.js";import{loadLocalConfig}from"./chunk-Y24FMUYU.js";import{parseOperations}from"./chunk-CVX2YWHC.js";import"./chunk-VYDPW2YO.js";import"./chunk-TTST7UDR.js";import{loadAiConfig}from"./chunk-FABDZBDZ.js";import{SKILL_PREFIX_RE,setSkillPrefix}from"./chunk-6CS5L24D.js";import"./chunk-N2UVRM3Z.js";import"./chunk-O52RKZCC.js";import"./chunk-LDBYJPRD.js";import{PRIVATE_PROJECT_PREFIX,
|
|
4
4
|
PRIVATE_PROJECT_REF,isPrivateProjectRef}from"./chunk-RMFLTSOV.js";import{LIST_FLAGS,LIST_PAGING_HELP,envelopePaging,nonEmpty,positiveInteger}from"./chunk-MI6HVYR2.js";import"./chunk-II5RVJQN.js";import{requireResolved,singleRef,withResolved}from"./chunk-PS5QFKHB.js";import{acknowledgement,isRecord,pick}from"./chunk-3ZRMMBP5.js";import{ApiResponseError,UsageError}from"./chunk-VFPY2A23.js";import"./chunk-PMOUHEJQ.js";import"./chunk-J7QYPKVK.js";import"./chunk-5WGOHFAS.js";
|
|
5
5
|
import"./chunk-RZVI6PMW.js";import"./chunk-NHYMHCAT.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\
|
|
6
6
|
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 PLAN_RESULTS=["enqueued","empty","json_not_found","ai_failed","error","skipped","gated","locked","abandoned"];var PLAN_HISTORY_COLUMNS=["plan_run_id","result","runner_id","ai_type","duration_ms","cost_usd","step_count","started_at"];var PROJECT_FLAG={name:"--pr\
|
|
@@ -1,6 +1,6 @@
|
|
|
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-
|
|
3
|
+
import{failureHint,isAuthError,isCliFatalText,isRateLimited,isServerAiType,isUntrusted,maxTurnsReached,rateLimitWaitSeconds,tailForScan}from"./chunk-MBPJV745.js";import{expandServerSkills,prepareSkillOverlay}from"./chunk-QGRBZ2C2.js";import{detectAiClis}from"./chunk-5SONMN6K.js";import"./chunk-MYBIPHZ7.js";import"./chunk-A4LFG7MW.js";import"./chunk-VRBI2NPI.js";import{ClaudeStreamRenderer}from"./chunk-JUJSF5ZG.js";import{DEFAULT_CLAUDE_LAUNCHER,activeSlotPath,
|
|
4
4
|
detectClaudeAutoSwitch,isClaudeAi,isUsableModelId,modelFitsRoute,resolveSpawnTarget,usesBedrock,wrapWithAutoSwitch}from"./chunk-FABDZBDZ.js";import"./chunk-6CS5L24D.js";import{isForceOnly,killProcessTree,system32}from"./chunk-N2UVRM3Z.js";import"./chunk-O52RKZCC.js";import"./chunk-LDBYJPRD.js";import"./chunk-RMFLTSOV.js";import"./chunk-VFPY2A23.js";import{findExecutable,isWindowsDriveAbsolute}from"./chunk-PMOUHEJQ.js";import"./chunk-J7QYPKVK.js";
|
|
5
5
|
import"./chunk-5WGOHFAS.js";import{stripTerminalControls}from"./chunk-NHYMHCAT.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 DEFAULT_AI_TIMING={abortGraceMs:5e3,abortReapMs:2e3,pollIntervalMs:5e3};function resolveTiming(over){return{abortGraceMs:over?.abortGraceMs??DEFAULT_AI_TIMING.abortGraceMs,abortReapMs:over?.abortReapMs??DEFAULT_AI_TIMING.abortReapMs,pollIntervalMs:over?.pollIntervalMs??DEFAULT_AI_TIMING.pollIntervalMs}}var MAX_RETAINED_BYTES=4*1024*1024;function closeStream(stream){return new Promise(resolve=>{if(stream===null)return resolve();stream.once("error",()=>resolve());stream.end(()=>resolve())})}function buildArgs(req,cfg,env,workspace){
|
|
6
6
|
const warnings=[];const requested=(req.model??"").trim();const usable=requested!==""&&isUsableModelId(requested);if(requested!==""&&!usable){warnings.push(`ai_model '${requested}' \u306F\u4F7F\u3048\u306A\u3044\u5F62\u3067\u3059 \u2192 \u30AB\u30C6\u30B4\u30EA\u65E2\u5B9A\u306E\u30E2\u30C7\u30EB\u3092\u4F7F\u3044\u307E\u3059`)}const fitsRoute=!usable||!isClaudeAi(req.ai)||modelFitsRoute(requested,env);if(usable&&!fitsRoute){warnings.push(`ai_model '${requested}' \u306F\u73FE\u5728\u306E\u5B9F\u884C\u7D4C\u8DEF\u3067\u306F\u89E3\u6C7A\u3067\u304D\u307E\u305B\u3093\uFF08\u3053\u306E\u6A5F\u4F53\u306F ${usesBedrock(
|
|
@@ -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-WMIIFPXT.js";import"./chunk-4DY3NU53.js";import{renderOutput}from"./chunk-PO35MCYP.js";import"./chunk-Q3B65OFC.js";import{evaluateQuery}from"./chunk-GFLGXGWE.js";import{describeWaitResult,parseWaitOptions,waitUntilTerminal}from"./chunk-WVCEKC7V.js";
|
|
4
4
|
import{redactSecretValues,redactSecrets,withDebug}from"./chunk-LDBYJPRD.js";import{parseOperationArgs,repeatedValues}from"./chunk-RX5HWI4L.js";import{readBody}from"./chunk-6LSQCOCJ.js";import"./chunk-RSSPNFSK.js";import"./chunk-HVZUXLQ4.js";import{ApiError,TwpApiClient,appendQuery}from"./chunk-JA5A6UJ2.js";import"./chunk-H4CDX4TX.js";import{DEFAULT_MAX_ITEMS,DEFAULT_MAX_PAGES,envelopePaging,isPageNumberEnvelope,pageRangeNotes,positiveInteger,readEnvelopeCursor,
|
|
5
5
|
readPageNumberCursor,shellQuote}from"./chunk-MI6HVYR2.js";import"./chunk-II5RVJQN.js";import"./chunk-3ZRMMBP5.js";import{ApiResponseError,EXIT_OK,EXIT_WAIT_TIMEOUT,NetworkError,UsageError}from"./chunk-VFPY2A23.js";import{GLOBAL_OPTIONS_HELP}from"./chunk-PECIBNFD.js";import{AuthSession,NotLoggedInError,SessionExpiredError,loadCredentials}from"./chunk-XNLIEUAW.js";import{httpFetch}from"./chunk-J7QYPKVK.js";import{effectiveApiUrl,resolveConfiguredOutput,resolveProfile}from"./chunk-EDF4U5BT.js";
|
|
6
6
|
import"./chunk-RZVI6PMW.js";import{HELP_TOKEN}from"./chunk-MLRBDF44.js";import"./chunk-QQRJLH6B.js";import{OUTPUT_FORMATS,resolveOutputFormat}from"./chunk-74BPZOKU.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=>/^\{[^/{}]+\}$/.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
2
|
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
-
import{RESIDENT_TOKEN_CAP,activateModeFiles,activatePermissionSettings,buildResidentSet,buildSystemPrompt,createAuditLogger,createTwpToolkit,currentBranch,describeAuditLog,describeToolCatalog,displayCwd,executeTool,findProjectTwpSubdir,localTools,lstatOrNull,parseFrontMatter,parseRule,persistProjectAllow,projectPermissionsPath,projectRootFor,readFileTool,residentInputs,resolveGitExecutable,runTurn,secretReason}from"./chunk-
|
|
4
|
-
diffStat}from"./chunk-VRBI2NPI.js";import{require_fuzzysort}from"./chunk-DIMZRTLE.js";import"./chunk-N2UVRM3Z.js";import"./chunk-LDBYJPRD.js";import"./chunk-RSSPNFSK.js";import"./chunk-HVZUXLQ4.js";import"./chunk-JA5A6UJ2.js";import"./chunk-H4CDX4TX.js";import"./chunk-II5RVJQN.js";import"./chunk-VFPY2A23.js";import{RelayError,builtinCatalog,classifyModelSwitch,createRuntime,loadCachedCatalog,modelLabel,pickModel,specFor,toModelInfos}from"./chunk-
|
|
3
|
+
import{RESIDENT_TOKEN_CAP,activateModeFiles,activatePermissionSettings,buildResidentSet,buildSystemPrompt,createAuditLogger,createTwpToolkit,currentBranch,describeAuditLog,describeToolCatalog,displayCwd,executeTool,findProjectTwpSubdir,localTools,lstatOrNull,parseFrontMatter,parseRule,persistProjectAllow,projectPermissionsPath,projectRootFor,readFileTool,residentInputs,resolveGitExecutable,runTurn,secretReason}from"./chunk-DRERU42W.js";import"./chunk-NZ7WI4RZ.js";import{buildDiffLines,
|
|
4
|
+
diffStat}from"./chunk-VRBI2NPI.js";import{require_fuzzysort}from"./chunk-DIMZRTLE.js";import"./chunk-N2UVRM3Z.js";import"./chunk-LDBYJPRD.js";import"./chunk-RSSPNFSK.js";import"./chunk-HVZUXLQ4.js";import"./chunk-JA5A6UJ2.js";import"./chunk-H4CDX4TX.js";import"./chunk-II5RVJQN.js";import"./chunk-VFPY2A23.js";import{RelayError,builtinCatalog,classifyModelSwitch,createRuntime,loadCachedCatalog,modelLabel,pickModel,specFor,toModelInfos}from"./chunk-VON6ODNL.js";
|
|
5
5
|
import"./chunk-D233KKXW.js";import"./chunk-PMOUHEJQ.js";import"./chunk-XNLIEUAW.js";import{proxyDiagnostics}from"./chunk-J7QYPKVK.js";import{checkMinSupportedVersion,isBelowMinSupported,minSupportedBlockMessage}from"./chunk-DXXFUNYN.js";import"./chunk-EDF4U5BT.js";import{configReadDirs,twpHomeDir}from"./chunk-RZVI6PMW.js";import{parseArgv}from"./chunk-IVFSEXD3.js";import{applyPermissionMode,checkPermission,describePermissionMode,getMode,isModeId,modeSource,
|
|
6
6
|
nextMode}from"./chunk-2LOT54OO.js";import"./chunk-MLRBDF44.js";import"./chunk-VERYHAWV.js";import"./chunk-QQRJLH6B.js";import{isFullWidth,isWide,stringWidth,stripAnsi}from"./chunk-UREA4ZIG.js";import{stripTerminalControls}from"./chunk-NHYMHCAT.js";import{__commonJS,__export,__require,__toESM}from"./chunk-VSJBJXZO.js";var require_react_production=__commonJS({"node_modules/react/cjs/react.production.js"(exports){"use strict";var REACT_ELEMENT_TYPE=Symbol.for("react.transitional.element");var REACT_PORTAL_TYPE=Symbol.for("react.portal");var REACT_FRAGMENT_TYPE=Symbol.for("react.fragment");var REACT_STRICT_MODE_TYPE=Symbol.for("react.strict_mode");var REACT_PROFILER_TYPE=Symbol.for("react.profiler");var REACT_CONSUMER_TYPE=Symbol.for("react.consumer");var REACT_CONTEXT_TYPE=Symbol.for("react.context");var REACT_FORWARD_REF_TYPE=Symbol.
|
|
7
7
|
for("react.forward_ref");var REACT_SUSPENSE_TYPE=Symbol.for("react.suspense");var REACT_MEMO_TYPE=Symbol.for("react.memo");var REACT_LAZY_TYPE=Symbol.for("react.lazy");var REACT_ACTIVITY_TYPE=Symbol.for("react.activity");var REACT_VIEW_TRANSITION_TYPE=Symbol.for("react.view_transition");var MAYBE_ITERATOR_SYMBOL=Symbol.iterator;function getIteratorFn(maybeIterable){if(null===maybeIterable||"object"!==typeof maybeIterable)return null;maybeIterable=MAYBE_ITERATOR_SYMBOL&&maybeIterable[MAYBE_ITERATOR_SYMBOL]||
|
|
@@ -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-OKRSGCIR.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",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
2
|
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
-
import{fetchLatestVersion,isBehindLatest,resolveNpmCommand}from"./chunk-
|
|
3
|
+
import{fetchLatestVersion,isBehindLatest,resolveNpmCommand}from"./chunk-7KFX2TPV.js";import"./chunk-VON6ODNL.js";import"./chunk-D233KKXW.js";import"./chunk-PMOUHEJQ.js";import"./chunk-XNLIEUAW.js";import"./chunk-J7QYPKVK.js";import{PARENT_PID_ENV,WORKER_ENV,autoUpdateDisabledReason,classifyInstall,isCheckDue,listRegisteredPids,lockFilePath,readUpdateState,resolveCliPath,runDirPath,writeUpdateState}from"./chunk-CH6QU76P.js";import{PACKAGE_NAME,parseVersionCore}from"./chunk-DXXFUNYN.js";
|
|
4
4
|
import"./chunk-5WGOHFAS.js";import"./chunk-EDF4U5BT.js";import"./chunk-RZVI6PMW.js";import{stripTerminalControls}from"./chunk-NHYMHCAT.js";import"./chunk-VSJBJXZO.js";import{execFile}from"child_process";import fs from"fs";import path from"path";var PARENT_WAIT_MAX_MS=12*60*60*1e3;var PARENT_POLL_MS=1e3;var LOCK_STALE_MS=PARENT_WAIT_MAX_MS+60*60*1e3;var INSTALL_TIMEOUT_MS=0;function childEnv(env){const next={...env};delete next[WORKER_ENV];delete next[PARENT_PID_ENV];return next}function createNpmRunner(env=process.env){const cmd=resolveNpmCommand({env});if(cmd===null)return null;return(args,timeoutMs)=>new Promise(resolve=>{execFile(cmd.file,[...cmd.prefix,...args],{timeout:timeoutMs,windowsHide:true,maxBuffer:8*1024*1024,cwd:path.dirname(lockFilePath(env)),env:childEnv(env)},(error,stdout,stderr)=>{if(error===null){resolve({ok:true,stdout:String(stdout),stderr:String(
|
|
5
5
|
stderr)});return}const e=error;resolve({ok:false,stdout:String(stdout??""),stderr:String(stderr??""),...e.killed?{error:"\u30BF\u30A4\u30E0\u30A2\u30A6\u30C8\u3057\u307E\u3057\u305F"}:typeof e.code==="string"?{error:e.code}:{}})})})}function summarizeNpmFailure(result){const text=`${result.stderr}
|
|
6
6
|
${result.stdout}`;const code=/npm (?:ERR!|error) code (\S+)/.exec(text)?.[1]??result.error;let reason;if(code==="EACCES"||code==="EPERM"){reason=`\u30B0\u30ED\u30FC\u30D0\u30EB\u306E\u5C0E\u5165\u5148\u306B\u66F8\u304D\u8FBC\u3080\u6A29\u9650\u304C\u3042\u308A\u307E\u305B\u3093\uFF08${code}\uFF09`}else if(code!==void 0&&/^(ENOTFOUND|ETIMEDOUT|ECONNREFUSED|ECONNRESET|EAI_AGAIN|ENETUNREACH)$/.test(code)){reason=`npm registry \u306B\u63A5\u7D9A\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\uFF08${code}\
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
2
|
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
-
var LOADERS={agent:async()=>(await import("./agent-WTDLGRNM.js")).agentDomain,"agent-loop":async()=>(await import("./agent-loop-
|
|
3
|
+
var LOADERS={agent:async()=>(await import("./agent-WTDLGRNM.js")).agentDomain,"agent-loop":async()=>(await import("./agent-loop-W2KS5JJV.js")).agentLoopDomain,"ai-review-reason":async()=>(await import("./sales-ai-review-L5VW3DU3.js")).aiReviewReasonDomain,analysis:async()=>(await import("./analysis-H52FJIFO.js")).analysisDomain,announcement:async()=>(await import("./announcement-RTTVGW4K.js")).announcementDomain,attendance:async()=>(await import("./attendance-correct-OLWRCDP4.js")).attendanceDomainWithRecords,
|
|
4
4
|
backlog:async()=>(await import("./backlog-HDDV2NTC.js")).backlogDomain,budget:async()=>(await import("./budget-T246BG2P.js")).budgetDomain,"business-hours":async()=>(await import("./business-hours-I4X6YQS3.js")).businessHoursDomain,"business-place":async()=>(await import("./sales-master-BQML5IJT.js")).businessPlaceDomain,company:async()=>(await import("./company-2CRWKBJL.js")).companyDomain,contract:async()=>(await import("./contract-73RVPBYM.js")).contractDomain,customer:async()=>(await import("./company-2CRWKBJL.js")).
|
|
5
5
|
customerDomain,department:async()=>(await import("./department-GPVHVFFP.js")).departmentDomain,deposit:async()=>(await import("./deposit-3I3NV556.js")).depositDomain,estimate:async()=>(await import("./estimate-NLKTWCYI.js")).estimateDomain,evaluation:async()=>(await import("./evaluation-VP7OFTBS.js")).evaluationDomain,expense:async()=>(await import("./expense-O2O4623X.js")).expenseDomain,"fiscal-year":async()=>(await import("./fiscal-year-ZTCSF46U.js")).fiscalYearDomain,holiday:async()=>(await import("./holiday-WDI4CSNL.js")).
|
|
6
6
|
holidayDomain,"goal-sheet":async()=>(await import("./evaluation-VP7OFTBS.js")).goalSheetDomain,inquiry:async()=>(await import("./inquiry-4Q4BRYM3.js")).inquiryDomain,invoice:async()=>(await import("./invoice-BXSI6SMA.js")).invoiceDomain,"job-title":async()=>(await import("./job-title-NCFHCA4M.js")).jobTitleDomain,knowledge:async()=>(await import("./domain-knowledge-SZZCV6IO.js")).knowledgeDomain,leave:async()=>(await import("./leave-W4GHXMSE.js")).leaveDomain,license:async()=>(await import("./license-XSWDXSJE.js")).
|
|
7
|
-
licenseDomain,media:async()=>(await import("./media-
|
|
7
|
+
licenseDomain,media:async()=>(await import("./media-CTIY3IAB.js")).mediaDomain,meeting:async()=>(await import("./knowledge-TCADQEPU.js")).meetingDomain,note:async()=>(await import("./knowledge-TCADQEPU.js")).noteDomain,notification:async()=>(await import("./notification-WP7CH734.js")).notificationDomain,onedrive:async()=>(await import("./onedrive-KWVOUGG6.js")).onedriveDomain,outlook:async()=>(await import("./outlook-GYRF5TXA.js")).outlookDomain,payee:async()=>(await import("./sales-master-BQML5IJT.js")).
|
|
8
8
|
payeeDomain,position:async()=>(await import("./position-H3NSDVKQ.js")).positionDomain,project:async()=>(await import("./project-UDHRIZZN.js")).projectDomain,prospect:async()=>(await import("./prospect-QY3NYP2A.js")).prospectDomain,purchase:async()=>(await import("./purchase-7XCGCQ2G.js")).purchaseDomain,qualification:async()=>(await import("./skill-4TSTVUXY.js")).qualificationDomain,receivable:async()=>(await import("./receivable-GW5WCVJ7.js")).receivableDomain,redmine:async()=>(await import("./redmine-644RTL42.js")).
|
|
9
9
|
redmineDomain,report:async()=>(await import("./report-P74LSHTE.js")).reportDomain,"rounding-setting":async()=>(await import("./sales-numbering-OW4O6WH6.js")).roundingSettingDomain,"seal-impression":async()=>(await import("./sales-master-BQML5IJT.js")).sealImpressionDomain,search:async()=>(await import("./search-BLMSVPIL.js")).searchDomain,segment:async()=>(await import("./segment-G4IPD43F.js")).segmentDomain,shift:async()=>(await import("./attendance-lists-TBUZCRKK.js")).shiftDomain,skill:async()=>(await import("./skill-4TSTVUXY.js")).
|
|
10
10
|
skillDomain,"staffing-board":async()=>(await import("./staffing-board-MQREMSVJ.js")).staffingBoardDomain,storage:async()=>(await import("./storage-AQDCEBDJ.js")).storageDomain,"supplier-payment":async()=>(await import("./supplier-payment-KRLYWEKY.js")).supplierPaymentDomain,support:async()=>(await import("./support-ITRXFVMK.js")).supportDomain,task:async()=>(await import("./task-AGNMPS4F.js")).taskDomain,teams:async()=>(await import("./teams-MZR3256V.js")).teamsDomain,user:async()=>(await import("./user-3IHEIFAT.js")).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
2
|
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
-
import{DEFAULT_INTERVAL_SEC}from"./chunk-
|
|
3
|
+
import{DEFAULT_INTERVAL_SEC}from"./chunk-Y24FMUYU.js";import{CHAIN_KEYS,reloadAiConfig}from"./chunk-FABDZBDZ.js";import{describeError}from"./chunk-O52RKZCC.js";import{isPrivateProjectId}from"./chunk-RMFLTSOV.js";import{stripTerminalControls}from"./chunk-NHYMHCAT.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}}const rawLoop=b["loop"];const rawInterval=rawLoop!==null&&typeof rawLoop==="object"&&!Array.isArray(rawLoop)?
|
|
5
5
|
rawLoop["interval_sec"]:void 0;const intervalSec=typeof rawInterval==="number"&&Number.isInteger(rawInterval)&&rawInterval>0?rawInterval:null;const rawOutcomes=b["outcomes"];const outcomeSkills=Array.isArray(rawOutcomes)?[...new Set(rawOutcomes.map(r=>r!==null&&typeof r==="object"?r["skill"]:void 0).filter(v=>typeof v==="string"&&v.trim()!==""))]:[];return{revision,ai,prompts,intervalSec,outcomeSkills}}function formatConfigHash(aiHash,revision,ai,charter){return`${aiHash};r=${revision};ai=${ai};\
|
|
6
6
|
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="";lastInterval="";async apply(){const{config,log}=this.deps;const outcome=await this.fetch();const warning=outcome.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
2
|
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
-
import{createRuntime}from"./chunk-
|
|
3
|
+
import{createRuntime}from"./chunk-VON6ODNL.js";import{findExecutable}from"./chunk-PMOUHEJQ.js";import{httpFetch}from"./chunk-J7QYPKVK.js";import{describeAutoUpdate}from"./chunk-CH6QU76P.js";import{PACKAGE_NAME,UPDATE_COMMAND,compareVersionCores,isBelowMinSupported,parseVersionCore}from"./chunk-DXXFUNYN.js";import{stripTerminalControls}from"./chunk-NHYMHCAT.js";import{execFile}from"child_process";import fs from"fs";import path from"path";function resolveNpmCommand(deps={}){const platform=deps.platform??process.platform;const env=deps.env??process.env;const npmPath=(deps.find??(name=>findExecutable(name,{env,platform})))("npm");if(npmPath===null)return null;if(platform!=="win32")return{file:npmPath,prefix:[]};if(/\.exe$/i.test(npmPath))return{file:npmPath,prefix:[]};const cliJs=path.win32.join(path.win32.dirname(npmPath),"node_modules","npm","bin","npm-cli.js");return(deps.exists??fs.existsSync)(cliJs)?{file:deps.nodePath??process.
|
|
4
4
|
execPath,prefix:[cliJs]}:null}var DEFAULT_REGISTRY="https://registry.npmjs.org";function registryBase(env=process.env){const configured=env["npm_config_registry"]?.trim();if(configured===void 0||configured==="")return DEFAULT_REGISTRY;try{const url=new URL(configured);if(url.protocol!=="https:"&&url.protocol!=="http:")return DEFAULT_REGISTRY}catch{return DEFAULT_REGISTRY}return configured.replace(/\/+$/,"")}async function fetchFromRegistry(fetchImpl=httpFetch,env=process.env){const url=`${registryBase(env)}/${PACKAGE_NAME.replace(
|
|
5
5
|
"/","%2f")}`;const res=await fetchImpl(url,{headers:{Accept:"application/vnd.npm.install-v1+json"},signal:AbortSignal.timeout(5e3)});if(!res.ok){throw new Error(`registry \u304C ${res.status} \u3092\u8FD4\u3057\u307E\u3057\u305F`)}const body=await res.json();const latest=body["dist-tags"]?.latest;if(typeof latest!=="string"||parseVersionCore(latest)===null){throw new Error("registry \u306E\u5FDC\u7B54\u306B dist-tags.latest \u304C\u3042\u308A\u307E\u305B\u3093")}return{version:latest.trim(),source:"\
|
|
6
6
|
registry"}}async function fetchFromNpmCli(){const npm=resolveNpmCommand();if(npm===null){throw new Error("npm \u304C PATH \u306B\u898B\u3064\u304B\u308A\u307E\u305B\u3093")}const stdout=await new Promise((resolve,reject)=>{execFile(npm.file,[...npm.prefix,"view",PACKAGE_NAME,"version","--json"],{timeout:15e3,windowsHide:true},(error,out)=>error?reject(error):resolve(out))});const parsed=JSON.parse(stdout.trim());const latest=typeof parsed==="string"?parsed:null;if(latest===null||parseVersionCore(
|
|
@@ -11,6 +11,6 @@ m[1]??""))return null;return token}return null}function stepToItem(step,assign,p
|
|
|
11
11
|
if(!label||promptLike||label.startsWith("[P"))label=prompt;const taskKey=ledgerTaskKey(args);const category=assign?.categoryForSkill(skill)??step.ai_category??"complex";const display=taskKey&&!label.includes(taskKey)?`[${priority}] ${taskKey} ${label} #ai:${category}`:`[${priority}] ${label} #ai:${category}`;const item={label:display.slice(0,200),prompt,task_key:taskKey};const platforms=normalizeRequiredPlatforms(step.required_platforms);if(platforms.length>0)item.required_platforms=platforms;if(assign!==
|
|
12
12
|
void 0){const ai=assign.selectPrimary(category,skill,priority,display);if(ai!=="")item.ai_type=ai}return item}function parsePlanExcludeKeys(prefetchSection){const m=/OPS_PLAN_EXCLUDE_KEYS\s+([^\s]*)\s+-->/.exec(prefetchSection);const keys=new Set;if(!m||!m[1])return keys;for(const raw of m[1].split(",")){const key=raw.trim();if(key!=="")keys.add(key)}return keys}function excludedKeyInArgs(args,excluded){if(excluded.size===0)return null;for(const key of[...excluded].sort()){const re=new RegExp(`(\
|
|
13
13
|
?<![A-Za-z0-9-])${key.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?![0-9])`);if(re.test(args))return key}return null}function parseOpsCount(prefetchSection,field){const marker=/OPS_COUNTS\s+([^>]*?)-->/.exec(prefetchSection);if(!marker||!marker[1])return null;const escaped=field.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");const hit=new RegExp(`(?:^|\\s)${escaped}=(-?\\d+)(?:\\s|$)`).exec(marker[1]);if(!hit||hit[1]===void 0)return null;const n=Number.parseInt(hit[1],10);if(!Number.isFinite(n)||n<0)return null;
|
|
14
|
-
return n}function releaseDeployDropReason(verifyBacklog,devVerifyPlanned){if(verifyBacklog===null){return
|
|
14
|
+
return n}function releaseDeployDropReason(verifyBacklog,devVerifyPlanned,guard){if(verifyBacklog===null){return`${guard.countField} \u306E\u4EF6\u6570\u3092\u53D6\u5F97\u3067\u304D\u306A\u304B\u3063\u305F\uFF08\u5224\u5B9A\u4E0D\u80FD\u306E\u305F\u3081\u30EA\u30EA\u30FC\u30B9\u306F\u898B\u9001\u308B\uFF09`}if(verifyBacklog>devVerifyPlanned){return`${guard.countField} ${verifyBacklog}\u4EF6 > \u8A08\u753B\u5185${guard.drainedBy}${devVerifyPlanned}\u4EF6\uFF08Phase 1\u306E0\u4EF6\u898B\u8FBC\u307F\u304C\u7ACB\u305F\u306A\u3044\uFF09`}
|
|
15
15
|
return null}function duplicateTaskKeyDropReason(enqueuedKeys,taskKey){if(!taskKey)return null;if(!enqueuedKeys.has(taskKey))return null;return`${taskKey} \u306F\u672C\u8A08\u753B\u3067\u65E2\u306B\u6295\u5165\u6E08\u307F\uFF08\u540C\u4E00\u30AD\u30FC\u306F1\u8A08\u753B1\u4EF6\uFF09`}var NO_ZERO_TARGET_GATES={};function zeroTargetDropReasons(prefetchSection,gates=NO_ZERO_TARGET_GATES){const reasons=new Map;for(const[skill,gate]of Object.entries(gates)){const n=parseOpsCount(prefetchSection,gate.field);
|
|
16
16
|
if(n===null)reasons.set(skill,`${gate.label}\u4EF6\u6570\u304C\u5224\u5B9A\u4E0D\u80FD\u306E\u305F\u3081\u898B\u9001\u308A`);else if(n===0)reasons.set(skill,`${gate.label}0\u4EF6\u306E\u305F\u3081\u5BFE\u8C61\u306A\u3057`)}return reasons}export{extractPlanJson,placeholderTaskKey,stepToItem,parsePlanExcludeKeys,excludedKeyInArgs,parseOpsCount,releaseDeployDropReason,duplicateTaskKeyDropReason,zeroTargetDropReasons};
|
|
@@ -7,10 +7,10 @@ statePath,"utf8"));const fingerprint=parsed["fingerprint"];const plannedAtMs=par
|
|
|
7
7
|
{fingerprint,planned_at_ms:nowMs,planned_at:new Date(nowMs).toISOString()}));fs.renameSync(tmp,statePath);return true}catch{fs.rmSync(tmp,{force:true});return false}}async function evaluatePlanGate(gate,opts){const run=opts.run??((h,cwd)=>runHook(h,cwd));const outcome=await run(gate.hook,opts.cwd);if(!outcome.ok){return{skip:false,fingerprint:null,reason:`\u30D5\u30C3\u30AF\u304C\u5931\u6557\u3057\u305F\u305F\u3081\u8A08\u753B\u3057\u307E\u3059\uFF08${outcome.reason??"\u7406\u7531\u4E0D\u660E"}\uFF09`}}
|
|
8
8
|
const fingerprint=fingerprintOf(outcome.stdout);if(fingerprint===null){return{skip:false,fingerprint:null,reason:"\u30D5\u30C3\u30AF\u304C\u6307\u7D0B\u3092\u51FA\u3055\u306A\u304B\u3063\u305F\u305F\u3081\u8A08\u753B\u3057\u307E\u3059"}}const short=fingerprint.slice(0,12);const prev=readPlanGateState(opts.statePath);if(prev===null){return{skip:false,fingerprint,reason:`\u524D\u56DE\u8A08\u753B\u6642\u306E\u8A18\u9332\u304C\u7121\u3044\u305F\u3081\u8A08\u753B\u3057\u307E\u3059\uFF08\u6307\u7D0B ${short}\
|
|
9
9
|
\uFF09`}}if(prev.fingerprint!==fingerprint){return{skip:false,fingerprint,reason:`\u5165\u529B\u304C\u5909\u308F\u3063\u305F\u305F\u3081\u8A08\u753B\u3057\u307E\u3059\uFF08\u6307\u7D0B ${prev.fingerprint.slice(0,12)} \u2192 ${short}\uFF09`}}const elapsedSec=Math.trunc((opts.nowMs-prev.plannedAtMs)/1e3);if(elapsedSec<0||elapsedSec>=gate.maxSkipSec){return{skip:false,fingerprint,reason:`\u5165\u529B\u306F\u5909\u308F\u3063\u3066\u3044\u307E\u305B\u3093\u304C\u3001\u524D\u56DE\u306E\u8A08\u753B\u304B\u3089 ${elapsedSec}\
|
|
10
|
-
\u79D2\u7D4C\u904E\u3057\u305F\u305F\u3081\u8A08\u753B\u3057\u307E\u3059\uFF08max_skip_sec=${gate.maxSkipSec}\uFF09`}}return{skip:true,fingerprint,reason:`\u5165\u529B\u306B\u5909\u5316\u304C\u306A\u3044\u305F\u3081\u8A08\u753B\u3092\u30B9\u30AD\u30C3\u30D7\u3057\u307E\u3059\uFF08\u6307\u7D0B ${short}\u30FB\u524D\u56DE\u306E\u8A08\u753B\u304B\u3089 ${elapsedSec}\u79D2\uFF09`}}var NO_OPERATIONS={exclusiveSkills:new Set,statusEndpoint:null,highRiskSkills:new Set,preflightHosts:[],releaseRecoverySkill:null,postSuccessEnqueue:new Map,contractSkills:new Set,contractLines:new Map,advancingOutcomes:new Map,zeroTargetGates:{},countHooks:new Map,planSkill:null,planGate:null,skillPrefix:DEFAULT_SKILL_PREFIX};var DEFAULT_STATUS_PATH="/api/release/list";var DEFAULT_STATUS_HEADER="X-API-Key";function stringArray(value,label,warnings){if(value===void 0||value===null)
|
|
11
|
-
isArray(value)){warnings.push(`operations.${label} \u306F\u914D\u5217\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u7121\u8996\u3057\u307E\u3059\uFF09`);return[]}const out=[];for(const v of value){if(typeof v!=="string"||v.trim()===""){warnings.push(`operations.${label} \u306E\u8981\u7D20\u306F\u7A7A\u3067\u306A\u3044\u6587\u5B57\u5217\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u3053\u306E\u8981\u7D20\u306F\u7121\u8996\u3057\u307E\u3059\uFF09`);
|
|
12
|
-
trim())}return out}var KEYS_LINE_RE=/^[A-Za-z][A-Za-z0-9_]*$/;function parsePostSuccessEnqueue(value,warnings){const out=new Map;if(value===void 0||value===null)return out;if(typeof value!=="object"||Array.isArray(value)){warnings.push("operations.post_success_enqueue \u306F\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u7121\u8996\u3057\u307E\u3059\uFF09");return out}for(const[k,v]of Object.entries(value)){const label=`
|
|
13
|
-
|
|
10
|
+
\u79D2\u7D4C\u904E\u3057\u305F\u305F\u3081\u8A08\u753B\u3057\u307E\u3059\uFF08max_skip_sec=${gate.maxSkipSec}\uFF09`}}return{skip:true,fingerprint,reason:`\u5165\u529B\u306B\u5909\u5316\u304C\u306A\u3044\u305F\u3081\u8A08\u753B\u3092\u30B9\u30AD\u30C3\u30D7\u3057\u307E\u3059\uFF08\u6307\u7D0B ${short}\u30FB\u524D\u56DE\u306E\u8A08\u753B\u304B\u3089 ${elapsedSec}\u79D2\uFF09`}}var NO_OPERATIONS={exclusiveSkills:new Set,statusEndpoint:null,highRiskSkills:new Set,preflightHosts:[],releaseRecoverySkill:null,postSuccessEnqueue:new Map,contractSkills:new Set,contractLines:new Map,advancingOutcomes:new Map,zeroTargetGates:{},countHooks:new Map,planSkill:null,planGate:null,skillPrefix:DEFAULT_SKILL_PREFIX,releaseHooks:null};var DEFAULT_STATUS_PATH="/api/release/list";var DEFAULT_STATUS_HEADER="X-API-Key";function stringArray(value,label,warnings){if(value===void 0||value===null)
|
|
11
|
+
return[];if(!Array.isArray(value)){warnings.push(`operations.${label} \u306F\u914D\u5217\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u7121\u8996\u3057\u307E\u3059\uFF09`);return[]}const out=[];for(const v of value){if(typeof v!=="string"||v.trim()===""){warnings.push(`operations.${label} \u306E\u8981\u7D20\u306F\u7A7A\u3067\u306A\u3044\u6587\u5B57\u5217\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u3053\u306E\u8981\u7D20\u306F\u7121\u8996\u3057\u307E\u3059\uFF09`);
|
|
12
|
+
continue}out.push(v.trim())}return out}var KEYS_LINE_RE=/^[A-Za-z][A-Za-z0-9_]*$/;function parsePostSuccessEnqueue(value,warnings){const out=new Map;if(value===void 0||value===null)return out;if(typeof value!=="object"||Array.isArray(value)){warnings.push("operations.post_success_enqueue \u306F\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u7121\u8996\u3057\u307E\u3059\uFF09");return out}for(const[k,v]of Object.entries(value)){const label=`operat\
|
|
13
|
+
ions.post_success_enqueue.${k}`;if(typeof v==="string"){if(v.trim()===""){warnings.push(`${label} \u306F\u7A7A\u3067\u306A\u3044\u6587\u5B57\u5217\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u3053\u306E\u9805\u76EE\u306F\u7121\u8996\u3057\u307E\u3059\uFF09`);continue}out.set(k,{skill:v.trim(),keysLine:null});continue}if(typeof v!=="object"||v===null||Array.isArray(v)){warnings.push(`${label} \u306F\u6587\u5B57\u5217\u304B { skill, keys_line } \u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u3053\u306E\u9805\u76EE\u306F\u7121\u8996\u3057\u307E\u3059\uFF09`);
|
|
14
14
|
continue}const o=v;const skill=typeof o["skill"]==="string"?o["skill"].trim():"";if(skill===""){warnings.push(`${label}.skill \u306F\u7A7A\u3067\u306A\u3044\u6587\u5B57\u5217\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u3053\u306E\u9805\u76EE\u306F\u7121\u8996\u3057\u307E\u3059\uFF09`);continue}const rawLine=o["keys_line"];let keysLine=null;if(typeof rawLine==="string"&&KEYS_LINE_RE.test(rawLine.trim())){keysLine=rawLine.trim()}else if(rawLine!==void 0&&rawLine!==null){warnings.push(
|
|
15
15
|
`${label}.keys_line \u306F\u82F1\u5B57\u3067\u59CB\u307E\u308B\u82F1\u6570\u5B57\u3068 _ \u3060\u3051\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u30AD\u30FC\u5358\u4F4D\u306E\u6295\u5165\u306F\u3057\u307E\u305B\u3093\uFF09`)}out.set(k,{skill,keysLine})}return out}function parseZeroTargetGates(value,warnings){const out={};if(value===void 0||value===null)return out;if(typeof value!=="object"||Array.isArray(value)){warnings.push("operations.zero_target_gates \u306F\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u7121\u8996\u3057\u307E\u3059\uFF09");
|
|
16
16
|
return out}for(const[skill,v]of Object.entries(value)){if(typeof v!=="object"||v===null||Array.isArray(v)){warnings.push(`operations.zero_target_gates.${skill} \u306F\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u7121\u8996\u3057\u307E\u3059\uFF09`);continue}const g=v;const field=typeof g["field"]==="string"?g["field"].trim():"";const label=typeof g["label"]==="string"?g["label"].trim():"";if(field===""||label===""){warnings.push(`operations.zer\
|
|
@@ -20,18 +20,22 @@ continue}const o=v;const line=typeof o["line"]==="string"?o["line"].trim():"";if
|
|
|
20
20
|
"object"||Array.isArray(rawAdvances)){warnings.push(`operations.contract_lines.${skill}.advances \u306F\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u7121\u8996\u3057\u307E\u3059\uFF09`)}else{for(const[rawValue,status]of Object.entries(rawAdvances)){if(!CONTRACT_VALUE_RE.test(rawValue)||typeof status!=="string"||status.trim()===""){warnings.push(`operations.contract_lines.${skill}.advances.${rawValue} \u306F\u300C\u5024: \u7A7A\u3067\u306A\u3044\u30B9\u30C6\u30FC\u30BF\u30B9\u300D\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u3053\u306E\u9805\u76EE\u306F\u7121\u8996\u3057\u307E\u3059\uFF09`);
|
|
21
21
|
continue}const outcome=`${line}: ${rawValue.toUpperCase()}`;const prev=advancingOutcomes.get(outcome);if(prev!==void 0&&prev!==status.trim()){warnings.push(`operations.contract_lines.${skill}.advances.${rawValue}: ${outcome} \u306E\u884C\u304D\u5148\u304C\u4ED6\u306E\u30B9\u30AD\u30EB\u3068\u98DF\u3044\u9055\u3044\u307E\u3059\uFF08${prev} \u3092\u63A1\u308A\u307E\u3059\uFF09`);continue}advances.set(rawValue.toUpperCase(),status.trim());advancingOutcomes.set(outcome,status.trim())}}}if(advances.size>
|
|
22
22
|
0&&!line.endsWith("_RESULT")){warnings.push(`operations.contract_lines.${skill}.line \u304C _RESULT \u3067\u7D42\u308F\u3089\u306A\u3044\u305F\u3081\u3001advances \u306F\u518D\u6295\u5165\u6291\u6B62\u306B\u4F7F\u3048\u307E\u305B\u3093\uFF08\u7DE0\u3081\u51E6\u7406\u306E\u5951\u7D04\u884C\u3068\u3057\u3066\u3060\u3051\u4F7F\u3044\u307E\u3059\uFF09`);for(const v2 of advances.keys())advancingOutcomes.delete(`${line}: ${v2}`)}contractLines.set(skill,{line,advances})}return{contractLines,advancingOutcomes}}
|
|
23
|
-
function
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
warnings};if(typeof value!=="object"||Array.isArray(value)){warnings.push("operations \u306F\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u7121\
|
|
28
|
-
push("operations.
|
|
29
|
-
|
|
23
|
+
var GUARD_NAME_RE=/^[A-Za-z0-9][A-Za-z0-9_-]*$/;function parseReleaseHooks(value,contractLines,skillPrefix,warnings){const bare=raw=>{const s=raw.trim().replace(/^\//,"");return skillPrefix!==""&&s.startsWith(skillPrefix)?s.slice(skillPrefix.length):s};if(value===void 0||value===null)return null;if(typeof value!=="object"||Array.isArray(value)){warnings.push("operations.release_hooks \u306F\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u7121\u8996\u3057\u307E\u3059\uFF09");
|
|
24
|
+
return null}const o=value;const rawSkill=typeof o["skill"]==="string"?bare(o["skill"]):"";if(!GUARD_NAME_RE.test(rawSkill)){warnings.push("operations.release_hooks.skill \u306F\u7A7A\u3067\u306A\u3044\u30B9\u30AD\u30EB\u540D\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u7121\u8996\u3057\u307E\u3059\uFF09");return null}const line=contractLines.get(rawSkill)?.line??null;if(line===null){warnings.push(`operations.release_hooks.skill \u306E ${rawSkill} \u306B contract_lines \u306E\u63A5\u982D\u8F9E\u304C\u3042\u308A\u307E\u305B\u3093\uFF08\u5B8C\u4E86\u5F8C\u51E6\u7406\
|
|
25
|
+
\u30FB\u56DE\u53CE\u6295\u5165\u3092\u884C\u3044\u307E\u305B\u3093\uFF09`)}let planGuard=null;const rawGuard=o["plan_guard"];if(rawGuard!==void 0&&rawGuard!==null){const g=typeof rawGuard==="object"&&!Array.isArray(rawGuard)?rawGuard:{};const countField=typeof g["count_field"]==="string"?g["count_field"].trim():"";const drainedBy=typeof g["drained_by"]==="string"?bare(g["drained_by"]):"";if(GUARD_NAME_RE.test(countField)&&GUARD_NAME_RE.test(drainedBy)){planGuard={countField,drainedBy}}else{warnings.
|
|
26
|
+
push("operations.release_hooks.plan_guard \u306B\u306F count_field \u3068 drained_by \u304C\u8981\u308A\u307E\u3059\uFF08\u8A08\u753B\u306E\u7A7A\u632F\u308A\u9632\u6B62\u30AC\u30FC\u30C9\u3092\u884C\u3044\u307E\u305B\u3093\uFF09")}}return{skill:rawSkill,line,planGuard}}function parseCountHooks(value,warnings){const out=new Map;if(value===void 0||value===null)return out;if(typeof value!=="object"||Array.isArray(value)){warnings.push("operations.count_hooks \u306F\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u7121\u8996\u3057\u307E\u3059\uFF09");
|
|
27
|
+
return out}for(const[key,v]of Object.entries(value)){const entry=v!==null&&typeof v==="object"&&!Array.isArray(v)?{id:`count:${key}`,...v}:v;const{hooks,warnings:w}=validateHooks([entry],`operations.count_hooks.${key}`);warnings.push(...w);const hook=hooks[0];if(hook)out.set(key,hook)}return out}function parseEndpoint(value,warnings){if(value===void 0||value===null)return null;if(typeof value!=="object"||Array.isArray(value)){warnings.push("operations.status_endpoint \u306F\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u6392\u4ED6\u3092\u7121\u52B9\u306B\u3057\u307E\u3059\uFF09");
|
|
28
|
+
return null}const o=value;const url=typeof o["url"]==="string"?o["url"].trim():"";if(url===""){warnings.push("operations.status_endpoint.url \u304C\u7121\u3044\u305F\u3081\u6392\u4ED6\u3092\u7121\u52B9\u306B\u3057\u307E\u3059");return null}if(!/^https?:\/\//i.test(url)){warnings.push(`operations.status_endpoint.url \u306F http(s) \u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044: ${url}\uFF08\u6392\u4ED6\u3092\u7121\u52B9\u306B\u3057\u307E\u3059\uFF09`);return null}const path2=typeof o["pat\
|
|
29
|
+
h"]==="string"&&o["path"].trim()!==""?o["path"].trim():DEFAULT_STATUS_PATH;const apiKeyEnvRaw=o["api_key_env"];const apiKeyEnv=typeof apiKeyEnvRaw==="string"&&apiKeyEnvRaw.trim()!==""?apiKeyEnvRaw.trim():null;const headerRaw=o["header"];const header=typeof headerRaw==="string"&&headerRaw.trim()!==""?headerRaw.trim():DEFAULT_STATUS_HEADER;return{url:url.replace(/\/+$/,""),path:path2.startsWith("/")?path2:`/${path2}`,apiKeyEnv,header}}function parseOperations(value){const warnings=[];if(value===void 0||
|
|
30
|
+
value===null)return{operations:NO_OPERATIONS,warnings};if(typeof value!=="object"||Array.isArray(value)){warnings.push("operations \u306F\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u7121\u8996\u3057\u307E\u3059\uFF09");return{operations:NO_OPERATIONS,warnings}}const o=value;const exclusiveSkills=new Set(stringArray(o["exclusive_skills"],"exclusive_skills",warnings));const statusEndpoint=parseEndpoint(o["status_endpoint"],warnings);if(exclusiveSkills.
|
|
31
|
+
size>0&&statusEndpoint===null){warnings.push("operations.exclusive_skills \u306F\u3042\u308A\u307E\u3059\u304C status_endpoint \u304C\u7121\u3044\u305F\u3081\u3001\u5B9A\u671F\u67A0\u306E\u6392\u4ED6\u306F\u884C\u3044\u307E\u305B\u3093")}if(exclusiveSkills.size===0&&statusEndpoint!==null){warnings.push("operations.status_endpoint \u306F\u3042\u308A\u307E\u3059\u304C exclusive_skills \u304C\u7A7A\u306E\u305F\u3081\u3001\u554F\u3044\u5408\u308F\u305B\u306F\u884C\u3044\u307E\u305B\u3093")}const releaseRecoveryRaw=o["\
|
|
32
|
+
release_recovery_skill"];const releaseRecoverySkill=typeof releaseRecoveryRaw==="string"&&releaseRecoveryRaw.trim()!==""?releaseRecoveryRaw.trim():null;const planSkillRaw=o["plan_skill"];let planSkill=null;if(typeof planSkillRaw==="string"&&planSkillRaw.trim()!==""){planSkill=planSkillRaw.trim()}else if(planSkillRaw!==void 0&&planSkillRaw!==null){warnings.push("operations.plan_skill \u306F\u7A7A\u3067\u306A\u3044\u6587\u5B57\u5217\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u8A08\u753B\u30D5\u30A7\u30FC\u30BA\u3092\u884C\u3044\u307E\u305B\u3093\uFF09")}
|
|
30
33
|
const planGate=parsePlanGate(o["plan_gate"],warnings);if(planGate!==null&&planSkill===null){warnings.push("operations.plan_gate \u306F\u3042\u308A\u307E\u3059\u304C plan_skill \u304C\u7121\u3044\u305F\u3081\u4F7F\u308F\u308C\u307E\u305B\u3093\uFF08\u8A08\u753B\u30D5\u30A7\u30FC\u30BA\u3092\u884C\u3044\u307E\u305B\u3093\uFF09")}const skillPrefixRaw=o["skill_prefix"];let skillPrefix=DEFAULT_SKILL_PREFIX;if(typeof skillPrefixRaw==="string"&&SKILL_PREFIX_RE.test(skillPrefixRaw)){skillPrefix=skillPrefixRaw}else if(skillPrefixRaw!==
|
|
31
34
|
void 0&&skillPrefixRaw!==null){warnings.push(`operations.skill_prefix \u306F\u82F1\u5C0F\u6587\u5B57\u30FB\u6570\u5B57\u30FB\u30CF\u30A4\u30D5\u30F3\u306E\u6587\u5B57\u5217\uFF08\u7A7A\u6587\u5B57\u53EF\uFF09\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u65E2\u5B9A\u306E '${DEFAULT_SKILL_PREFIX}' \u3092\u4F7F\u3044\u307E\u3059\uFF09`)}const{contractLines,advancingOutcomes}=parseContractLines(o["contract_lines"],warnings);const contractSkills=new Set(stringArray(o["contract_skills"],
|
|
32
|
-
"contract_skills",warnings));for(const skill of contractSkills){if(!contractLines.has(skill)){warnings.push(`operations.contract_skills \u306E ${skill} \u306B contract_lines \u306E\u63A5\u982D\u8F9E\u304C\u3042\u308A\u307E\u305B\u3093\uFF08\u7DE0\u3081\u51E6\u7406\u306F\u6C4E\u7528\u306E *_RESULT \u884C\u3092\u62FE\u3044\u307E\u3059\uFF09`)}}return{operations:{exclusiveSkills,statusEndpoint,highRiskSkills:new Set(
|
|
33
|
-
o["preflight_hosts"],"preflight_hosts",warnings),releaseRecoverySkill,postSuccessEnqueue:parsePostSuccessEnqueue(o["post_success_enqueue"],warnings),contractSkills,contractLines,advancingOutcomes,zeroTargetGates:parseZeroTargetGates(o["zero_target_gates"],warnings),countHooks:parseCountHooks(o["count_hooks"],warnings),planSkill,planGate,skillPrefix},warnings}}function describeOperations(ops){const plan=ops.
|
|
34
|
-
planGate.maxSkipSec}\u79D2\uFF09`:""}`:"\u8A08\u753B\u30B9\u30AD\u30EB\u672A\u8A2D\u5B9A\uFF08\u8A08\u753B\u30D5\u30A7\u30FC\u30BA\u3092\u884C\u3044\u307E\u305B\u3093\uFF09";const prefix=`\u30B9\u30AD\u30EB\u63A5\u982D\u8F9E '/${ops.skillPrefix}'`;const advance=ops.advancingOutcomes.size>0?`\u518D\u6295\u5165\u6291\u6B62 ${ops.advancingOutcomes.
|
|
35
|
-
exclusiveSkills.size===0&&ops.highRiskSkills.size===0&&ops.postSuccessEnqueue.size===0){return`\u904B\u7528\u8A2D\u5B9A: \u306A\u3057\uFF08\u30B9\u30AD\u30EB\u540D\u306B\u3088\u308B\u7279\u5225\u6271\u3044\u306F\u884C\u3044\u307E\u305B\u3093\uFF09 / ${prefix} / ${plan} / ${advance}`}const parts=[prefix,plan,advance];if(ops.
|
|
36
|
-
0){parts.push(`\u6392\u4ED6 ${[...ops.exclusiveSkills].join(",")}\uFF08\u554F\u3044\u5408\u308F\u305B\u5148\u304C\u7121\u3044\u305F\u3081\u7121\u52B9\uFF09`)}if(ops.highRiskSkills.size>0)parts.push(`\u9AD8\u30EA\u30B9\u30AF ${ops.highRiskSkills.size}\u4EF6`);if(ops.releaseRecoverySkill)parts.push(`\u56DE\u53CE ${ops.releaseRecoverySkill}`);
|
|
37
|
-
`\u5F8C\
|
|
35
|
+
"contract_skills",warnings));for(const skill of contractSkills){if(!contractLines.has(skill)){warnings.push(`operations.contract_skills \u306E ${skill} \u306B contract_lines \u306E\u63A5\u982D\u8F9E\u304C\u3042\u308A\u307E\u305B\u3093\uFF08\u7DE0\u3081\u51E6\u7406\u306F\u6C4E\u7528\u306E *_RESULT \u884C\u3092\u62FE\u3044\u307E\u3059\uFF09`)}}const releaseHooks=parseReleaseHooks(o["release_hooks"],contractLines,skillPrefix,warnings);return{operations:{exclusiveSkills,statusEndpoint,highRiskSkills:new Set(
|
|
36
|
+
stringArray(o["high_risk_skills"],"high_risk_skills",warnings)),preflightHosts:stringArray(o["preflight_hosts"],"preflight_hosts",warnings),releaseRecoverySkill,postSuccessEnqueue:parsePostSuccessEnqueue(o["post_success_enqueue"],warnings),contractSkills,contractLines,advancingOutcomes,zeroTargetGates:parseZeroTargetGates(o["zero_target_gates"],warnings),countHooks:parseCountHooks(o["count_hooks"],warnings),planSkill,planGate,skillPrefix,releaseHooks},warnings}}function describeOperations(ops){const plan=ops.
|
|
37
|
+
planSkill?`\u8A08\u753B ${ops.planSkill}${ops.planGate?`\uFF08plan_gate: \u5165\u529B\u306B\u5909\u5316\u304C\u306A\u3051\u308C\u3070\u7701\u304F\u30FB\u6700\u9577${ops.planGate.maxSkipSec}\u79D2\uFF09`:""}`:"\u8A08\u753B\u30B9\u30AD\u30EB\u672A\u8A2D\u5B9A\uFF08\u8A08\u753B\u30D5\u30A7\u30FC\u30BA\u3092\u884C\u3044\u307E\u305B\u3093\uFF09";const prefix=`\u30B9\u30AD\u30EB\u63A5\u982D\u8F9E '/${ops.skillPrefix}'`;const advance=ops.advancingOutcomes.size>0?`\u518D\u6295\u5165\u6291\u6B62 ${ops.advancingOutcomes.
|
|
38
|
+
size}\u7A2E`:"contract_lines \u672A\u8A2D\u5B9A\uFF08\u518D\u6295\u5165\u6291\u6B62\u3092\u884C\u3044\u307E\u305B\u3093\uFF09";if(ops===NO_OPERATIONS||ops.exclusiveSkills.size===0&&ops.highRiskSkills.size===0&&ops.postSuccessEnqueue.size===0&&ops.releaseHooks===null){return`\u904B\u7528\u8A2D\u5B9A: \u306A\u3057\uFF08\u30B9\u30AD\u30EB\u540D\u306B\u3088\u308B\u7279\u5225\u6271\u3044\u306F\u884C\u3044\u307E\u305B\u3093\uFF09 / ${prefix} / ${plan} / ${advance}`}const parts=[prefix,plan,advance];if(ops.
|
|
39
|
+
exclusiveSkills.size>0&&ops.statusEndpoint){parts.push(`\u6392\u4ED6 ${[...ops.exclusiveSkills].join(",")} \u2190 ${ops.statusEndpoint.url}`)}else if(ops.exclusiveSkills.size>0){parts.push(`\u6392\u4ED6 ${[...ops.exclusiveSkills].join(",")}\uFF08\u554F\u3044\u5408\u308F\u305B\u5148\u304C\u7121\u3044\u305F\u3081\u7121\u52B9\uFF09`)}if(ops.highRiskSkills.size>0)parts.push(`\u9AD8\u30EA\u30B9\u30AF ${ops.highRiskSkills.size}\u4EF6`);if(ops.releaseRecoverySkill)parts.push(`\u56DE\u53CE ${ops.releaseRecoverySkill}`);
|
|
40
|
+
if(ops.releaseHooks){const h=ops.releaseHooks;parts.push(`\u30EA\u30EA\u30FC\u30B9\u5F8C\u51E6\u7406 ${h.skill}\uFF08${h.line?`${h.line} \u884C`:"\u5951\u7D04\u884C\u672A\u8A2D\u5B9A\u306E\u305F\u3081\u5F8C\u51E6\u7406\u306A\u3057"}${h.planGuard?`\u30FB${h.planGuard.countField} > \u8A08\u753B\u5185 ${h.planGuard.drainedBy} \u306A\u3089\u8A08\u753B\u304B\u3089\u9664\u5916`:""}\uFF09`)}for(const[from,f]of ops.postSuccessEnqueue){parts.push(f.keysLine?`\u5F8C\u7D9A ${from}\u2192${f.skill}\uFF08${f.
|
|
41
|
+
keysLine} \u884C\u306E\u30AD\u30FC\u5358\u4F4D\uFF09`:`\u5F8C\u7D9A ${from}\u2192${f.skill}\uFF08keys_line \u672A\u8A2D\u5B9A\u306E\u305F\u3081\u30AD\u30FC\u5358\u4F4D\u306E\u6295\u5165\u306F\u3057\u307E\u305B\u3093\uFF09`)}return`\u904B\u7528\u8A2D\u5B9A: ${parts.join(" / ")}`}export{planGateStatePath,recordPlanned,evaluatePlanGate,parseOperations,describeOperations};
|
|
@@ -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,loadCommandModelIndex,validateBody,validateQuery}from"./chunk-NZ7WI4RZ.js";import{isForceOnly,killProcessTree,system32}from"./chunk-N2UVRM3Z.js";import{redactSecretValues}from"./chunk-LDBYJPRD.js";import{isSafePathSegment}from"./chunk-HVZUXLQ4.js";import{ApiError,TwpApiClient,appendQuery}from"./chunk-JA5A6UJ2.js";import{DEFAULT_MAX_TOKENS,effectiveModelSpec,emptyUsage}from"./chunk-
|
|
3
|
+
import{CommandModelMissingError,MAX_REPORTED_VIOLATIONS,loadCommandModelDomain,loadCommandModelIndex,validateBody,validateQuery}from"./chunk-NZ7WI4RZ.js";import{isForceOnly,killProcessTree,system32}from"./chunk-N2UVRM3Z.js";import{redactSecretValues}from"./chunk-LDBYJPRD.js";import{isSafePathSegment}from"./chunk-HVZUXLQ4.js";import{ApiError,TwpApiClient,appendQuery}from"./chunk-JA5A6UJ2.js";import{DEFAULT_MAX_TOKENS,effectiveModelSpec,emptyUsage}from"./chunk-VON6ODNL.js";
|
|
4
4
|
import{isPrivateTwpHome,isTrustworthyCacheFile,writePrivateFileAtomic}from"./chunk-D233KKXW.js";import{findExecutable,isWindowsDriveAbsolute}from"./chunk-PMOUHEJQ.js";import{AuthSession,NotLoggedInError,SessionExpiredError,withFileLock}from"./chunk-XNLIEUAW.js";import{httpFetch}from"./chunk-J7QYPKVK.js";import{configReadDirs,ensureTwpHome,twpHomeDir}from"./chunk-RZVI6PMW.js";import{MODES,applyPermissionMode,checkPermission,isModeId,setActiveModes}from"./chunk-2LOT54OO.js";
|
|
5
5
|
import{stripTerminalControls}from"./chunk-NHYMHCAT.js";import fs2 from"fs";import path3 from"path";import os2 from"os";import{realpathSync}from"fs";import{homedir}from"os";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),abs);assertNotSecret(abs,home);const real=realOrSelf(abs);if(real!==
|
|
6
6
|
abs){assertInside(real,root,abs);assertNotSecret(real,home)}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(`path escapes the working directory (${reported}). Only paths under ${root} can be accessed.`)}}function realOrSelf(target){let current=target;const rest=[];
|
|
@@ -3,7 +3,7 @@ const require = __twpCreateRequire(import.meta.url);
|
|
|
3
3
|
function isAiUnavailable(outcome){return outcome==="unavailable"||outcome==="rate-limited"||outcome==="network-down"}function needsHumanToRestoreAi(outcome){return outcome==="unavailable"}function aiUnavailableLabel(outcome){if(outcome==="rate-limited")return"\u5168AI\u30EC\u30FC\u30C8\u30EA\u30DF\u30C3\u30C8";if(outcome==="network-down")return"\u30DB\u30B9\u30C8\u5074\u306E\u30CD\u30C3\u30C8\u30EF\u30FC\u30AF\u969C\u5BB3";return"AI \u304C1\u3064\u3082\u4F7F\u3048\u306A\u3044\uFF08\u672A\u30ED\u30B0\u30A4\u30F3\u7B49\uFF09"}
|
|
4
4
|
var SERVER_AI_TYPES=["claude","gemini","codex","copilot"];function isServerAiType(value){return SERVER_AI_TYPES.includes(value)}var NoopEngine=class{constructor(note="\uFF08noop \u30A8\u30F3\u30B8\u30F3: AI \u306F\u8D77\u52D5\u3057\u3066\u3044\u307E\u305B\u3093\uFF09"){this.note=note}note;name="noop";run(req){const output=[`[noop] prompt: ${req.prompt.split("\n").slice(-1)[0]??""}`,`[noop] cwd: ${req.cwd}`,`[noop] ai_type=${req.aiType??"(\u672A\u6307\u5B9A)"} ai_model=${req.aiModel??"(\u672A\u6307\u5B9A)"}`,
|
|
5
5
|
this.note].join("\n");return Promise.resolve({outcome:"ok",usedAi:"noop",serverAiType:null,output})}};var UnknownEngineError=class extends Error{constructor(name,available){super(`\u672A\u77E5\u306E\u30A8\u30F3\u30B8\u30F3\u3067\u3059: ${name}\uFF08\u5229\u7528\u3067\u304D\u308B\u306E\u306F ${available.join(" / ")}\uFF09`)}};var ENGINE_NAMES=["cli","noop"];function assertKnownEngine(name){if(!ENGINE_NAMES.includes(name)){throw new UnknownEngineError(name,ENGINE_NAMES)}}var EngineNotConfiguredError=class extends Error{constructor(){
|
|
6
|
-
super('\u5B9F\u884C\u30A8\u30F3\u30B8\u30F3\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002\n \u5B9F AI \u3092\u8D77\u52D5\u3059\u308B\u306A\u3089 --engine cli\uFF08\u8A2D\u5B9A\u306A\u3089 "engine": "cli"\uFF09\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\u3002\n \u9AA8\u683C\u3060\u3051\u3092\u691C\u8A3C\u3057\u305F\u3044\u5834\u5408\u306F --engine noop \u3092**\u660E\u793A**\u3057\u3066\u304F\u3060\u3055\u3044\u3002\n \u26A0\uFE0F noop \u306F AI \u30921\u3064\u3082\u8D77\u52D5\u305B\u305A\u30A2\u30A4\u30C6\u30E0\u3092 completed \u306B\u3057\u307E\u3059\u3002**\u5B9F\u30AD\u30E5\u30FC\uFF08\u672C\u756A\u306E TWP \u7B49\uFF09\u3078\u5411\u3051\u306A\u3044\u3053\u3068**\n \u5B9A\u671F\u7531\u6765\u306E\u30A2\u30A4\u30C6\u30E0\u306A\u3089\u67A0\u307E\u3067\u6D88\u5316\u3055\u308C\u3001\u305D\u306E\u7A93\u306E
|
|
6
|
+
super('\u5B9F\u884C\u30A8\u30F3\u30B8\u30F3\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002\n \u5B9F AI \u3092\u8D77\u52D5\u3059\u308B\u306A\u3089 --engine cli\uFF08\u8A2D\u5B9A\u306A\u3089 "engine": "cli"\uFF09\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\u3002\n \u9AA8\u683C\u3060\u3051\u3092\u691C\u8A3C\u3057\u305F\u3044\u5834\u5408\u306F --engine noop \u3092**\u660E\u793A**\u3057\u3066\u304F\u3060\u3055\u3044\u3002\n \u26A0\uFE0F noop \u306F AI \u30921\u3064\u3082\u8D77\u52D5\u305B\u305A\u30A2\u30A4\u30C6\u30E0\u3092 completed \u306B\u3057\u307E\u3059\u3002**\u5B9F\u30AD\u30E5\u30FC\uFF08\u672C\u756A\u306E TWP \u7B49\uFF09\u3078\u5411\u3051\u306A\u3044\u3053\u3068**\n \u5B9A\u671F\u7531\u6765\u306E\u30A2\u30A4\u30C6\u30E0\u306A\u3089\u67A0\u307E\u3067\u6D88\u5316\u3055\u308C\u3001\u305D\u306E\u7A93\u306E\u30EA\u30EA\u30FC\u30B9\u30FB\u30DE\u30FC\u30B8\u7B49\u306E\u5B9A\u671F\u51E6\u7406\u304C\u767A\u706B\u3057\u306A\u304F\u306A\u308A\u307E\u3059\u3002')}};var MAX_SCAN_BYTES=512*1024;var PROGRESS_PREFIX=/^\s*\[\d{2}:\d{2}:\d{2}\]\s*/;var FINAL_REPORT_BEGIN="<<<AI_FINAL_REPORT>>>";var FINAL_REPORT_END="<<<END_AI_FINAL_REPORT>>>";var TRANSCRIPT_MARKER=/^(>>|<<|⛔|!!)\s/;function stripProgressPrefix(line){return line.replace(PROGRESS_PREFIX,"").trim()}function stripTranscript(raw){return filterLines(raw,true)}function stripModelProse(raw){return filterLines(raw,false)}function filterLines(raw,dropToolLines){const out=[];let inReport=false;for(const line of raw.
|
|
7
7
|
split("\n")){if(line.includes(FINAL_REPORT_BEGIN)){inReport=true;continue}if(line.includes(FINAL_REPORT_END)){inReport=false;continue}if(inReport||line.includes("\u{1F4AC}"))continue;if(dropToolLines&&TRANSCRIPT_MARKER.test(stripProgressPrefix(line)))continue;out.push(line)}return out.join("\n")}var UNTRUSTED_PATTERNS=[/has not been trusted/i,/Ignoring [0-9]+ permissions\.allow entries/i];function isUntrusted(raw){const text=stripTranscript(raw);return UNTRUSTED_PATTERNS.some(p=>p.test(text))}var CLI_FATAL_TEXT_PATTERNS=[
|
|
8
8
|
/^api error\b/i,/^failed to authenticate\b/i];function isCliFatalText(text){const head=text.trim();return CLI_FATAL_TEXT_PATTERNS.some(p=>p.test(head))}var CODEX_PLAIN_LIMIT_PATTERNS=[/^(?:error\s*:\s*)?you(?:'ve| have)? hit (?:your|the) (?:usage|session|weekly|rate|quota|spend) (?:limit|cap)\b.*$/i,/^(?:error\s*:\s*)?(?:your|the) (?:usage|rate|session|quota) limit (?:has been )?(?:reached|exceeded)\b.*$/i,/^(?:error\s*:\s*)?(?:usage|rate|session|quota) limit (?:reached|exceeded)\b.*$/i,/^try again at\s+(?:jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)[a-z]*\s+\d{1,2}(?:st|nd|rd|th)?\b.*$/i];
|
|
9
9
|
var CODEX_RUST_LIMIT_PATTERN=/^(?:\d{4}-\d{2}-\d{2}T\S+\s+)?(?:ERROR|WARN)\s+codex(?:[_:]+[a-z0-9-]+){0,8}\s*:\s*.*(?:\b(?:429|529)\b|(?:usage|rate|session)[ ._-]*limit|quota[_ -]?(?:exhausted|exceeded))/i;var COMMON_LIMIT_PATTERNS=[/(?:status|code|http)[^a-z0-9]{0,10}429/i,/429[^0-9].{0,15}(?:too many|rate|throttl)/i,/(?:status|code|http)[^a-z0-9]{0,10}529/i,/529[^0-9].{0,15}overloaded/i,/too many requests/i,/max.?spend.?(?:limit|reached|exceeded)/i,/spending.?limit/i,/resets?\s+\d+(?::\d+)?\s*(?:am|pm)/i];
|
|
@@ -6,7 +6,16 @@ model,max_tokens:request.maxTokens,...request.system!==void 0?{system:request.sy
|
|
|
6
6
|
-1);if(block?.type==="tool_use"&&typeof block.id==="string"&&typeof block.name==="string"){const seeded=block.input;const initial=typeof seeded==="object"&&seeded!==null&&!Array.isArray(seeded)?JSON.stringify(seeded):"";return[{kind:"tool_start",index,id:block.id,name:block.name,initialJson:initial==="{}"?"":initial}]}return[]}if(type==="content_block_delta"){const delta=parsed["delta"];if(delta?.type==="text_delta"&&typeof delta.text==="string"&&delta.text!==""){return[{kind:"text",delta:delta.
|
|
7
7
|
text}]}if(delta?.type==="input_json_delta"&&typeof delta.partial_json==="string"){return[{kind:"tool_delta",index:numberOr(parsed["index"],-1),json:delta.partial_json}]}return[]}if(type==="content_block_stop"){return[{kind:"tool_end",index:numberOr(parsed["index"],-1)}]}if(type==="message_delta"){const out=usageEvent(parsed["usage"]);const delta=parsed["delta"];if(typeof delta?.stop_reason==="string")out.push({kind:"stop",reason:delta.stop_reason});return out}if(type==="error"){const err=parsed["\
|
|
8
8
|
error"];return[{kind:"error",message:typeof err?.message==="string"?err.message:"\u30B9\u30C8\u30EA\u30FC\u30E0\u304C\u4E2D\u65AD\u3055\u308C\u307E\u3057\u305F"}]}return[]}function usageEvent(source){if(typeof source!=="object"||source===null)return[];const raw=source;const usage={};const pick=(key,field)=>{const v=raw[key];if(typeof v==="number"&&Number.isFinite(v))usage[field]=v};pick("input_tokens","inputTokens");pick("cache_read_input_tokens","cacheReadTokens");pick("cache_creation_input_tok\
|
|
9
|
-
ens","cacheWriteTokens");pick("output_tokens","outputTokens");return[{kind:"usage",usage}]}function numberOr(value,fallback){return typeof value==="number"&&Number.isFinite(value)?value:fallback}function safeJson(text){try{const parsed=JSON.parse(text);return typeof parsed==="object"&&parsed!==null?parsed:null}catch{return null}}
|
|
9
|
+
ens","cacheWriteTokens");pick("output_tokens","outputTokens");return[{kind:"usage",usage}]}function numberOr(value,fallback){return typeof value==="number"&&Number.isFinite(value)?value:fallback}function safeJson(text){try{const parsed=JSON.parse(text);return typeof parsed==="object"&&parsed!==null?parsed:null}catch{return null}}import{randomUUID}from"crypto";var geminiAdapter={protocol:"gemini",streamPath:"/api/cli/v1/gemini/stream",toRequestBody:toRequestBody2,decode:decode2};var thoughtSignatures=new Map;var SKIP_THOUGHT_SIGNATURE="skip_thought_signature_validator";var MAX_SIGNATURES=2e3;function rememberSignature(id,signature,model){if(thoughtSignatures.size>=MAX_SIGNATURES){const oldest=thoughtSignatures.keys().next();if(!oldest.done)thoughtSignatures.delete(oldest.value)}thoughtSignatures.set(id,{signature,model})}
|
|
10
|
+
function signatureFor(id,model){const saved=thoughtSignatures.get(id);return saved!==void 0&&saved.model===model?saved.signature:SKIP_THOUGHT_SIGNATURE}var currentModel="";var nextToolIndex=0;function toRequestBody2(request){currentModel=request.model;const toolNames=new Map;for(const message of request.messages){for(const block of message.content){if(block.type==="tool_use")toolNames.set(block.id,block.name)}}const tools=request.tools&&request.tools.length>0?request.tools:void 0;return{model:request.model,contents:request.messages.map(message=>toContent(message,toolNames,request.model)),...request.system!==void 0&&request.system!==""?{systemInstruction:{parts:[{text:request.
|
|
11
|
+
system}]}}:{},...tools?{tools:[{functionDeclarations:tools.map(tool=>({name:tool.name,description:tool.description,parametersJsonSchema:tool.input_schema}))}]}:{},generationConfig:{maxOutputTokens:request.maxTokens}}}function toContent(message,toolNames,model){const parts=[];for(const block of message.content){if(block.type==="text"){if(block.text!=="")parts.push({text:block.text})}else if(block.type==="tool_use"){parts.push({functionCall:{id:block.id,name:block.name,args:block.input},thoughtSignature:signatureFor(
|
|
12
|
+
block.id,model)})}else{parts.push({functionResponse:{id:block.tool_use_id,name:toolNames.get(block.tool_use_id)??"unknown",response:block.is_error===true?{error:block.content}:{output:block.content}}})}}if(parts.length===0)parts.push({text:" "});return{role:message.role==="assistant"?"model":"user",parts}}function decode2(ev){const parsed=safeJson2(ev.data);if(!parsed){return ev.event==="error"?[{kind:"error",message:ev.data.trim()||"\u30B9\u30C8\u30EA\u30FC\u30E0\u304C\u4E2D\u65AD\u3055\u308C\u307E\u3057\u305F"}]:
|
|
13
|
+
[]}if(ev.event==="error"||typeof parsed["error"]==="object"&&parsed["error"]!==null){const err=parsed["error"];return[{kind:"error",message:typeof err?.message==="string"?err.message:"\u30B9\u30C8\u30EA\u30FC\u30E0\u304C\u4E2D\u65AD\u3055\u308C\u307E\u3057\u305F"}]}const out=[];const candidates=Array.isArray(parsed["candidates"])?parsed["candidates"]:[];const candidate=candidates[0];const parts=Array.isArray(candidate?.content?.parts)?candidate.content.parts:[];for(const raw of parts){if(typeof raw!==
|
|
14
|
+
"object"||raw===null)continue;const part=raw;if(part.functionCall&&typeof part.functionCall.name==="string"){const id=typeof part.functionCall.id==="string"&&part.functionCall.id!==""?part.functionCall.id:`gemini_${randomUUID()}`;if(typeof part.thoughtSignature==="string"&&part.thoughtSignature!==""){rememberSignature(id,part.thoughtSignature,currentModel)}const args=part.functionCall.args;const index=nextToolIndex++;out.push({kind:"tool_start",index,id,name:part.functionCall.name,initialJson:typeof args===
|
|
15
|
+
"object"&&args!==null&&!Array.isArray(args)?JSON.stringify(args):""});out.push({kind:"tool_end",index});continue}if(typeof part.text==="string"&&part.text!==""&&part.thought!==true){out.push({kind:"text",delta:part.text})}}const usage=usageOf(parsed["usageMetadata"]);if(usage)out.push({kind:"usage",usage});const feedback=parsed["promptFeedback"];if(typeof feedback?.blockReason==="string"&&feedback.blockReason!==""){out.push({kind:"error",message:`Gemini \u304C\u8981\u6C42\u3092\u62D2\u5426\u3057\u307E\u3057\u305F: ${feedback.
|
|
16
|
+
blockReason}`})}if(typeof candidate?.finishReason==="string"&&candidate.finishReason!==""){const reason=candidate.finishReason;out.push({kind:"stop",reason:stopReasonOf(reason)});if(!NORMAL_FINISH_REASONS.has(reason)){out.push({kind:"error",message:`Gemini \u304C\u5FDC\u7B54\u3092\u6253\u3061\u5207\u308A\u307E\u3057\u305F: ${reason}`})}}return out}var NORMAL_FINISH_REASONS=new Set(["STOP","MAX_TOKENS","FINISH_REASON_UNSPECIFIED"]);function usageOf(source){if(typeof source!=="object"||source===null)
|
|
17
|
+
return null;const raw=source;const num=key=>{const v=raw[key];return typeof v==="number"&&Number.isFinite(v)?Math.max(0,v):null};const prompt=num("promptTokenCount");const candidates=num("candidatesTokenCount");if(prompt===null&&candidates===null)return null;const usage={};if(prompt!==null){const cached=Math.min(num("cachedContentTokenCount")??0,prompt);usage.inputTokens=prompt-cached;usage.cacheReadTokens=cached;usage.cacheWriteTokens=0}if(candidates!==null||num("thoughtsTokenCount")!==null){usage.
|
|
18
|
+
outputTokens=(candidates??0)+(num("thoughtsTokenCount")??0)}return usage}function stopReasonOf(finishReason){if(finishReason==="STOP")return"end_turn";if(finishReason==="MAX_TOKENS")return"max_tokens";return finishReason.toLowerCase()}function safeJson2(text){try{const parsed=JSON.parse(text);return typeof parsed==="object"&&parsed!==null&&!Array.isArray(parsed)?parsed:null}catch{return null}}var ADAPTERS={anthropic:anthropicAdapter,gemini:geminiAdapter};var PROTOCOLS_HEADER="X-TWP-CLI-Protocols";function supportedProtocols(){return Object.keys(ADAPTERS)}function isModelProtocol(value){return value==="anthropic"||value==="openai-chat"||value==="gemini"}function adapterFor(protocol){return ADAPTERS[protocol]??null}var DEFAULT_PROVIDER="anthropic";function effectiveModelSpec(spec){return{provider:spec?.provider??DEFAULT_PROVIDER,protocol:spec?.protocol??"anthropic",contextWindow:spec?.contextWindow??null,maxOutputTokens:spec?.maxOutputTokens??null,tools:spec?.capabilities?.tools??true,promptCache:spec?.capabilities?.promptCache??"explicit"}}var PROVIDER_PATTERN=/^[a-z0-9-]{1,32}$/;function positiveInt(value){return typeof value==="number"&&Number.isInteger(value)&&value>0?value:void 0}function parseModelSpec(id,raw){
|
|
10
19
|
const spec={id};if(typeof raw!=="object"||raw===null)return spec;const r=raw;if(typeof r["provider"]==="string"&&PROVIDER_PATTERN.test(r["provider"]))spec.provider=r["provider"];if(isModelProtocol(r["protocol"]))spec.protocol=r["protocol"];const contextWindow=positiveInt(r["context_window"]);if(contextWindow!==void 0)spec.contextWindow=contextWindow;const maxOutputTokens=positiveInt(r["max_output_tokens"]);if(maxOutputTokens!==void 0)spec.maxOutputTokens=maxOutputTokens;const caps=r["capabilitie\
|
|
11
20
|
s"];if(typeof caps==="object"&&caps!==null){const c=caps;const capabilities={};if(typeof c["tools"]==="boolean")capabilities.tools=c["tools"];const cache=c["prompt_cache"];if(cache==="explicit"||cache==="automatic"||cache==="none")capabilities.promptCache=cache;if(Object.keys(capabilities).length>0)spec.capabilities=capabilities}return spec}function toWireSpec(spec){return{id:spec.id,...spec.provider!==void 0?{provider:spec.provider}:{},...spec.protocol!==void 0?{protocol:spec.protocol}:{},...spec.
|
|
12
21
|
contextWindow!==void 0?{context_window:spec.contextWindow}:{},...spec.maxOutputTokens!==void 0?{max_output_tokens:spec.maxOutputTokens}:{},...spec.capabilities!==void 0?{capabilities:{...spec.capabilities.tools!==void 0?{tools:spec.capabilities.tools}:{},...spec.capabilities.promptCache!==void 0?{prompt_cache:spec.capabilities.promptCache}:{}}}:{}}}function modelCachePath(env=process.env){return path.join(twpHomeDir(env),"models.json")}function modelCacheLockPath(env=process.env){return path.join(twpHomeDir(env),"models.lock")}function builtinCatalog(){return{ids:MODELS.map(m=>m.id),source:"builtin",fetchedAt:null,minSupportedVersion:null}}function readCacheFile(env){const file=modelCachePath(env);if(!isTrustworthyCacheFile(file)){return{version:1,entries:{}}}const parsed=JSON.parse(fs.readFileSync(file,"utf8"));if(!parsed||typeof parsed!==
|
|
@@ -25,7 +34,7 @@ timeout(MODELS_TIMEOUT_MS));const body=await res.json().catch(()=>null);const mo
|
|
|
25
34
|
const floor=body?.min_supported_version;const minSupportedVersion=typeof floor==="string"&&parseVersionCore(floor)!==null?floor.trim():null;return{ids,models,minSupportedVersion}}async stream(request,hooks){const protocol=request.protocol??"anthropic";const adapter=adapterFor(protocol);if(!adapter){throw new RelayError("validation",`\u30E2\u30C7\u30EB ${request.model} \u306F ${protocol} \u30D7\u30ED\u30C8\u30B3\u30EB\u306E\u305F\u3081\u3001\u3053\u306E\u7248\u306E twp \u3067\u306F\u5229\u7528\u3067\u304D\u307E\u305B\u3093\uFF08twp \u3092\u66F4\u65B0\u3057\u3066\u304F\u3060\u3055\u3044\uFF09`)}
|
|
26
35
|
let res;try{res=await this.send("POST",adapter.streamPath,adapter.toRequestBody({model:request.model,maxTokens:request.maxTokens,...request.system!==void 0?{system:request.system}:{},messages:request.messages,...request.tools!==void 0?{tools:request.tools}:{},promptCache:request.promptCache??"explicit"}),hooks.signal)}catch(err){if(isAbortError(err)||hooks.signal?.aborted===true){return{text:"",usage:emptyUsage(),toolUses:[],stopReason:null,aborted:true,upstreamError:null}}throw err}const body=res.
|
|
27
36
|
body;if(!body){throw new RelayError("upstream","\u30EA\u30EC\u30FC\u304C\u5FDC\u7B54\u672C\u6587\u3092\u8FD4\u3057\u307E\u305B\u3093\u3067\u3057\u305F")}const parser=new SseParser;const decoder=new TextDecoder;const usage=emptyUsage();let text="";let stopReason=null;let streamError=null;const reader=body.getReader();const building=new Map;const toolUses=[];const finalizeBlock=index=>{const pending=building.get(index);if(!pending)return;building.delete(index);const input=pending.json.trim()===""?
|
|
28
|
-
{}:
|
|
37
|
+
{}:safeJson3(pending.json);if(input===null){streamError=`\u30C4\u30FC\u30EB ${pending.name} \u306E\u5F15\u6570\u3092\u89E3\u91C8\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F`;return}toolUses.push({type:"tool_use",id:pending.id,name:pending.name,input})};const apply=ev=>{switch(ev.kind){case"usage":Object.assign(usage,ev.usage);return;case"text":text+=ev.delta;hooks.onTextDelta(ev.delta);return;case"tool_start":building.set(ev.index,{id:ev.id,name:ev.name,json:ev.initialJson});return;case"tool\
|
|
29
38
|
_delta":{const pending=building.get(ev.index);if(pending)pending.json+=ev.json;return}case"tool_end":finalizeBlock(ev.index);return;case"stop":stopReason=ev.reason;return;case"error":streamError=ev.message;return}};const handle=events=>{for(const ev of events){for(const neutral of adapter.decode(ev))apply(neutral)}};const onAbort=()=>{void reader.cancel().catch(()=>void 0)};if(hooks.signal){if(hooks.signal.aborted)onAbort();else hooks.signal.addEventListener("abort",onAbort,{once:true})}try{for(;;){
|
|
30
39
|
const{done,value}=await reader.read();if(done)break;handle(parser.push(decoder.decode(value,{stream:true})))}handle(parser.flush())}catch(err){if(err instanceof SseBufferOverflowError){streamError=err.message}else if(!isAbortError(err)&&hooks.signal?.aborted!==true){throw new RelayError("network",`\u30B9\u30C8\u30EA\u30FC\u30E0\u304C\u5207\u65AD\u3055\u308C\u307E\u3057\u305F: ${errorMessage(err)}`)}}finally{hooks.signal?.removeEventListener("abort",onAbort);void reader.cancel().catch(()=>void 0)}
|
|
31
40
|
for(const index of[...building.keys()])finalizeBlock(index);return{text,usage,toolUses,stopReason,aborted:hooks.signal?.aborted===true,upstreamError:streamError===null?null:stripTerminalControls(streamError)}}async send(method,path2,body,signal){let token;try{token=await this.session.getAccessToken()}catch(err){throw new RelayError("not_logged_in",errorMessage(err))}let res=await this.fetchOrThrow(method,path2,token,body,signal);if(res.status===401){try{token=await this.session.refresh(token)}catch(err){
|
|
@@ -33,7 +42,7 @@ throw new RelayError("not_logged_in",errorMessage(err))}res=await this.fetchOrTh
|
|
|
33
42
|
void 0?{"Content-Type":"application/json"}:{}},...body!==void 0?{body:JSON.stringify(body)}:{},...signal?{signal}:{}})}catch(err){if(isAbortError(err))throw err;throw new RelayError("network",`\u30E2\u30C7\u30EB\u53D6\u6B21\u30B5\u30FC\u30D0\u306B\u63A5\u7D9A\u3067\u304D\u307E\u305B\u3093\uFF08${this.relayUrl}\uFF09: ${errorMessage(err)}`)}}};async function toRelayError(res){const body=await res.json().catch(()=>null);const nested=typeof body?.error==="object"&&body.error!==null?body.error:void 0;
|
|
34
43
|
const message=stripTerminalControls(body?.message??nested?.message??`HTTP ${res.status}`);if(res.status===401){return new RelayError("unauthorized","\u30E2\u30C7\u30EB\u53D6\u6B21\u306E\u8A8D\u8A3C\u306B\u5931\u6557\u3057\u307E\u3057\u305F\u3002`twp login`\uFF08\u30D6\u30E9\u30A6\u30B6\u59D4\u8B72\uFF09\u307E\u305F\u306F `twp login --password` \u3067\u30ED\u30B0\u30A4\u30F3\u3057\u76F4\u3057\u3066\u304F\u3060\u3055\u3044\uFF08`twp login --token` \u3067\u4FDD\u5B58\u3057\u305F\u901A\u5E38\u30C8\u30FC\u30AF\u30F3\u306F\u30E2\u30C7\u30EB\u53D6\u6B21\u306B\u306F\u4F7F\u3048\u307E\u305B\u3093\uFF09\u3002",
|
|
35
44
|
401)}if(res.status===403){return new RelayError("cli_disabled",message,403)}if(res.status===429){return new RelayError("rate_limit",message,429)}if(res.status===400){const detail=body?.details;if(Array.isArray(detail?.allowed_models)){return new RelayError("model_not_allowed",`${message}
|
|
36
|
-
\u5229\u7528\u3067\u304D\u308B\u30E2\u30C7\u30EB: ${detail.allowed_models.join(" / ")}`,400)}return new RelayError("validation",message,400)}if(res.status===503){return new RelayError("unavailable",message,503)}return new RelayError("upstream",message,res.status)}function
|
|
45
|
+
\u5229\u7528\u3067\u304D\u308B\u30E2\u30C7\u30EB: ${detail.allowed_models.join(" / ")}`,400)}return new RelayError("validation",message,400)}if(res.status===503){return new RelayError("unavailable",message,503)}return new RelayError("upstream",message,res.status)}function safeJson3(text){try{const parsed=JSON.parse(text);return typeof parsed==="object"&&parsed!==null?parsed:null}catch{return null}}function isAbortError(err){return err instanceof Error&&(err.name==="AbortError"||err.name==="Timeo\
|
|
37
46
|
utError")}function errorMessage(err){return err instanceof Error?err.message:String(err)}var DEFAULT_CONTEXT_WINDOW_TOKENS=2e5;var DEFAULT_MAX_TOKENS=8192;var TRIM_THRESHOLD=.8;var ContextManager=class{constructor(defaultContextWindowTokens=DEFAULT_CONTEXT_WINDOW_TOKENS){this.defaultContextWindowTokens=defaultContextWindowTokens;this.contextWindowTokens=defaultContextWindowTokens}defaultContextWindowTokens;messages=[];totals=emptyUsage();turns=0;lastPromptTokens=0;pendingChars=0;droppedMessages=0;contextWindowTokens;setContextWindow(tokens){this.contextWindowTokens=tokens!==null&&tokens>
|
|
38
47
|
0?tokens:this.defaultContextWindowTokens}addUser(text){this.pendingChars+=text.length;const last=this.messages[this.messages.length-1];if(last?.role==="user"){last.content.push({type:"text",text});return}this.messages.push({role:"user",content:[{type:"text",text}]})}addToolExchange(assistantText,toolUses,results){if(toolUses.length===0)return;const blocks=[];if(assistantText.trim()!=="")blocks.push({type:"text",text:assistantText});blocks.push(...toolUses);this.messages.push({role:"assistant",content:blocks});
|
|
39
48
|
this.messages.push({role:"user",content:results});this.pendingChars+=blocks.reduce((n,b)=>n+blockLength(b),0);this.pendingChars+=results.reduce((n,b)=>n+blockLength(b),0)}completeTurn(assistantText){const text=assistantText.trim();if(text===""){const last=this.messages[this.messages.length-1];if(last?.role==="user"&&!hasToolResult(last)){this.messages.pop();this.pendingChars=Math.max(0,this.pendingChars-lengthOf(last))}return false}this.messages.push({role:"assistant",content:[{type:"text",text:assistantText}]});
|
|
@@ -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-4DY3NU53.js";import{renderDocument,renderOutput}from"./chunk-PO35MCYP.js";import{JsonBodyWithView}from"./chunk-Q3B65OFC.js";import{evaluateQuery}from"./chunk-GFLGXGWE.js";import{redactSecretValues,redactSecrets,withDebug}from"./chunk-LDBYJPRD.js";import{parseOperationArgs}from"./chunk-RX5HWI4L.js";import{Resolver,requireDefaultProject}from"./chunk-RSSPNFSK.js";import{ResolveError}from"./chunk-HVZUXLQ4.js";import{ApiError,
|
|
4
4
|
MultipartBody,TwpApiClient,appendQuery}from"./chunk-JA5A6UJ2.js";import{DEFAULT_MAX_ITEMS,DEFAULT_MAX_PAGES,nextPageNotes,positiveInteger,shellQuote}from"./chunk-MI6HVYR2.js";import{isRecord}from"./chunk-3ZRMMBP5.js";import{ApiRejectedError,ApiResponseError,EXIT_API_CLIENT,EXIT_API_SERVER,EXIT_AUTH,EXIT_FAILURE,EXIT_OK,EXIT_USAGE,EXIT_WAIT_TIMEOUT,NetworkError,UsageError,WaitTimeoutError}from"./chunk-VFPY2A23.js";import{GLOBAL_OPTIONS_HELP}from"./chunk-PECIBNFD.js";
|
|
5
5
|
import{AuthSession,NotLoggedInError,SessionExpiredError,loadCredentials}from"./chunk-XNLIEUAW.js";import{httpFetch}from"./chunk-J7QYPKVK.js";import{effectiveApiUrl,loadUserConfig,resolveConfiguredBacklogSpace,resolveConfiguredOutput,resolveProfile}from"./chunk-EDF4U5BT.js";import{HELP_TOKEN}from"./chunk-MLRBDF44.js";import{OUTPUT_FORMATS,resolveOutputFormat}from"./chunk-74BPZOKU.js";import{stringWidth}from"./chunk-UREA4ZIG.js";import{stripTerminalControls}from"./chunk-NHYMHCAT.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{parseOperations}from"./chunk-
|
|
3
|
+
import{parseOperations}from"./chunk-CVX2YWHC.js";import{parseCapacityProbe}from"./chunk-VYDPW2YO.js";import{validateHooks}from"./chunk-TTST7UDR.js";import{DEFAULT_CLAUDE_LAUNCHER,loadAiConfig}from"./chunk-FABDZBDZ.js";import{projectFileKey}from"./chunk-RMFLTSOV.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){
|