@outerlayer/cli 0.38.0-next.20261105155912 → 0.38.0-next.20261106003041
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/dist/agent-setup-CBEPGNFY.js +40 -0
- package/dist/{agent-subcommand-KPQGEOPQ.js → agent-subcommand-UNSXJUHA.js} +6 -6
- package/dist/{artifact-link-cmd-72FQTBGO.js → artifact-link-cmd-QP6VO7AJ.js} +2 -2
- package/dist/{bridge-F4BNXRM2.js → bridge-JI4IO7JN.js} +9 -9
- package/dist/build-2L3L2OJO.js +24 -0
- package/dist/build-disk-CKBEEF4N.js +21 -0
- package/dist/build-info.json +1 -1
- package/dist/builder-PKDA7X2H.js +20 -0
- package/dist/caller-XETCC46J.js +23 -0
- package/dist/{check-CZM3LZ7Y.js → check-FG32SYJF.js} +59 -59
- package/dist/{chunk-K7BI4TLM.js → chunk-256R6O56.js} +20 -7
- package/dist/{chunk-HU3POMM4.js → chunk-2MQQASWB.js} +6 -6
- package/dist/{chunk-H6H5GCM6.js → chunk-3DVCPRKE.js} +22 -11
- package/dist/{chunk-PMBG7IYE.js → chunk-3FAJMXBA.js} +11 -11
- package/dist/{chunk-QDM23DTW.js → chunk-3XWZKL2P.js} +10 -10
- package/dist/{chunk-3PR7BPMG.js → chunk-45TFVWNT.js} +6 -6
- package/dist/{chunk-6XYKZH3K.js → chunk-4MSEUIMK.js} +14 -8
- package/dist/{chunk-QAFR65VC.js → chunk-5R5FEPLH.js} +1 -1
- package/dist/{chunk-2C3XLYO5.js → chunk-5VAXNAOD.js} +1 -1
- package/dist/{chunk-QJKW4MKH.js → chunk-7PZDPISM.js} +54 -2
- package/dist/{chunk-YU6XPJ5I.js → chunk-ABN4UBR5.js} +3 -3
- package/dist/{chunk-XN4A275V.js → chunk-AJC5Q2NY.js} +23 -13
- package/dist/{chunk-HVUS5WRU.js → chunk-AMG5ICDO.js} +4 -4
- package/dist/{chunk-IYUJFAQD.js → chunk-AVEF3T6Y.js} +919 -36
- package/dist/{chunk-EKRLMOWS.js → chunk-BL6CCU26.js} +7 -7
- package/dist/{chunk-3B5H5MGB.js → chunk-BO3NOGKE.js} +3 -3
- package/dist/{chunk-BMYIPXBG.js → chunk-CCMKLF7K.js} +6 -6
- package/dist/{chunk-DP6ZOSCR.js → chunk-CGXYPLK3.js} +24 -10
- package/dist/{chunk-K7KQCOSM.js → chunk-DK5YFDYI.js} +9 -9
- package/dist/{chunk-IJN3GP4M.js → chunk-DL5N6V3D.js} +1 -1
- package/dist/{chunk-VG524OUD.js → chunk-DVFGCVTV.js} +5 -5
- package/dist/{chunk-EVFZUFCO.js → chunk-DXBYNJRM.js} +6 -6
- package/dist/{chunk-45UZPTDQ.js → chunk-EERD7VI3.js} +1 -1
- package/dist/{chunk-U63SE2NJ.js → chunk-EFAOERZH.js} +1 -1
- package/dist/{chunk-64D2YZK5.js → chunk-EHJYXABQ.js} +1 -1
- package/dist/{chunk-2FDWTE6F.js → chunk-ERQLHUWU.js} +5 -5
- package/dist/{chunk-MPGTKJOM.js → chunk-EXIZ3G6I.js} +6 -6
- package/dist/{chunk-KXKVMSHC.js → chunk-FER7JJ3S.js} +1 -1
- package/dist/{chunk-OVRLLZPJ.js → chunk-FGVVBYCT.js} +1 -1
- package/dist/{chunk-J56SR6X4.js → chunk-FOUG2R4Q.js} +1 -1
- package/dist/{chunk-35RIDLSD.js → chunk-GMRVWRHD.js} +2 -2
- package/dist/{chunk-LMT72G74.js → chunk-HG2ZG6ZU.js} +1 -1
- package/dist/{chunk-2QIK3JRV.js → chunk-IRFN2ZHJ.js} +1 -1
- package/dist/{chunk-VVZIFOAN.js → chunk-IXB2IIEW.js} +1 -1
- package/dist/{chunk-GMRIR2MF.js → chunk-JTDMSQMI.js} +9 -9
- package/dist/{chunk-TOH7FJH3.js → chunk-K6JOU4CT.js} +42 -31
- package/dist/{chunk-RVIZRXBK.js → chunk-KLQLQQGG.js} +3 -3
- package/dist/{chunk-L25GQH45.js → chunk-L4ACBB5R.js} +1 -1
- package/dist/{chunk-7TPLWWFN.js → chunk-M53UNEO6.js} +1 -1
- package/dist/{chunk-IG7SBYJY.js → chunk-MDKLSY43.js} +1 -1
- package/dist/{chunk-3J7F3VGZ.js → chunk-MPE4NOKD.js} +2 -2
- package/dist/{chunk-ZBPUHNUZ.js → chunk-NEEMG462.js} +1 -1
- package/dist/{chunk-CUAV3727.js → chunk-O4Z2YVC3.js} +5 -5
- package/dist/{chunk-SSSPZ3TB.js → chunk-OFWNBTLU.js} +1 -1
- package/dist/{chunk-5YWOGS66.js → chunk-OGQW7A4G.js} +16 -12
- package/dist/{chunk-MY6T3N3A.js → chunk-ONOINHY4.js} +1 -1
- package/dist/{chunk-XUXDUOJI.js → chunk-OUHM6U6Z.js} +6 -6
- package/dist/{chunk-JCEJARDB.js → chunk-PARDL7HH.js} +1 -1
- package/dist/{chunk-WWTZLRPH.js → chunk-PLVHIQJN.js} +43 -3
- package/dist/{chunk-EOVVSXRH.js → chunk-PMJ6IEUM.js} +7 -7
- package/dist/{chunk-OCDG3ZWH.js → chunk-QONY6C2B.js} +9 -9
- package/dist/{chunk-FRQPX2QR.js → chunk-QWDGHEQL.js} +3 -3
- package/dist/{chunk-AWY7ORQ2.js → chunk-RNCCRUT5.js} +1 -1
- package/dist/{chunk-J7MMYBBV.js → chunk-RSRNZB4T.js} +7 -7
- package/dist/{chunk-MB7IX6DO.js → chunk-RUJR3SDB.js} +1 -1
- package/dist/{chunk-RM3K57Q7.js → chunk-RZ6WJTUP.js} +39 -16
- package/dist/{chunk-XQSTN7NG.js → chunk-S7CE7QCF.js} +3 -3
- package/dist/{chunk-OV4XTV5M.js → chunk-SF2TBJBP.js} +7 -4
- package/dist/{chunk-WHPMCF7R.js → chunk-SMFWLPXC.js} +18 -18
- package/dist/{chunk-Y2HVISUN.js → chunk-T524XQKI.js} +1 -1
- package/dist/{chunk-2RKPEUGK.js → chunk-TAEDH2SU.js} +1 -1
- package/dist/{chunk-W7LJQ2GU.js → chunk-U5EE7PGC.js} +4 -4
- package/dist/{chunk-SUMRSD2Q.js → chunk-U7L4GBGS.js} +1 -1
- package/dist/{chunk-SKV6FO37.js → chunk-VNT2IRLM.js} +4 -4
- package/dist/{chunk-M4WTELYI.js → chunk-VWNQRD4I.js} +4 -4
- package/dist/{chunk-D5JJQRW7.js → chunk-WF2NXBOM.js} +9 -9
- package/dist/{chunk-5M3KXOPY.js → chunk-X2DX3A7H.js} +2 -2
- package/dist/{chunk-VUSYGNNN.js → chunk-XDRZ3BNA.js} +1 -1
- package/dist/{chunk-DOKFFSOZ.js → chunk-XE2PXGZT.js} +3 -3
- package/dist/{chunk-Y5ZKDLNX.js → chunk-YKWOVYVN.js} +15 -15
- package/dist/{chunk-HI5RBFL3.js → chunk-YWWW47OY.js} +14 -9
- package/dist/{chunk-2JIGPSVF.js → chunk-YXXJBHHF.js} +20 -4
- package/dist/{chunk-KXCTWOPU.js → chunk-YZRDJOOR.js} +3 -3
- package/dist/{chunk-GLJX2CZY.js → chunk-Z4R36YDJ.js} +353 -303
- package/dist/{chunk-GZETHU2Z.js → chunk-ZCEM4GJ5.js} +3 -3
- package/dist/{chunk-VV2VLQWG.js → chunk-ZLJXMXZP.js} +2 -2
- package/dist/{chunk-ZEEQB7VM.js → chunk-ZO3RUMUR.js} +5 -5
- package/dist/{chunk-HOCVTWV2.js → chunk-ZTJTAKVW.js} +1 -1
- package/dist/{claude-launcher-3O5W5ENW.js → claude-launcher-FHQTSQOM.js} +10 -10
- package/dist/{cli-YMSYVF7O.js → cli-GNC4MFMP.js} +173 -159
- package/dist/{command-ZOWMTOWA.js → command-47EYM2FJ.js} +54 -54
- package/dist/{config-J4NNZ2XO.js → config-EA6WVKAS.js} +14 -14
- package/dist/{connect-cmd-GVIUKK3R.js → connect-cmd-4JO2LBUT.js} +15 -15
- package/dist/{container-start-RZSGWDZG.js → container-start-XR7KANS6.js} +58 -53
- package/dist/{context-cleanup-7V2ARBSC.js → context-cleanup-6CTKLEUT.js} +6 -6
- package/dist/{context-show-cmd-73E36KAV.js → context-show-cmd-Z7NQAKNE.js} +16 -16
- package/dist/{control-plane-launch-L744RJ4A.js → control-plane-launch-4PLBJKBS.js} +17 -17
- package/dist/{demo-record-cmd-KGH3WGLY.js → demo-record-cmd-3B2ME2ZI.js} +10 -10
- package/dist/{demo-voice-cmd-CHCS7TQF.js → demo-voice-cmd-LIXAA3OS.js} +24 -24
- package/dist/{dist-U6EGOQD5.js → dist-3TV6G4YF.js} +2 -2
- package/dist/docker-FPEQS6HK.js +20 -0
- package/dist/{doctor-NILQ2RUT.js → doctor-AFH6UUX6.js} +59 -59
- package/dist/emit-artifact-cmd-5XIEUWFX.js +44 -0
- package/dist/{emit-cmd-AG7HL3YI.js → emit-cmd-IKYF27IK.js} +9 -9
- package/dist/emit-criteria-cmd-YS5ZSLCN.js +35 -0
- package/dist/{emit-demo-cmd-GHDL7ZGH.js → emit-demo-cmd-IDC2JC46.js} +24 -24
- package/dist/{emit-finding-cmd-KPHWY6ZU.js → emit-finding-cmd-C4NRTIZO.js} +18 -18
- package/dist/{emit-result-cmd-WOJEHOXH.js → emit-result-cmd-GC2I7JQU.js} +22 -22
- package/dist/{emit-step-cmd-QTNJBTZN.js → emit-step-cmd-TTH4FYFW.js} +18 -18
- package/dist/{exec-client-IPPD3NF4.js → exec-client-DT5EWVQL.js} +10 -10
- package/dist/find-unit-337Y4QAC.js +24 -0
- package/dist/{findings-cmd-LVYAXHQG.js → findings-cmd-MSV52ODM.js} +18 -18
- package/dist/fleet-readiness-O76CSI7M.js +31 -0
- package/dist/governing-source-QEFYVBQF.js +41 -0
- package/dist/guest-init-X7M5AIOI.js +20 -0
- package/dist/{hook-fast-RNST4WJH.js → hook-fast-T6FOTZHA.js} +4 -4
- package/dist/{hook-install-G3FUCXBE.js → hook-install-OUSUHQ6C.js} +6 -6
- package/dist/{hook-wrap-fast-HNY3OGLN.js → hook-wrap-fast-GVS5HF5C.js} +3 -3
- package/dist/host-checks-OXB5J3KR.js +79 -0
- package/dist/host-key-UFUIBFBF.js +18 -0
- package/dist/{image-tag-5Z2NKCHC.js → image-tag-AE6EKDPV.js} +10 -10
- package/dist/index.js +7 -7
- package/dist/{init-7OHFUQBV.js → init-PUN3PKOT.js} +50 -50
- package/dist/init-V7X3KA7B.js +79 -0
- package/dist/{init-agent-B5ADPZIB.js → init-agent-D3KK24QX.js} +51 -51
- package/dist/{init-cmd-ZT2PXGPD.js → init-cmd-LGRN3U7K.js} +32 -32
- package/dist/{init-update-WYM5WSM7.js → init-update-ZL2J7EQI.js} +27 -27
- package/dist/install-cmd-4ID4VBH2.js +21 -0
- package/dist/{layout-RPYMSWCY.js → layout-G6K72TXK.js} +6 -6
- package/dist/{login-browser-AMCRDS5C.js → login-browser-I6CWBA7K.js} +2 -2
- package/dist/{logs-XKEW5EOB.js → logs-DIA3NWC2.js} +9 -9
- package/dist/loop-AWBFKDV7.js +90 -0
- package/dist/machine-BZPKYURG.js +79 -0
- package/dist/{machine-skills-RP2Y5F32.js → machine-skills-JLJJDXBS.js} +6 -6
- package/dist/{mcp-install-cmd-IZYHXHXG.js → mcp-install-cmd-OTAX7QP2.js} +6 -6
- package/dist/{mcp-serve-cmd-HAIJVRR7.js → mcp-serve-cmd-63KQEQYS.js} +11 -11
- package/dist/{paths-6AMRSXZK.js → paths-KVMMJQ7T.js} +9 -9
- package/dist/pending-2IE3VBAN.js +18 -0
- package/dist/pidfile-NCBBWZNH.js +19 -0
- package/dist/record-PQDJVKYV.js +18 -0
- package/dist/{relay-CO5I2WOV.js → relay-QDB526DJ.js} +7 -7
- package/dist/{relay-protocol-S2JGOYZZ.js → relay-protocol-PJ2HOP6B.js} +7 -7
- package/dist/runner-agents-CEW4Z3FR.js +14 -0
- package/dist/runner-env-23OLQBQZ.js +24 -0
- package/dist/runner-identity-IJKE4SRJ.js +20 -0
- package/dist/{runner-key-VCWF2EN7.js → runner-key-4J4MHN3S.js} +50 -50
- package/dist/session-sender-HKNACIH5.js +44 -0
- package/dist/{shell-function-FTY7SSAJ.js → shell-function-RBJR373S.js} +2 -2
- package/dist/{spec-cmd-2WKI4V2T.js → spec-cmd-4R7AYTBU.js} +19 -19
- package/dist/{starter-pack-W6S3L76K.js → starter-pack-6C7HPT4O.js} +7 -7
- package/dist/state-DPEWDXQN.js +18 -0
- package/dist/{status-HHM6TH6J.js → status-GMVC666R.js} +50 -50
- package/dist/{statusline-fast-5G2CTPSX.js → statusline-fast-WUXKRABL.js} +3 -3
- package/dist/{sync-cmd-TIDWKW4E.js → sync-cmd-UMAENSGZ.js} +22 -22
- package/dist/update-steps-GTXNCG3Z.js +80 -0
- package/dist/{watch-IA6UDVSF.js → watch-RAUF223H.js} +22 -22
- package/dist/{work-claim-cmd-7TLC4DKU.js → work-claim-cmd-A3ISXUFA.js} +24 -24
- package/dist/{work-cmd-2LXE27RX.js → work-cmd-U7YLMDZ7.js} +18 -18
- package/dist/work-comment-cmd-CMWMOWVG.js +38 -0
- package/dist/{work-demo-cmd-CSXUA7KH.js → work-demo-cmd-EKTJHIVM.js} +18 -18
- package/dist/{work-logs-cmd-ECF7ZLHO.js → work-logs-cmd-Z3QOFYTJ.js} +18 -18
- package/dist/{work-open-pr-cmd-SUJEYZ6C.js → work-open-pr-cmd-NJXIX3QZ.js} +19 -19
- package/dist/work-pr-cmd-JUV3SN7I.js +34 -0
- package/dist/{work-proofs-cmd-UQU6SSFD.js → work-proofs-cmd-MIDPIFTH.js} +20 -20
- package/dist/{work-proofs-record-MKCYQLS2.js → work-proofs-record-6FTMJDQG.js} +29 -29
- package/dist/{work-stop-cmd-PBC7SJ7M.js → work-stop-cmd-Z7MYNR7R.js} +18 -18
- package/package.json +2 -2
- package/skill-pack/maintained/outerlayer-build/references/evidence.md +5 -2
- package/dist/agent-setup-RXMEQ7PA.js +0 -40
- package/dist/build-ZH5MAZNM.js +0 -24
- package/dist/build-disk-GPCMOIZV.js +0 -21
- package/dist/builder-ZMVXHOEJ.js +0 -20
- package/dist/caller-J7FR4VBJ.js +0 -23
- package/dist/docker-CAMJXBAJ.js +0 -20
- package/dist/emit-artifact-cmd-CGY656UZ.js +0 -44
- package/dist/emit-criteria-cmd-3HYUUSDK.js +0 -35
- package/dist/find-unit-N3OJBFS5.js +0 -24
- package/dist/fleet-readiness-F46LOKJ6.js +0 -31
- package/dist/governing-source-4XYZYZCD.js +0 -41
- package/dist/guest-init-CFJM25V5.js +0 -20
- package/dist/host-checks-PPTMNHRA.js +0 -79
- package/dist/host-key-QUBI74MS.js +0 -18
- package/dist/init-5ERGXSUD.js +0 -79
- package/dist/install-cmd-3NOHEA6E.js +0 -21
- package/dist/loop-HTKTSGBA.js +0 -90
- package/dist/machine-RBYGRRSM.js +0 -79
- package/dist/pending-C4XQUKWA.js +0 -18
- package/dist/pidfile-3BILBCEO.js +0 -19
- package/dist/record-MV6WJGZT.js +0 -18
- package/dist/runner-agents-FQ4FODZN.js +0 -14
- package/dist/runner-env-72OTIZV2.js +0 -24
- package/dist/runner-identity-IVP2GW33.js +0 -20
- package/dist/session-sender-PWYFVWN6.js +0 -44
- package/dist/state-C3FRODOO.js +0 -18
- package/dist/update-steps-WD25IX2R.js +0 -80
- package/dist/work-comment-cmd-ER53OPLH.js +0 -38
- package/dist/work-pr-cmd-FCNFYWUR.js +0 -34
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from 'node:module';
|
|
3
|
-
import { CLAUDE_CODE_HOOKS } from './chunk-
|
|
4
|
-
import { CLAUDE_CODE, NATIVE_AGENTS, LEGACY_AGENT, homeRelative } from './chunk-
|
|
3
|
+
import { CLAUDE_CODE_HOOKS, OPENCODE_CODEC } from './chunk-PLVHIQJN.js';
|
|
4
|
+
import { CLAUDE_CODE, OPENCODE, NATIVE_AGENTS, LEGACY_AGENT, homeRelative } from './chunk-7PZDPISM.js';
|
|
5
5
|
import { MAINTAINED_SKILLS } from './chunk-CDDED64E.js';
|
|
6
6
|
import { resolvePackageVersion } from './chunk-RA3O54FC.js';
|
|
7
7
|
import { homeFromEnv } from './chunk-352DHUTP.js';
|
|
8
|
-
import { forkFor, RAW_MIRROR_SEGMENTS, WarningCollector, WARNING_CODES, isNewerThanSupported, bucketsFromTurns, costOfUsage } from './chunk-
|
|
9
|
-
import { RESERVED_EMIT_NAMES, EVENT_TYPES, isHumanUserTurn, INPUT_BAND_BOUNDARIES, parseAgentSession, SCHEMA_VERSION, ARTIFACT_KINDS, ArtifactCriterionIdSchema, SPEED_MAX_LENGTH } from './chunk-
|
|
8
|
+
import { forkFor, RAW_MIRROR_SEGMENTS, WarningCollector, WARNING_CODES, isNewerThanSupported, bucketsFromTurns, costOfUsage } from './chunk-5R5FEPLH.js';
|
|
9
|
+
import { RESERVED_EMIT_NAMES, EVENT_TYPES, isHumanUserTurn, INPUT_BAND_BOUNDARIES, parseAgentSession, SCHEMA_VERSION, ARTIFACT_KINDS, ArtifactCriterionIdSchema, SPEED_MAX_LENGTH } from './chunk-YXXJBHHF.js';
|
|
10
10
|
import { __commonJS, __require, __toESM } from './chunk-Z5GEFMRW.js';
|
|
11
11
|
import { existsSync, readFileSync, mkdirSync, writeFileSync, readdirSync, rmSync, renameSync, realpathSync, readlinkSync, symlinkSync, copyFileSync, statSync, accessSync, constants, lstatSync } from 'fs';
|
|
12
12
|
import { join as join$1, dirname, sep, basename, relative, delimiter } from 'path';
|
|
@@ -2333,9 +2333,9 @@ var require_stringifyNumber = __commonJS({
|
|
|
2333
2333
|
function stringifyNumber({ format, minFractionDigits, tag, value }) {
|
|
2334
2334
|
if (typeof value === "bigint")
|
|
2335
2335
|
return String(value);
|
|
2336
|
-
const
|
|
2337
|
-
if (!isFinite(
|
|
2338
|
-
return isNaN(
|
|
2336
|
+
const num3 = typeof value === "number" ? value : Number(value);
|
|
2337
|
+
if (!isFinite(num3))
|
|
2338
|
+
return isNaN(num3) ? ".nan" : num3 < 0 ? "-.inf" : ".inf";
|
|
2339
2339
|
let n = Object.is(value, -0) ? "-0" : JSON.stringify(value);
|
|
2340
2340
|
if (!format && minFractionDigits && (!tag || tag === "tag:yaml.org,2002:float") && /^-?\d/.test(n) && !n.includes("e")) {
|
|
2341
2341
|
let i = n.indexOf(".");
|
|
@@ -2374,8 +2374,8 @@ var require_float = __commonJS({
|
|
|
2374
2374
|
test: /^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,
|
|
2375
2375
|
resolve: (str) => parseFloat(str),
|
|
2376
2376
|
stringify(node) {
|
|
2377
|
-
const
|
|
2378
|
-
return isFinite(
|
|
2377
|
+
const num3 = Number(node.value);
|
|
2378
|
+
return isFinite(num3) ? num3.toExponential() : stringifyNumber.stringifyNumber(node);
|
|
2379
2379
|
}
|
|
2380
2380
|
};
|
|
2381
2381
|
var float = {
|
|
@@ -2806,8 +2806,8 @@ var require_float2 = __commonJS({
|
|
|
2806
2806
|
test: /^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,
|
|
2807
2807
|
resolve: (str) => parseFloat(str.replace(/_/g, "")),
|
|
2808
2808
|
stringify(node) {
|
|
2809
|
-
const
|
|
2810
|
-
return isFinite(
|
|
2809
|
+
const num3 = Number(node.value);
|
|
2810
|
+
return isFinite(num3) ? num3.toExponential() : stringifyNumber.stringifyNumber(node);
|
|
2811
2811
|
}
|
|
2812
2812
|
};
|
|
2813
2813
|
var float = {
|
|
@@ -3006,23 +3006,23 @@ var require_timestamp = __commonJS({
|
|
|
3006
3006
|
function parseSexagesimal(str, asBigInt) {
|
|
3007
3007
|
const sign = str[0];
|
|
3008
3008
|
const parts = sign === "-" || sign === "+" ? str.substring(1) : str;
|
|
3009
|
-
const
|
|
3010
|
-
const res = parts.replace(/_/g, "").split(":").reduce((res2, p) => res2 *
|
|
3011
|
-
return sign === "-" ?
|
|
3009
|
+
const num3 = (n) => asBigInt ? BigInt(n) : Number(n);
|
|
3010
|
+
const res = parts.replace(/_/g, "").split(":").reduce((res2, p) => res2 * num3(60) + num3(p), num3(0));
|
|
3011
|
+
return sign === "-" ? num3(-1) * res : res;
|
|
3012
3012
|
}
|
|
3013
3013
|
function stringifySexagesimal(node) {
|
|
3014
3014
|
let { value } = node;
|
|
3015
|
-
let
|
|
3015
|
+
let num3 = (n) => n;
|
|
3016
3016
|
if (typeof value === "bigint")
|
|
3017
|
-
|
|
3017
|
+
num3 = (n) => BigInt(n);
|
|
3018
3018
|
else if (isNaN(value) || !isFinite(value))
|
|
3019
3019
|
return stringifyNumber.stringifyNumber(node);
|
|
3020
3020
|
let sign = "";
|
|
3021
3021
|
if (value < 0) {
|
|
3022
3022
|
sign = "-";
|
|
3023
|
-
value *=
|
|
3023
|
+
value *= num3(-1);
|
|
3024
3024
|
}
|
|
3025
|
-
const _60 =
|
|
3025
|
+
const _60 = num3(60);
|
|
3026
3026
|
const parts = [value % _60];
|
|
3027
3027
|
if (value < 60) {
|
|
3028
3028
|
parts.unshift(0);
|
|
@@ -9507,7 +9507,7 @@ function forkOptions(record, entry) {
|
|
|
9507
9507
|
}
|
|
9508
9508
|
function createClaudeCodeCapture(io) {
|
|
9509
9509
|
const rollup = createSubagentRollup(io);
|
|
9510
|
-
const
|
|
9510
|
+
const parseText2 = (text, options) => parseTranscript(text, { agentType: CLAUDE_CODE.id, ...options }, io.sha256);
|
|
9511
9511
|
return {
|
|
9512
9512
|
discover(roots) {
|
|
9513
9513
|
const liveRoot = roots.root ?? defaultProjectsDir(io);
|
|
@@ -9533,7 +9533,7 @@ function createClaudeCodeCapture(io) {
|
|
|
9533
9533
|
parse(entry, opts) {
|
|
9534
9534
|
const text = io.fs.readRawText(entry.file);
|
|
9535
9535
|
if (text === void 0) throw new Error(`cannot read the transcript ${entry.file}`);
|
|
9536
|
-
const result =
|
|
9536
|
+
const result = parseText2(text, {
|
|
9537
9537
|
fallbackId: sessionIdFromPath(entry.file),
|
|
9538
9538
|
isSubagent: entry.isSubagent,
|
|
9539
9539
|
...entry.parentSessionId ? { parentSessionId: entry.parentSessionId } : {},
|
|
@@ -9550,9 +9550,9 @@ function createClaudeCodeCapture(io) {
|
|
|
9550
9550
|
}
|
|
9551
9551
|
return result;
|
|
9552
9552
|
},
|
|
9553
|
-
parseText,
|
|
9553
|
+
parseText: parseText2,
|
|
9554
9554
|
tail(file, completeText, options) {
|
|
9555
|
-
const { session } =
|
|
9555
|
+
const { session } = parseText2(completeText, { fallbackId: sessionIdFromPath(file), ...options });
|
|
9556
9556
|
return !options.isSubagent && session ? rollup.applySubagentCommitRollup(session, file) : session;
|
|
9557
9557
|
},
|
|
9558
9558
|
identify(file) {
|
|
@@ -9646,20 +9646,20 @@ function filesOf(fs) {
|
|
|
9646
9646
|
return false;
|
|
9647
9647
|
}
|
|
9648
9648
|
};
|
|
9649
|
-
const
|
|
9649
|
+
const filesUnder3 = (dir, base = dir) => {
|
|
9650
9650
|
if (fs.kind(dir) !== "directory") return [];
|
|
9651
9651
|
const out = [];
|
|
9652
9652
|
for (const name of fs.list(dir)) {
|
|
9653
9653
|
const abs = join(dir, name);
|
|
9654
9654
|
const kind = fs.kind(abs);
|
|
9655
|
-
if (kind === "directory") out.push(...
|
|
9655
|
+
if (kind === "directory") out.push(...filesUnder3(abs, base));
|
|
9656
9656
|
else if (kind === "file") out.push(abs.slice(base.length + 1));
|
|
9657
9657
|
}
|
|
9658
9658
|
return out.sort();
|
|
9659
9659
|
};
|
|
9660
9660
|
const readText = (path) => fs.kind(path) === "file" ? fs.readText(path) : void 0;
|
|
9661
9661
|
const isFile = (path) => fs.kind(path) === "file";
|
|
9662
|
-
return { exists: exists2, filesUnder:
|
|
9662
|
+
return { exists: exists2, filesUnder: filesUnder3, readText, isFile };
|
|
9663
9663
|
}
|
|
9664
9664
|
function deliveredSettings(raw, dir) {
|
|
9665
9665
|
if (raw === void 0) return "{}\n";
|
|
@@ -9678,7 +9678,7 @@ function deliveredSettings(raw, dir) {
|
|
|
9678
9678
|
}
|
|
9679
9679
|
function createDelivery(io) {
|
|
9680
9680
|
const { fs } = io;
|
|
9681
|
-
const { exists: exists2, filesUnder:
|
|
9681
|
+
const { exists: exists2, filesUnder: filesUnder3, readText, isFile } = filesOf(fs);
|
|
9682
9682
|
return {
|
|
9683
9683
|
compose({ tree, dir, maintainedSkills }) {
|
|
9684
9684
|
const added = [];
|
|
@@ -9688,7 +9688,7 @@ function createDelivery(io) {
|
|
|
9688
9688
|
added.push(rel);
|
|
9689
9689
|
};
|
|
9690
9690
|
for (const skill of maintainedSkills) {
|
|
9691
|
-
for (const rel of
|
|
9691
|
+
for (const rel of filesUnder3(join(tree, ".outerlayer/skills", skill))) {
|
|
9692
9692
|
const target = `.claude/skills/${skill}/${rel}`;
|
|
9693
9693
|
if (exists2(join(tree, target))) continue;
|
|
9694
9694
|
fs.makeDir(parentOf(join(tree, target)));
|
|
@@ -9700,7 +9700,7 @@ function createDelivery(io) {
|
|
|
9700
9700
|
if (exists2(agentSkills) && fs.kind(agentSkills) === "directory") {
|
|
9701
9701
|
for (const name of fs.list(agentSkills)) {
|
|
9702
9702
|
if (fs.kind(join(agentSkills, name)) !== "directory" || exists2(join(tree, ".claude/skills", name))) continue;
|
|
9703
|
-
for (const rel of
|
|
9703
|
+
for (const rel of filesUnder3(join(agentSkills, name))) {
|
|
9704
9704
|
const target = `.claude/skills/${name}/${rel}`;
|
|
9705
9705
|
fs.makeDir(parentOf(join(tree, target)));
|
|
9706
9706
|
fs.copy(join(agentSkills, name, rel), join(tree, target));
|
|
@@ -9708,7 +9708,7 @@ function createDelivery(io) {
|
|
|
9708
9708
|
}
|
|
9709
9709
|
}
|
|
9710
9710
|
}
|
|
9711
|
-
for (const rel of [...
|
|
9711
|
+
for (const rel of [...filesUnder3(join(tree, ".claude/skills"), tree), ...filesUnder3(join(tree, ".claude/agents"), tree)]) {
|
|
9712
9712
|
const text = readText(join(tree, rel));
|
|
9713
9713
|
if (text === void 0) continue;
|
|
9714
9714
|
const rewritten = rewriteControlPlanePaths(text, dir);
|
|
@@ -10642,9 +10642,722 @@ function createClaudeCodeAdapter(io) {
|
|
|
10642
10642
|
};
|
|
10643
10643
|
}
|
|
10644
10644
|
|
|
10645
|
+
// ../agents/src/opencode/capture.ts
|
|
10646
|
+
var SUBAGENTS = "subagents";
|
|
10647
|
+
var MAX_DEPTH = 4;
|
|
10648
|
+
var SESSION_ID = /^[A-Za-z0-9_-]+$/;
|
|
10649
|
+
var EDIT_TOOLS2 = /* @__PURE__ */ new Set(["edit", "write", "patch", "multiedit"]);
|
|
10650
|
+
var PATH_DELIMITER = ":";
|
|
10651
|
+
var isObject2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
10652
|
+
var num2 = (value) => typeof value === "number" && Number.isFinite(value) && value >= 0 ? Math.round(value) : 0;
|
|
10653
|
+
var isoOf = (ms) => typeof ms === "number" && Number.isFinite(ms) && ms > 0 ? new Date(ms).toISOString() : void 0;
|
|
10654
|
+
function emptyResult(lines = 0) {
|
|
10655
|
+
return { session: null, warnings: {}, stats: { lines, parsed: 0, skipped: lines, unmapped: 0 }, versions: [], blobs: [] };
|
|
10656
|
+
}
|
|
10657
|
+
function toolCallsOf(content) {
|
|
10658
|
+
const calls = [];
|
|
10659
|
+
for (const item of content) {
|
|
10660
|
+
if (!isObject2(item) || item.type !== "tool" || typeof item.name !== "string" || item.name === "") continue;
|
|
10661
|
+
const state = isObject2(item.state) ? item.state : {};
|
|
10662
|
+
const metadata = isObject2(state.metadata) ? state.metadata : {};
|
|
10663
|
+
const exitCode = typeof metadata.exit === "number" ? metadata.exit : void 0;
|
|
10664
|
+
const failed = state.status === "error" || exitCode !== void 0 && exitCode !== 0;
|
|
10665
|
+
const time = isObject2(item.time) ? item.time : {};
|
|
10666
|
+
const startTs = isoOf(time.ran) ?? isoOf(time.created);
|
|
10667
|
+
const durationMs = typeof time.completed === "number" && typeof time.created === "number" && time.completed >= time.created ? Math.round(time.completed - time.created) : void 0;
|
|
10668
|
+
const input = isObject2(state.input) ? state.input : void 0;
|
|
10669
|
+
const file = EDIT_TOOLS2.has(item.name) && input !== void 0 ? [input.path, input.filePath].find((candidate) => typeof candidate === "string") : void 0;
|
|
10670
|
+
const error = isObject2(state.error) ? state.error.message : state.error;
|
|
10671
|
+
const output = Array.isArray(state.content) ? state.content.flatMap((part) => isObject2(part) && typeof part.text === "string" ? [part.text] : []).join("\n") : void 0;
|
|
10672
|
+
calls.push({
|
|
10673
|
+
name: item.name,
|
|
10674
|
+
...startTs === void 0 ? {} : { startTs },
|
|
10675
|
+
...durationMs === void 0 ? {} : { durationMs },
|
|
10676
|
+
status: failed ? "error" : "ok",
|
|
10677
|
+
isEdit: EDIT_TOOLS2.has(item.name),
|
|
10678
|
+
...typeof item.id === "string" ? { toolUseId: item.id } : {},
|
|
10679
|
+
...file === void 0 ? {} : { file },
|
|
10680
|
+
...failed && typeof error === "string" ? { errorSignature: error.split("\n")[0].slice(0, 200) } : {},
|
|
10681
|
+
...input === void 0 ? {} : { input },
|
|
10682
|
+
...output === void 0 || output === "" ? typeof error === "string" ? { output: error } : {} : { output },
|
|
10683
|
+
...exitCode === void 0 ? {} : { exitCode }
|
|
10684
|
+
});
|
|
10685
|
+
}
|
|
10686
|
+
return calls;
|
|
10687
|
+
}
|
|
10688
|
+
function wordsOf(content) {
|
|
10689
|
+
const texts = [];
|
|
10690
|
+
const thinking = [];
|
|
10691
|
+
for (const item of content) {
|
|
10692
|
+
if (!isObject2(item) || typeof item.text !== "string") continue;
|
|
10693
|
+
if (item.type === "text") texts.push(item.text);
|
|
10694
|
+
else if (item.type === "reasoning" || item.type === "thinking") thinking.push(item.text);
|
|
10695
|
+
}
|
|
10696
|
+
return { text: texts.length === 0 ? null : texts.join("\n"), thinking: thinking.length === 0 ? null : thinking.join("\n") };
|
|
10697
|
+
}
|
|
10698
|
+
function sessionOf(exported, options) {
|
|
10699
|
+
const info = isObject2(exported.info) ? exported.info : {};
|
|
10700
|
+
const messages = Array.isArray(exported.messages) ? exported.messages : [];
|
|
10701
|
+
const id = typeof info.id === "string" && info.id !== "" ? info.id : options.fallbackId;
|
|
10702
|
+
if (id === void 0 || id === "") return null;
|
|
10703
|
+
const turns = [];
|
|
10704
|
+
const models = /* @__PURE__ */ new Set();
|
|
10705
|
+
const totals = { in: 0, out: 0, cacheRead: 0, cacheCreate: 0 };
|
|
10706
|
+
let cost = 0;
|
|
10707
|
+
let anyCost = false;
|
|
10708
|
+
for (const message of messages) {
|
|
10709
|
+
if (!isObject2(message)) continue;
|
|
10710
|
+
const created = isObject2(message.time) ? message.time : {};
|
|
10711
|
+
if (message.type === "user") {
|
|
10712
|
+
turns.push({ index: turns.length, role: "user", ...isoOf(created.created) === void 0 ? {} : { ts: isoOf(created.created) }, text: typeof message.text === "string" ? message.text : null, toolCalls: [] });
|
|
10713
|
+
continue;
|
|
10714
|
+
}
|
|
10715
|
+
if (message.type !== "assistant") continue;
|
|
10716
|
+
const model = isObject2(message.model) && typeof message.model.id === "string" ? message.model.id : void 0;
|
|
10717
|
+
const tokens = isObject2(message.tokens) ? message.tokens : {};
|
|
10718
|
+
const cache = isObject2(tokens.cache) ? tokens.cache : {};
|
|
10719
|
+
const usage = { in: num2(tokens.input), out: num2(tokens.output) + num2(tokens.reasoning), cacheRead: num2(cache.read), cacheCreate: num2(cache.write) };
|
|
10720
|
+
const content = Array.isArray(message.content) ? message.content : [];
|
|
10721
|
+
const { text, thinking } = wordsOf(content);
|
|
10722
|
+
const costUsd = model === void 0 ? null : costOfUsage(model, usage);
|
|
10723
|
+
totals.in += usage.in;
|
|
10724
|
+
totals.out += usage.out;
|
|
10725
|
+
totals.cacheRead += usage.cacheRead;
|
|
10726
|
+
totals.cacheCreate += usage.cacheCreate;
|
|
10727
|
+
if (costUsd !== null) {
|
|
10728
|
+
cost += costUsd;
|
|
10729
|
+
anyCost = true;
|
|
10730
|
+
}
|
|
10731
|
+
if (model !== void 0) models.add(model);
|
|
10732
|
+
const duration = typeof created.completed === "number" && typeof created.created === "number" && created.completed >= created.created ? Math.round(created.completed - created.created) : void 0;
|
|
10733
|
+
turns.push({
|
|
10734
|
+
index: turns.length,
|
|
10735
|
+
role: "assistant",
|
|
10736
|
+
...isoOf(created.created) === void 0 ? {} : { ts: isoOf(created.created) },
|
|
10737
|
+
...model === void 0 ? {} : { model },
|
|
10738
|
+
usage,
|
|
10739
|
+
costUsd,
|
|
10740
|
+
...duration === void 0 ? {} : { durationMs: duration },
|
|
10741
|
+
toolCalls: toolCallsOf(content),
|
|
10742
|
+
text,
|
|
10743
|
+
thinking,
|
|
10744
|
+
...typeof message.id === "string" ? { messageId: message.id } : {}
|
|
10745
|
+
});
|
|
10746
|
+
}
|
|
10747
|
+
if (turns.length === 0) return null;
|
|
10748
|
+
const time = isObject2(info.time) ? info.time : {};
|
|
10749
|
+
const lastTurnTs = [...turns].reverse().find((turn) => turn.ts !== void 0)?.ts;
|
|
10750
|
+
const startedAt = isoOf(time.created) ?? turns.find((turn) => turn.ts !== void 0)?.ts ?? (/* @__PURE__ */ new Date(0)).toISOString();
|
|
10751
|
+
const endedAt = isoOf(time.updated) ?? lastTurnTs;
|
|
10752
|
+
const location = isObject2(info.location) ? info.location : {};
|
|
10753
|
+
const parentId = typeof info.parentID === "string" && info.parentID !== "" ? info.parentID : options.parentSessionId;
|
|
10754
|
+
const buckets = bucketsFromTurns(turns);
|
|
10755
|
+
const session = {
|
|
10756
|
+
schemaVersion: SCHEMA_VERSION,
|
|
10757
|
+
id,
|
|
10758
|
+
agent: { type: options.agentType ?? OPENCODE.id },
|
|
10759
|
+
env: { ...typeof location.directory === "string" ? { cwd: location.directory } : {} },
|
|
10760
|
+
...parentId === void 0 ? {} : { subagent: { agentId: id, parentSessionId: parentId, ...typeof info.title === "string" ? { spawnDescription: info.title } : {}, ...typeof info.agent === "string" ? { spawnAgentType: info.agent } : {} } },
|
|
10761
|
+
startedAt,
|
|
10762
|
+
...endedAt === void 0 ? {} : { endedAt },
|
|
10763
|
+
models: [...models].sort(),
|
|
10764
|
+
turns,
|
|
10765
|
+
events: [],
|
|
10766
|
+
totals: {
|
|
10767
|
+
inputTokens: totals.in,
|
|
10768
|
+
outputTokens: totals.out,
|
|
10769
|
+
cacheReadTokens: totals.cacheRead,
|
|
10770
|
+
cacheCreationTokens: totals.cacheCreate,
|
|
10771
|
+
costUsd: anyCost ? Math.round(cost * 1e6) / 1e6 : null,
|
|
10772
|
+
...buckets.length > 0 ? { buckets, bandBoundaries: [...INPUT_BAND_BOUNDARIES] } : {}
|
|
10773
|
+
},
|
|
10774
|
+
...typeof info.title === "string" && info.title !== "" ? { title: info.title } : {},
|
|
10775
|
+
captureTier: options.captureTier ?? "full",
|
|
10776
|
+
warnings: []
|
|
10777
|
+
};
|
|
10778
|
+
return parseAgentSession(session);
|
|
10779
|
+
}
|
|
10780
|
+
function parseText(text, options) {
|
|
10781
|
+
if (text.trim() === "") return emptyResult();
|
|
10782
|
+
let exported;
|
|
10783
|
+
try {
|
|
10784
|
+
exported = JSON.parse(text);
|
|
10785
|
+
} catch {
|
|
10786
|
+
return { ...emptyResult(1), warnings: { "export-not-json": 1 } };
|
|
10787
|
+
}
|
|
10788
|
+
if (!isObject2(exported)) return { ...emptyResult(1), warnings: { "export-not-object": 1 } };
|
|
10789
|
+
const session = sessionOf(exported, options);
|
|
10790
|
+
const lines = Array.isArray(exported.messages) ? exported.messages.length : 0;
|
|
10791
|
+
if (session === null) return emptyResult(lines);
|
|
10792
|
+
return { session, warnings: {}, stats: { lines, parsed: lines, skipped: 0, unmapped: 0 }, versions: [], blobs: [] };
|
|
10793
|
+
}
|
|
10794
|
+
var stemOf = (file) => (file.split(/[/\\]/).pop() ?? file).replace(/\.json$/, "");
|
|
10795
|
+
function childIdsOf(exported) {
|
|
10796
|
+
if (!isObject2(exported) || !Array.isArray(exported.messages)) return [];
|
|
10797
|
+
const ids = [];
|
|
10798
|
+
for (const message of exported.messages) {
|
|
10799
|
+
if (!isObject2(message) || !Array.isArray(message.content)) continue;
|
|
10800
|
+
for (const item of message.content) {
|
|
10801
|
+
if (!isObject2(item) || item.type !== "tool" || item.name !== "subagent" || !isObject2(item.state) || !isObject2(item.state.metadata)) continue;
|
|
10802
|
+
const child = item.state.metadata.sessionID;
|
|
10803
|
+
if (typeof child === "string" && SESSION_ID.test(child)) ids.push(child);
|
|
10804
|
+
}
|
|
10805
|
+
}
|
|
10806
|
+
return [...new Set(ids)];
|
|
10807
|
+
}
|
|
10808
|
+
function createOpenCodeCapture(io, launch) {
|
|
10809
|
+
const folderIn = (home) => io.path.join(home, homeRelative(OPENCODE.capture.sessionFolder));
|
|
10810
|
+
const entryOf = (file, parent) => {
|
|
10811
|
+
const stat = io.fs.stat(file);
|
|
10812
|
+
return { file, mtimeMs: stat.mtimeMs, bytes: stat.size, isSubagent: parent !== void 0, ...parent === void 0 ? {} : { parentSessionId: parent, ownId: stemOf(file) } };
|
|
10813
|
+
};
|
|
10814
|
+
async function runProgram(program, args) {
|
|
10815
|
+
const ran = await io.run(program, args);
|
|
10816
|
+
if (ran.code !== 0) throw new Error(`opencode ${args.slice(0, 2).join(" ")} exited ${ran.code}: ${ran.stderr.trim().split("\n")[0] ?? ""}`.trimEnd());
|
|
10817
|
+
return ran.stdout;
|
|
10818
|
+
}
|
|
10819
|
+
async function exportSession(program, id, dir, depth) {
|
|
10820
|
+
const text = await runProgram(program, ["session", "export", "--standalone", id]);
|
|
10821
|
+
let exported;
|
|
10822
|
+
try {
|
|
10823
|
+
exported = JSON.parse(text);
|
|
10824
|
+
} catch {
|
|
10825
|
+
throw new Error(`opencode session export ${id} printed no JSON`);
|
|
10826
|
+
}
|
|
10827
|
+
if (!isObject2(exported)) throw new Error(`opencode session export ${id} printed no session`);
|
|
10828
|
+
const failures = [];
|
|
10829
|
+
if (depth < MAX_DEPTH) {
|
|
10830
|
+
for (const child of childIdsOf(exported)) {
|
|
10831
|
+
try {
|
|
10832
|
+
await exportSession(program, child, io.path.join(dir, id, SUBAGENTS), depth + 1);
|
|
10833
|
+
} catch (error) {
|
|
10834
|
+
failures.push(error.message);
|
|
10835
|
+
}
|
|
10836
|
+
}
|
|
10837
|
+
}
|
|
10838
|
+
if (failures.length > 0) throw new Error(failures.join("; "));
|
|
10839
|
+
io.fs.makeDir(dir);
|
|
10840
|
+
io.fs.write(io.path.join(dir, `${id}.json`), text);
|
|
10841
|
+
}
|
|
10842
|
+
return {
|
|
10843
|
+
discover() {
|
|
10844
|
+
const found = [];
|
|
10845
|
+
const walk = (folder, parent) => {
|
|
10846
|
+
let names;
|
|
10847
|
+
try {
|
|
10848
|
+
names = io.fs.list(folder);
|
|
10849
|
+
} catch {
|
|
10850
|
+
return;
|
|
10851
|
+
}
|
|
10852
|
+
for (const name of names) {
|
|
10853
|
+
const file = io.path.join(folder, name);
|
|
10854
|
+
if (name.endsWith(".json")) {
|
|
10855
|
+
found.push(entryOf(file, parent));
|
|
10856
|
+
continue;
|
|
10857
|
+
}
|
|
10858
|
+
const children = io.path.join(file, SUBAGENTS);
|
|
10859
|
+
if (io.fs.kind(children) === "directory") walk(children, name);
|
|
10860
|
+
}
|
|
10861
|
+
};
|
|
10862
|
+
walk(folderIn(io.home()), void 0);
|
|
10863
|
+
return found.sort((a, b) => b.mtimeMs - a.mtimeMs);
|
|
10864
|
+
},
|
|
10865
|
+
async collect({ home }) {
|
|
10866
|
+
const program = launch.findProgram(io.env().PATH, PATH_DELIMITER);
|
|
10867
|
+
if (program === void 0) return;
|
|
10868
|
+
const folder = folderIn(home);
|
|
10869
|
+
const listed = JSON.parse(await runProgram(program, ["session", "list", "--standalone", "--format", "json"]));
|
|
10870
|
+
if (!Array.isArray(listed)) throw new Error("opencode session list printed no list");
|
|
10871
|
+
const failures = [];
|
|
10872
|
+
for (const item of listed) {
|
|
10873
|
+
if (!isObject2(item) || typeof item.id !== "string" || !SESSION_ID.test(item.id) || typeof item.updated !== "number") continue;
|
|
10874
|
+
const file = io.path.join(folder, `${item.id}.json`);
|
|
10875
|
+
const stat = io.fs.stat(file);
|
|
10876
|
+
if (stat.kind === "file" && stat.mtimeMs >= item.updated) continue;
|
|
10877
|
+
try {
|
|
10878
|
+
await exportSession(program, item.id, folder, 0);
|
|
10879
|
+
} catch (error) {
|
|
10880
|
+
failures.push(error.message);
|
|
10881
|
+
}
|
|
10882
|
+
}
|
|
10883
|
+
if (failures.length > 0) throw new Error(failures.join("; "));
|
|
10884
|
+
},
|
|
10885
|
+
parse(entry, options) {
|
|
10886
|
+
const text = io.fs.readRawText(entry.file);
|
|
10887
|
+
if (text === void 0) throw new Error(`cannot read the export ${entry.file}`);
|
|
10888
|
+
return parseText(text, {
|
|
10889
|
+
fallbackId: stemOf(entry.file),
|
|
10890
|
+
...entry.isSubagent ? { isSubagent: true } : {},
|
|
10891
|
+
...entry.parentSessionId === void 0 ? {} : { parentSessionId: entry.parentSessionId },
|
|
10892
|
+
...options.captureTier === void 0 ? {} : { captureTier: options.captureTier }
|
|
10893
|
+
});
|
|
10894
|
+
},
|
|
10895
|
+
parseText,
|
|
10896
|
+
tail(file, completeText, options) {
|
|
10897
|
+
return parseText(completeText, { fallbackId: stemOf(file), ...options }).session;
|
|
10898
|
+
},
|
|
10899
|
+
sessionFiles: ({ home, sessionId }) => ({ dir: folderIn(home), entries: [`${sessionId}.json`] }),
|
|
10900
|
+
identify(file) {
|
|
10901
|
+
const sessionId = stemOf(file);
|
|
10902
|
+
const segments = file.split(/[/\\]/);
|
|
10903
|
+
const at = segments.lastIndexOf(SUBAGENTS);
|
|
10904
|
+
if (at < 1) return { sessionId, isSubagent: false };
|
|
10905
|
+
return { sessionId, isSubagent: true, parentSessionId: segments[at - 1], ownId: sessionId };
|
|
10906
|
+
}
|
|
10907
|
+
};
|
|
10908
|
+
}
|
|
10909
|
+
|
|
10910
|
+
// ../agents/src/opencode/credentials.ts
|
|
10911
|
+
var { forwarded: forwarded2, kinds: kinds2, placeholders: placeholders2 } = OPENCODE.credentials;
|
|
10912
|
+
var FORWARDED2 = forwarded2;
|
|
10913
|
+
var KINDS2 = kinds2;
|
|
10914
|
+
var BASE_URL_VARIABLE2 = "ANTHROPIC_BASE_URL";
|
|
10915
|
+
var MODELS_FETCH_VARIABLE = "OPENCODE_DISABLE_MODELS_FETCH";
|
|
10916
|
+
function createOpenCodeCredentials() {
|
|
10917
|
+
return {
|
|
10918
|
+
classify(env) {
|
|
10919
|
+
for (const variable of FORWARDED2) {
|
|
10920
|
+
const value = env[variable];
|
|
10921
|
+
if (value === void 0 || value === "") continue;
|
|
10922
|
+
const kind = KINDS2[variable];
|
|
10923
|
+
return { variable, provider: kind.provider, kind: kind.providerKind };
|
|
10924
|
+
}
|
|
10925
|
+
return void 0;
|
|
10926
|
+
},
|
|
10927
|
+
identify(value) {
|
|
10928
|
+
return FORWARDED2.find((variable) => new RegExp(KINDS2[variable].pattern).test(value));
|
|
10929
|
+
},
|
|
10930
|
+
buildEnvironment({ providerUrl, variable }) {
|
|
10931
|
+
const placeholder = placeholders2[variable ?? ""];
|
|
10932
|
+
return {
|
|
10933
|
+
[BASE_URL_VARIABLE2]: providerUrl(OPENCODE.providers[0]),
|
|
10934
|
+
...placeholder === void 0 ? {} : { [variable]: placeholder },
|
|
10935
|
+
[MODELS_FETCH_VARIABLE]: "1"
|
|
10936
|
+
};
|
|
10937
|
+
}
|
|
10938
|
+
};
|
|
10939
|
+
}
|
|
10940
|
+
|
|
10941
|
+
// ../agents/src/opencode/config.ts
|
|
10942
|
+
var PLUGIN_PATH = "./plugins/outerlayer";
|
|
10943
|
+
function providerBlock(keyVariable = "ANTHROPIC_API_KEY") {
|
|
10944
|
+
return { anthropic: { options: { baseURL: "{env:ANTHROPIC_BASE_URL}/v1", apiKey: `{env:${keyVariable}}` } } };
|
|
10945
|
+
}
|
|
10946
|
+
function openCodeConfigText() {
|
|
10947
|
+
const config = {
|
|
10948
|
+
$schema: "https://opencode.ai/config.json",
|
|
10949
|
+
provider: providerBlock(),
|
|
10950
|
+
enabled_providers: ["anthropic"],
|
|
10951
|
+
autoupdate: false,
|
|
10952
|
+
share: "disabled",
|
|
10953
|
+
plugin: [PLUGIN_PATH],
|
|
10954
|
+
mcp: {}
|
|
10955
|
+
};
|
|
10956
|
+
return `${JSON.stringify(config, null, 2)}
|
|
10957
|
+
`;
|
|
10958
|
+
}
|
|
10959
|
+
|
|
10960
|
+
// ../agents/src/opencode/plugin.ts
|
|
10961
|
+
var PLUGIN_PACKAGE_JSON = `${JSON.stringify({ name: "outerlayer", version: "0.0.0", type: "module", main: "index.js" }, null, 2)}
|
|
10962
|
+
`;
|
|
10963
|
+
function pluginSource(events) {
|
|
10964
|
+
return `const EVENTS = new Set(${JSON.stringify(events)});
|
|
10965
|
+
const noop = () => {};
|
|
10966
|
+
|
|
10967
|
+
function forward(spawn, event) {
|
|
10968
|
+
try {
|
|
10969
|
+
const child = spawn("outerlayer", ["hook", "--agent", "opencode", event.type], { stdio: ["pipe", "ignore", "ignore"], detached: true });
|
|
10970
|
+
child.on("error", noop);
|
|
10971
|
+
child.stdin.on("error", noop);
|
|
10972
|
+
child.stdin.end(JSON.stringify(event));
|
|
10973
|
+
child.unref();
|
|
10974
|
+
} catch {
|
|
10975
|
+
// A hook call that cannot start is dropped. The session goes on.
|
|
10976
|
+
}
|
|
10977
|
+
}
|
|
10978
|
+
|
|
10979
|
+
async function watch(spawn, stream) {
|
|
10980
|
+
for await (const event of stream) {
|
|
10981
|
+
if (event && typeof event.type === "string" && EVENTS.has(event.type)) forward(spawn, event);
|
|
10982
|
+
}
|
|
10983
|
+
}
|
|
10984
|
+
|
|
10985
|
+
export default {
|
|
10986
|
+
id: "outerlayer",
|
|
10987
|
+
setup(ctx) {
|
|
10988
|
+
try {
|
|
10989
|
+
const { spawn } = process.getBuiltinModule("child_process");
|
|
10990
|
+
watch(spawn, ctx.event.subscribe()).catch(noop);
|
|
10991
|
+
} catch {
|
|
10992
|
+
// A context without an event stream has nothing to forward.
|
|
10993
|
+
}
|
|
10994
|
+
},
|
|
10995
|
+
};
|
|
10996
|
+
`;
|
|
10997
|
+
}
|
|
10998
|
+
|
|
10999
|
+
// ../agents/src/opencode/delivery.ts
|
|
11000
|
+
var SKILL_SOURCES = [".outerlayer/skills", ".agents/skills", ".claude/skills"];
|
|
11001
|
+
function join2(base, ...parts) {
|
|
11002
|
+
return parts.reduce((path, part) => path === "" || path.endsWith("/") ? `${path}${part}` : `${path}/${part}`, base);
|
|
11003
|
+
}
|
|
11004
|
+
function parentOf2(path) {
|
|
11005
|
+
const cut = path.lastIndexOf("/");
|
|
11006
|
+
return cut <= 0 ? path.slice(0, cut + 1) : path.slice(0, cut);
|
|
11007
|
+
}
|
|
11008
|
+
function filesUnder(fs, dir, base = dir) {
|
|
11009
|
+
if (fs.kind(dir) !== "directory") return [];
|
|
11010
|
+
const out = [];
|
|
11011
|
+
for (const name of fs.list(dir)) {
|
|
11012
|
+
const abs = join2(dir, name);
|
|
11013
|
+
const kind = fs.kind(abs);
|
|
11014
|
+
if (kind === "directory") out.push(...filesUnder(fs, abs, base));
|
|
11015
|
+
else if (kind === "file") out.push(abs.slice(base.length + 1));
|
|
11016
|
+
}
|
|
11017
|
+
return out.sort();
|
|
11018
|
+
}
|
|
11019
|
+
function deliverySection2(dir) {
|
|
11020
|
+
return `This repository's control plane is not in the checkout. Its files are in \`${dir}\`. When the instructions name a file under \`.agents/\` that this directory holds, or a path under \`.outerlayer/\` or \`.claude/\`, read it under \`${dir}\`.`;
|
|
11021
|
+
}
|
|
11022
|
+
function escapesDelivery(pluginPath, controlPlaneVariable) {
|
|
11023
|
+
const inside = pluginPath.replace(new RegExp(`^\\$(?:\\{${controlPlaneVariable}\\}|${controlPlaneVariable})/`), "./");
|
|
11024
|
+
if (!inside.startsWith("./")) return true;
|
|
11025
|
+
if (/[{}%:\\]/.test(inside)) return true;
|
|
11026
|
+
return inside.split("/").includes("..");
|
|
11027
|
+
}
|
|
11028
|
+
function writeRuntimeFiles(io, dir) {
|
|
11029
|
+
const written = [];
|
|
11030
|
+
const put = (rel, content) => {
|
|
11031
|
+
io.fs.makeDir(parentOf2(join2(dir, rel)));
|
|
11032
|
+
io.fs.write(join2(dir, rel), content);
|
|
11033
|
+
written.push(rel);
|
|
11034
|
+
};
|
|
11035
|
+
put("plugins/outerlayer/package.json", PLUGIN_PACKAGE_JSON);
|
|
11036
|
+
put("plugins/outerlayer/index.js", pluginSource(OPENCODE_CODEC.events));
|
|
11037
|
+
put("opencode.json", openCodeConfigText());
|
|
11038
|
+
return written;
|
|
11039
|
+
}
|
|
11040
|
+
function createDelivery2(io) {
|
|
11041
|
+
const { fs } = io;
|
|
11042
|
+
return {
|
|
11043
|
+
compose({ tree, dir }) {
|
|
11044
|
+
const added = [];
|
|
11045
|
+
const put = (rel, content) => {
|
|
11046
|
+
fs.makeDir(parentOf2(join2(tree, rel)));
|
|
11047
|
+
fs.write(join2(tree, rel), content);
|
|
11048
|
+
added.push(rel);
|
|
11049
|
+
};
|
|
11050
|
+
const delivered = /* @__PURE__ */ new Set();
|
|
11051
|
+
for (const source of SKILL_SOURCES) {
|
|
11052
|
+
const root = join2(tree, source);
|
|
11053
|
+
if (fs.kind(root) !== "directory") continue;
|
|
11054
|
+
for (const name of fs.list(root)) {
|
|
11055
|
+
if (delivered.has(name) || fs.kind(join2(root, name)) !== "directory") continue;
|
|
11056
|
+
delivered.add(name);
|
|
11057
|
+
for (const rel of filesUnder(fs, join2(root, name))) {
|
|
11058
|
+
const target = `skills/${name}/${rel}`;
|
|
11059
|
+
fs.makeDir(parentOf2(join2(tree, target)));
|
|
11060
|
+
fs.copy(join2(root, name, rel), join2(tree, target));
|
|
11061
|
+
added.push(target);
|
|
11062
|
+
}
|
|
11063
|
+
}
|
|
11064
|
+
}
|
|
11065
|
+
for (const rel of filesUnder(fs, join2(tree, "skills"), tree)) {
|
|
11066
|
+
const text = fs.readText(join2(tree, rel));
|
|
11067
|
+
if (text === void 0) continue;
|
|
11068
|
+
const rewritten = rewriteControlPlanePaths(text, dir);
|
|
11069
|
+
if (rewritten !== text) fs.write(join2(tree, rel), rewritten);
|
|
11070
|
+
}
|
|
11071
|
+
const agents = fs.kind(join2(tree, "AGENTS.md")) === "file" ? fs.readText(join2(tree, "AGENTS.md")) : void 0;
|
|
11072
|
+
const instructions = agents === void 0 ? void 0 : rewriteAgentsFilePaths(rewriteControlPlanePaths(agents, dir), dir, (path) => fs.kind(join2(tree, path)) === "file");
|
|
11073
|
+
put("AGENTS.md", instructions === void 0 ? `${deliverySection2(dir)}
|
|
11074
|
+
` : `${deliverySection2(dir)}
|
|
11075
|
+
|
|
11076
|
+
${instructions}`);
|
|
11077
|
+
added.push(...writeRuntimeFiles(io, tree));
|
|
11078
|
+
return added;
|
|
11079
|
+
},
|
|
11080
|
+
deliveredSkills(tree) {
|
|
11081
|
+
const dir = join2(tree, "skills");
|
|
11082
|
+
if (fs.kind(dir) !== "directory") return [];
|
|
11083
|
+
return fs.list(dir).filter((name) => fs.kind(join2(dir, name)) === "directory").sort();
|
|
11084
|
+
},
|
|
11085
|
+
escapesDelivery
|
|
11086
|
+
};
|
|
11087
|
+
}
|
|
11088
|
+
|
|
11089
|
+
// ../agents/src/opencode/emit.ts
|
|
11090
|
+
function buildOpenCode(input) {
|
|
11091
|
+
const files = [];
|
|
11092
|
+
const copies = [];
|
|
11093
|
+
const warnings = [];
|
|
11094
|
+
for (const entry of input.entries) {
|
|
11095
|
+
const target = entry.kind === "instructions" ? joinPath(entry.scopePath, "AGENTS.md") : entry.kind === "skill" ? joinPath(entry.scopePath, ".agents/skills", entry.skillName, "SKILL.md") : entry.kind === "skill-reference" ? joinPath(entry.scopePath, ".agents/skills", entry.skillName, "references", skillReferenceRelPath(entry)) : void 0;
|
|
11096
|
+
if (target === void 0) continue;
|
|
11097
|
+
const content = contentForEntry(input.contents, entry, warnings);
|
|
11098
|
+
if (content !== void 0) files.push({ path: target, content: withHeader(entry.path, content) });
|
|
11099
|
+
}
|
|
11100
|
+
for (const assetPath of input.assetPaths) {
|
|
11101
|
+
const parsed = parseSkillAssetPath(assetPath);
|
|
11102
|
+
if (parsed) copies.push({ toPath: joinPath(parsed.scopePath, ".agents/skills", parsed.skillName, parsed.relPath), fromSourcePath: assetPath });
|
|
11103
|
+
}
|
|
11104
|
+
return { files, copies, warnings };
|
|
11105
|
+
}
|
|
11106
|
+
|
|
11107
|
+
// ../agents/src/opencode/image.ts
|
|
11108
|
+
var PREFIX2 = "/opt/outerlayer/opencode";
|
|
11109
|
+
var PACKAGE2 = "@opencode/cli";
|
|
11110
|
+
function createOpenCodeImage() {
|
|
11111
|
+
return {
|
|
11112
|
+
install: (version) => [
|
|
11113
|
+
// The package lists a binary per CPU and C library as optional dependencies, and npm fetches every one of them: about 1 GB, which a build limited to 1 GB of memory cannot write.
|
|
11114
|
+
// So npm installs only the launcher. Its install script then fetches the one binary that fits the machine, and checks that it runs. OpenCode skips its model-list download for that check.
|
|
11115
|
+
`RUN npm install --no-audit --no-fund --omit=optional --ignore-scripts --prefix /out${PREFIX2}/lib ${PACKAGE2}@${version} \\`,
|
|
11116
|
+
` && OPENCODE_DISABLE_MODELS_FETCH=1 node /out${PREFIX2}/lib/node_modules/${PACKAGE2}/postinstall.mjs \\`,
|
|
11117
|
+
` && mkdir -p /out${PREFIX2}/bin \\`,
|
|
11118
|
+
` && ln -s ../lib/node_modules/${PACKAGE2}/bin/opencode.exe /out${PREFIX2}/bin/opencode`
|
|
11119
|
+
],
|
|
11120
|
+
program: `${PREFIX2}/bin/opencode`,
|
|
11121
|
+
command: OPENCODE.program,
|
|
11122
|
+
files: [],
|
|
11123
|
+
// The model list comes from the runner's key proxy. Any OpenCode process in the image, a session export included, would otherwise ask a hosted service for it.
|
|
11124
|
+
env: { OPENCODE_DISABLE_MODELS_FETCH: "1" },
|
|
11125
|
+
versionKey: "opencodeVersion",
|
|
11126
|
+
latestUrl: `https://registry.npmjs.org/${PACKAGE2}/latest`
|
|
11127
|
+
};
|
|
11128
|
+
}
|
|
11129
|
+
|
|
11130
|
+
// ../agents/src/opencode/headless.ts
|
|
11131
|
+
var JUDGE_AGENT = "outerlayer-judge";
|
|
11132
|
+
var JUDGE_TOOLS_OFF = ["shell", "write", "webfetch", "websearch", "execute", "subagent", "question", "opencode_*"];
|
|
11133
|
+
var STEP_LIMIT_ERROR = "maximum agent steps";
|
|
11134
|
+
function ruleFor(dir, file) {
|
|
11135
|
+
const prefix = dir.endsWith("/") ? dir : `${dir}/`;
|
|
11136
|
+
return file.startsWith(prefix) ? file.slice(prefix.length) : file;
|
|
11137
|
+
}
|
|
11138
|
+
function judgeOf(io) {
|
|
11139
|
+
return (input) => {
|
|
11140
|
+
const configDir2 = io.path.join(input.home, "opencode-config");
|
|
11141
|
+
const variable = input.credential?.variable ?? "ANTHROPIC_API_KEY";
|
|
11142
|
+
const config = {
|
|
11143
|
+
$schema: "https://opencode.ai/config.json",
|
|
11144
|
+
provider: providerBlock(variable),
|
|
11145
|
+
enabled_providers: ["anthropic"],
|
|
11146
|
+
autoupdate: false,
|
|
11147
|
+
share: "disabled",
|
|
11148
|
+
agent: {
|
|
11149
|
+
[JUDGE_AGENT]: {
|
|
11150
|
+
mode: "primary",
|
|
11151
|
+
steps: input.maxTurns,
|
|
11152
|
+
tools: Object.fromEntries(JUDGE_TOOLS_OFF.map((tool) => [tool, false])),
|
|
11153
|
+
permission: {
|
|
11154
|
+
edit: { "*": "deny", ...Object.fromEntries(input.writable.map((file) => [ruleFor(input.dir, file), "allow"])) },
|
|
11155
|
+
external_directory: "deny"
|
|
11156
|
+
}
|
|
11157
|
+
}
|
|
11158
|
+
}
|
|
11159
|
+
};
|
|
11160
|
+
io.fs.makeDir(configDir2);
|
|
11161
|
+
io.fs.write(io.path.join(configDir2, "opencode.json"), `${JSON.stringify(config, null, 2)}
|
|
11162
|
+
`);
|
|
11163
|
+
const env = {
|
|
11164
|
+
HOME: input.home,
|
|
11165
|
+
TMPDIR: `${input.home}/tmp`,
|
|
11166
|
+
PATH: input.path,
|
|
11167
|
+
ANTHROPIC_BASE_URL: input.providerUrl("anthropic"),
|
|
11168
|
+
OPENCODE_CONFIG_DIR: configDir2,
|
|
11169
|
+
OPENCODE_DISABLE_MODELS_FETCH: "1",
|
|
11170
|
+
...input.credential === void 0 ? {} : { [input.credential.variable]: input.credential.placeholder }
|
|
11171
|
+
};
|
|
11172
|
+
const args = ["run", "--format", "json", "--agent", JUDGE_AGENT, "--standalone", input.brief];
|
|
11173
|
+
return { program: createOpenCodeImage().program, args, env, driver: "exec", exitFrom: "code" };
|
|
11174
|
+
};
|
|
11175
|
+
}
|
|
11176
|
+
var isObject3 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
11177
|
+
function readJudgeOutput2(stdout) {
|
|
11178
|
+
let sawEvent = false;
|
|
11179
|
+
let stepLimit = false;
|
|
11180
|
+
let lastFinish;
|
|
11181
|
+
let lastText;
|
|
11182
|
+
for (const line of stdout.split("\n")) {
|
|
11183
|
+
if (line.trim() === "") continue;
|
|
11184
|
+
let event;
|
|
11185
|
+
try {
|
|
11186
|
+
event = JSON.parse(line);
|
|
11187
|
+
} catch {
|
|
11188
|
+
continue;
|
|
11189
|
+
}
|
|
11190
|
+
if (!isObject3(event) || typeof event.type !== "string" || typeof event.sessionID !== "string") continue;
|
|
11191
|
+
sawEvent = true;
|
|
11192
|
+
const part = isObject3(event.part) ? event.part : {};
|
|
11193
|
+
const state = isObject3(part.state) ? part.state : {};
|
|
11194
|
+
if (part.type === "text" && typeof part.text === "string") {
|
|
11195
|
+
lastText = part.text;
|
|
11196
|
+
lastFinish = void 0;
|
|
11197
|
+
} else if (part.type === "step-finish") lastFinish = part.reason;
|
|
11198
|
+
else if (part.type === "tool" && state.status === "error" && typeof state.error === "string" && state.error.includes(STEP_LIMIT_ERROR)) stepLimit = true;
|
|
11199
|
+
}
|
|
11200
|
+
if (!sawEvent) return void 0;
|
|
11201
|
+
if (stepLimit || lastFinish === "tool-calls") return { kind: "turn-limit" };
|
|
11202
|
+
return { kind: "text", text: lastText ?? "" };
|
|
11203
|
+
}
|
|
11204
|
+
function createOpenCodeHeadless(io) {
|
|
11205
|
+
return {
|
|
11206
|
+
commandLine: (prompt) => `${OPENCODE.program} run --auto "${prompt}"`,
|
|
11207
|
+
promptFlags: ["run"],
|
|
11208
|
+
judge: judgeOf(io),
|
|
11209
|
+
readJudgeOutput: readJudgeOutput2
|
|
11210
|
+
};
|
|
11211
|
+
}
|
|
11212
|
+
|
|
11213
|
+
// ../agents/src/opencode/launch.ts
|
|
11214
|
+
var SHIM_MAX_BYTES = 256;
|
|
11215
|
+
var SHIM = /^#!\/bin\/sh\nexec outerlayer [^\n]*"\$@"\n$/;
|
|
11216
|
+
var joinPath4 = (...parts) => parts.join("/").replace(/\/{2,}/g, "/");
|
|
11217
|
+
function isSkipped2(io, candidate) {
|
|
11218
|
+
try {
|
|
11219
|
+
const { size } = io.fs.stat(candidate);
|
|
11220
|
+
return size <= SHIM_MAX_BYTES && SHIM.test(io.fs.readText(candidate) ?? "");
|
|
11221
|
+
} catch {
|
|
11222
|
+
return true;
|
|
11223
|
+
}
|
|
11224
|
+
}
|
|
11225
|
+
function findProgram2(io, path, delimiter2) {
|
|
11226
|
+
for (const entry of (path ?? "").split(delimiter2)) {
|
|
11227
|
+
if (entry === "") continue;
|
|
11228
|
+
const candidate = joinPath4(entry, OPENCODE.program);
|
|
11229
|
+
if (!io.fs.executable(candidate)) continue;
|
|
11230
|
+
if (isSkipped2(io, candidate)) continue;
|
|
11231
|
+
return candidate;
|
|
11232
|
+
}
|
|
11233
|
+
return void 0;
|
|
11234
|
+
}
|
|
11235
|
+
var REPOSITORY_SKILL_FOLDERS = [".outerlayer/skills", ".agents/skills", ".claude/skills"];
|
|
11236
|
+
var GOVERNANCE_VARIABLE = "OUTERLAYER_GOVERNANCE";
|
|
11237
|
+
var SELF_CONFIG = ".outerlayer/opencode-config";
|
|
11238
|
+
var SKILL_MESSAGE = "Follow the attached skill.";
|
|
11239
|
+
var VALUE_OPTIONS = /* @__PURE__ */ new Set(["--session", "-s", "--model", "-m", "--agent", "--format", "--file", "-f", "--title", "--log-level", "--server"]);
|
|
11240
|
+
function withSkillAttached(io, args, plane, cwd) {
|
|
11241
|
+
if (args[0] !== "run" || args.length < 2) return [...args];
|
|
11242
|
+
const last = args[args.length - 1];
|
|
11243
|
+
const before = args[args.length - 2];
|
|
11244
|
+
const name = /^\/([A-Za-z0-9][A-Za-z0-9._-]*)$/.exec(last)?.[1];
|
|
11245
|
+
if (name === void 0 || VALUE_OPTIONS.has(before)) return [...args];
|
|
11246
|
+
const candidates = plane === void 0 ? REPOSITORY_SKILL_FOLDERS.map((folder) => joinPath4(cwd, folder, name, "SKILL.md")) : [joinPath4(plane, "skills", name, "SKILL.md")];
|
|
11247
|
+
const skill = candidates.find((candidate) => io.fs.kind(candidate) === "file");
|
|
11248
|
+
if (skill === void 0) return [...args];
|
|
11249
|
+
return [...args.slice(0, -1), "--file", skill, SKILL_MESSAGE];
|
|
11250
|
+
}
|
|
11251
|
+
function interactive2(io, input) {
|
|
11252
|
+
const plane = input.controlPlane;
|
|
11253
|
+
let env = plane === void 0 ? input.env : { ...input.env, OPENCODE_CONFIG_DIR: plane, OPENCODE_DISABLE_MODELS_FETCH: "1" };
|
|
11254
|
+
if (plane === void 0 && input.env[GOVERNANCE_VARIABLE] === "self") {
|
|
11255
|
+
const folder = joinPath4(io.home(), SELF_CONFIG);
|
|
11256
|
+
writeRuntimeFiles(io, folder);
|
|
11257
|
+
env = { ...input.env, OPENCODE_CONFIG_DIR: folder, OPENCODE_DISABLE_MODELS_FETCH: "1" };
|
|
11258
|
+
}
|
|
11259
|
+
return {
|
|
11260
|
+
program: input.program,
|
|
11261
|
+
args: withSkillAttached(io, input.callerArgs, plane, input.cwd),
|
|
11262
|
+
env: Object.fromEntries(Object.entries(env).filter((entry) => entry[1] !== void 0)),
|
|
11263
|
+
driver: "exec",
|
|
11264
|
+
exitFrom: "code"
|
|
11265
|
+
};
|
|
11266
|
+
}
|
|
11267
|
+
function createLaunch2(io) {
|
|
11268
|
+
return {
|
|
11269
|
+
findProgram: (path, delimiter2 = ":") => findProgram2(io, path, delimiter2),
|
|
11270
|
+
version: (program, env) => io.runSync(program, ["--version"], { env, timeoutMs: 15e3 }).stdout,
|
|
11271
|
+
interactive: (input) => interactive2(io, input)
|
|
11272
|
+
};
|
|
11273
|
+
}
|
|
11274
|
+
|
|
11275
|
+
// ../agents/src/opencode/mcp.ts
|
|
11276
|
+
function documentOf2(text) {
|
|
11277
|
+
if (text === void 0) return {};
|
|
11278
|
+
let doc;
|
|
11279
|
+
try {
|
|
11280
|
+
doc = JSON.parse(text);
|
|
11281
|
+
} catch {
|
|
11282
|
+
throw new McpFileError("not-json");
|
|
11283
|
+
}
|
|
11284
|
+
if (!isObject4(doc)) throw new McpFileError("not-object");
|
|
11285
|
+
return doc;
|
|
11286
|
+
}
|
|
11287
|
+
function isObject4(value) {
|
|
11288
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
11289
|
+
}
|
|
11290
|
+
function openCodeEntry(entry) {
|
|
11291
|
+
if (entry.type === "stdio" && typeof entry.command === "string") {
|
|
11292
|
+
const args = Array.isArray(entry.args) ? entry.args.filter((arg) => typeof arg === "string") : [];
|
|
11293
|
+
return { type: "local", command: [entry.command, ...args], ...isObject4(entry.env) ? { environment: entry.env } : {} };
|
|
11294
|
+
}
|
|
11295
|
+
if ((entry.type === "http" || entry.type === "sse") && typeof entry.url === "string") {
|
|
11296
|
+
return { type: "remote", url: entry.url, ...isObject4(entry.headers) ? { headers: entry.headers } : {} };
|
|
11297
|
+
}
|
|
11298
|
+
return entry;
|
|
11299
|
+
}
|
|
11300
|
+
var OPENCODE_MCP = {
|
|
11301
|
+
file: "opencode.json",
|
|
11302
|
+
servers(text) {
|
|
11303
|
+
let doc;
|
|
11304
|
+
try {
|
|
11305
|
+
doc = JSON.parse(text);
|
|
11306
|
+
} catch {
|
|
11307
|
+
return void 0;
|
|
11308
|
+
}
|
|
11309
|
+
if (doc === null) return void 0;
|
|
11310
|
+
const mcp = doc.mcp;
|
|
11311
|
+
const servers = isObject4(mcp) ? mcp.servers : void 0;
|
|
11312
|
+
return isObject4(servers) ? servers : {};
|
|
11313
|
+
},
|
|
11314
|
+
setServer(text, name, entry, mode) {
|
|
11315
|
+
const doc = documentOf2(text);
|
|
11316
|
+
const mcp = doc.mcp;
|
|
11317
|
+
if (mode === "if-absent" && mcp !== void 0 && !isObject4(mcp)) throw new McpFileError("servers-not-object");
|
|
11318
|
+
const section = isObject4(mcp) ? mcp : {};
|
|
11319
|
+
const servers = section.servers;
|
|
11320
|
+
if (mode === "if-absent") {
|
|
11321
|
+
if (servers !== void 0 && !isObject4(servers)) throw new McpFileError("servers-not-object");
|
|
11322
|
+
if (isObject4(servers) && name in servers) return { text: text ?? "", changed: false };
|
|
11323
|
+
}
|
|
11324
|
+
const existing = isObject4(servers) ? servers : {};
|
|
11325
|
+
const written = openCodeEntry(entry);
|
|
11326
|
+
const changed = JSON.stringify(existing[name] ?? null) !== JSON.stringify(written);
|
|
11327
|
+
return { text: `${JSON.stringify({ ...doc, mcp: { ...section, servers: { ...existing, [name]: written } } }, null, 2)}
|
|
11328
|
+
`, changed };
|
|
11329
|
+
}
|
|
11330
|
+
};
|
|
11331
|
+
|
|
11332
|
+
// ../agents/src/opencode/adapter.ts
|
|
11333
|
+
function createOpenCodeAdapter(io) {
|
|
11334
|
+
const context = {
|
|
11335
|
+
emit: buildOpenCode,
|
|
11336
|
+
...createDelivery2(io),
|
|
11337
|
+
deliveredEntries: ["AGENTS.md", "skills", "plugins", "opencode.json"],
|
|
11338
|
+
mcp: OPENCODE_MCP
|
|
11339
|
+
};
|
|
11340
|
+
const launch = createLaunch2(io);
|
|
11341
|
+
return {
|
|
11342
|
+
context,
|
|
11343
|
+
launch,
|
|
11344
|
+
headless: createOpenCodeHeadless(io),
|
|
11345
|
+
lifecycle: {
|
|
11346
|
+
source: { kind: "hook-process", codec: OPENCODE_CODEC },
|
|
11347
|
+
// OpenCode's shell tool sets OPENCODE=1 for the processes it starts.
|
|
11348
|
+
detectInSession: (env) => env.OPENCODE === "1"
|
|
11349
|
+
},
|
|
11350
|
+
deliver: { kind: "none" },
|
|
11351
|
+
capture: createOpenCodeCapture(io, launch),
|
|
11352
|
+
credentials: createOpenCodeCredentials(),
|
|
11353
|
+
image: createOpenCodeImage()
|
|
11354
|
+
};
|
|
11355
|
+
}
|
|
11356
|
+
|
|
10645
11357
|
// ../agents/src/native/factories.ts
|
|
10646
11358
|
var ADAPTER_FACTORIES = {
|
|
10647
|
-
"claude-code": createClaudeCodeAdapter
|
|
11359
|
+
"claude-code": createClaudeCodeAdapter,
|
|
11360
|
+
opencode: createOpenCodeAdapter
|
|
10648
11361
|
};
|
|
10649
11362
|
|
|
10650
11363
|
// ../agents/src/claude-code/conformance-fixtures.ts
|
|
@@ -10677,6 +11390,175 @@ var PATHS = [".outerlayer/AGENTS.md", ".outerlayer/skills/build/SKILL.md", ".out
|
|
|
10677
11390
|
[`${TREE_ROOT}/.claude/settings.json`]: `${JSON.stringify({ hooks: { SessionStart: [{ hooks: [{ type: "command", command: '"$CLAUDE_PROJECT_DIR"/.claude/hooks/start.sh' }] }] } })}
|
|
10678
11391
|
`}}
|
|
10679
11392
|
});
|
|
11393
|
+
|
|
11394
|
+
// ../agents/src/opencode/fixtures/session-export.ts
|
|
11395
|
+
var SESSION_EXPORT = {
|
|
11396
|
+
"info": {
|
|
11397
|
+
"id": "ses_e5911fb0fffeGOKEpJJBN0lvIY",
|
|
11398
|
+
"projectID": "e75fe47e8650de23de6b64e1f21f27900ada68f8",
|
|
11399
|
+
"model": {
|
|
11400
|
+
"id": "claude-sonnet-4-5",
|
|
11401
|
+
"providerID": "anthropic",
|
|
11402
|
+
"variant": "default"
|
|
11403
|
+
},
|
|
11404
|
+
"cost": 7706e-7,
|
|
11405
|
+
"tokens": {
|
|
11406
|
+
"input": 304,
|
|
11407
|
+
"output": 13,
|
|
11408
|
+
"reasoning": 0,
|
|
11409
|
+
"cache": {
|
|
11410
|
+
"read": 0,
|
|
11411
|
+
"write": 0
|
|
11412
|
+
}
|
|
11413
|
+
},
|
|
11414
|
+
"outcome": "succeeded",
|
|
11415
|
+
"time": {
|
|
11416
|
+
"created": 1793801979254,
|
|
11417
|
+
"updated": 1793801979663,
|
|
11418
|
+
"busy": 1793801979492,
|
|
11419
|
+
"idle": 1793801979667
|
|
11420
|
+
},
|
|
11421
|
+
"title": "Title",
|
|
11422
|
+
"location": {
|
|
11423
|
+
"directory": "/work"
|
|
11424
|
+
}
|
|
11425
|
+
},
|
|
11426
|
+
"messages": [
|
|
11427
|
+
{
|
|
11428
|
+
"id": "msg_1a6ee05cc001xqleuUwvfcXdn4",
|
|
11429
|
+
"time": {
|
|
11430
|
+
"created": 1793801979507
|
|
11431
|
+
},
|
|
11432
|
+
"text": '"say hi"',
|
|
11433
|
+
"files": [],
|
|
11434
|
+
"type": "user"
|
|
11435
|
+
},
|
|
11436
|
+
{
|
|
11437
|
+
"id": "msg_1a6ee0684001OCXcEHTaI3odPp",
|
|
11438
|
+
"time": {
|
|
11439
|
+
"created": 1793801979531,
|
|
11440
|
+
"streamed": 1793801979590,
|
|
11441
|
+
"completed": 1793801979614
|
|
11442
|
+
},
|
|
11443
|
+
"type": "assistant",
|
|
11444
|
+
"agent": "build",
|
|
11445
|
+
"model": {
|
|
11446
|
+
"id": "claude-sonnet-4-5",
|
|
11447
|
+
"providerID": "anthropic",
|
|
11448
|
+
"variant": "default"
|
|
11449
|
+
},
|
|
11450
|
+
"content": [
|
|
11451
|
+
{
|
|
11452
|
+
"type": "tool",
|
|
11453
|
+
"id": "toolu_1",
|
|
11454
|
+
"name": "shell",
|
|
11455
|
+
"executed": false,
|
|
11456
|
+
"state": {
|
|
11457
|
+
"status": "completed",
|
|
11458
|
+
"input": {
|
|
11459
|
+
"command": "echo hi"
|
|
11460
|
+
},
|
|
11461
|
+
"content": [
|
|
11462
|
+
{
|
|
11463
|
+
"type": "text",
|
|
11464
|
+
"text": "hi\n"
|
|
11465
|
+
}
|
|
11466
|
+
],
|
|
11467
|
+
"metadata": {
|
|
11468
|
+
"status": "completed",
|
|
11469
|
+
"truncated": false,
|
|
11470
|
+
"exit": 0
|
|
11471
|
+
}
|
|
11472
|
+
},
|
|
11473
|
+
"time": {
|
|
11474
|
+
"created": 1793801979580,
|
|
11475
|
+
"ran": 1793801979587,
|
|
11476
|
+
"completed": 1793801979603
|
|
11477
|
+
}
|
|
11478
|
+
}
|
|
11479
|
+
],
|
|
11480
|
+
"snapshot": {
|
|
11481
|
+
"start": "4b825dc642cb6eb9a060e54bf8d69288fbee4904",
|
|
11482
|
+
"end": "4b825dc642cb6eb9a060e54bf8d69288fbee4904",
|
|
11483
|
+
"files": []
|
|
11484
|
+
},
|
|
11485
|
+
"finish": "tool-calls",
|
|
11486
|
+
"rawFinish": "tool_use",
|
|
11487
|
+
"cost": 408e-6,
|
|
11488
|
+
"tokens": {
|
|
11489
|
+
"input": 101,
|
|
11490
|
+
"output": 7,
|
|
11491
|
+
"reasoning": 0,
|
|
11492
|
+
"cache": {
|
|
11493
|
+
"read": 0,
|
|
11494
|
+
"write": 0
|
|
11495
|
+
}
|
|
11496
|
+
}
|
|
11497
|
+
},
|
|
11498
|
+
{
|
|
11499
|
+
"id": "msg_1a6ee06eb001NeAwADMhl7eDD4",
|
|
11500
|
+
"time": {
|
|
11501
|
+
"created": 1793801979634,
|
|
11502
|
+
"streamed": 1793801979655,
|
|
11503
|
+
"completed": 1793801979663
|
|
11504
|
+
},
|
|
11505
|
+
"type": "assistant",
|
|
11506
|
+
"agent": "build",
|
|
11507
|
+
"model": {
|
|
11508
|
+
"id": "claude-sonnet-4-5",
|
|
11509
|
+
"providerID": "anthropic",
|
|
11510
|
+
"variant": "default"
|
|
11511
|
+
},
|
|
11512
|
+
"content": [
|
|
11513
|
+
{
|
|
11514
|
+
"type": "text",
|
|
11515
|
+
"text": "done"
|
|
11516
|
+
}
|
|
11517
|
+
],
|
|
11518
|
+
"snapshot": {
|
|
11519
|
+
"start": "4b825dc642cb6eb9a060e54bf8d69288fbee4904",
|
|
11520
|
+
"end": "4b825dc642cb6eb9a060e54bf8d69288fbee4904",
|
|
11521
|
+
"files": []
|
|
11522
|
+
},
|
|
11523
|
+
"finish": "stop",
|
|
11524
|
+
"rawFinish": "end_turn",
|
|
11525
|
+
"cost": 351e-6,
|
|
11526
|
+
"tokens": {
|
|
11527
|
+
"input": 102,
|
|
11528
|
+
"output": 3,
|
|
11529
|
+
"reasoning": 0,
|
|
11530
|
+
"cache": {
|
|
11531
|
+
"read": 0,
|
|
11532
|
+
"write": 0
|
|
11533
|
+
}
|
|
11534
|
+
}
|
|
11535
|
+
},
|
|
11536
|
+
{
|
|
11537
|
+
"id": "msg_1a6ee07130011IztWS6MWWny1w",
|
|
11538
|
+
"time": {
|
|
11539
|
+
"created": 1793801979667
|
|
11540
|
+
},
|
|
11541
|
+
"type": "idle",
|
|
11542
|
+
"outcome": "succeeded"
|
|
11543
|
+
}
|
|
11544
|
+
]
|
|
11545
|
+
};
|
|
11546
|
+
JSON.stringify(SESSION_EXPORT);
|
|
11547
|
+
var PATHS2 = [".outerlayer/AGENTS.md", ".outerlayer/skills/build/SKILL.md"];
|
|
11548
|
+
var SESSION_ID2 = "ses_conformance";
|
|
11549
|
+
`/home/test/.outerlayer/agent-sessions/opencode/${SESSION_EXPORT.info.id}.json`;
|
|
11550
|
+
({
|
|
11551
|
+
hooks: {
|
|
11552
|
+
payloads: Object.fromEntries(
|
|
11553
|
+
["session.execution.started", "session.tool.success", "session.usage.updated", "session.execution.succeeded"].map((name) => [
|
|
11554
|
+
name,
|
|
11555
|
+
JSON.stringify({ id: "evt_1", type: name, data: { sessionID: SESSION_ID2 }, location: { directory: "/work" } })
|
|
11556
|
+
])
|
|
11557
|
+
)
|
|
11558
|
+
},
|
|
11559
|
+
context: {
|
|
11560
|
+
emitInput: { entries: classifyTree(PATHS2).entries}}
|
|
11561
|
+
});
|
|
10680
11562
|
var TEMPLATE_SKILLS = ["spec", "writing-specs", "writing-tests", "build"];
|
|
10681
11563
|
function templateClassLine(version) {
|
|
10682
11564
|
return `<!-- yours to edit. Copied once from the default template by outerlayer init ${version}; never overwritten. -->`;
|
|
@@ -10715,11 +11597,11 @@ ${content}`;
|
|
|
10715
11597
|
return `${block}${block.endsWith("\n") ? "" : "\n"}${line}
|
|
10716
11598
|
${body}`;
|
|
10717
11599
|
}
|
|
10718
|
-
function
|
|
11600
|
+
function filesUnder2(dir, base = dir) {
|
|
10719
11601
|
const out = [];
|
|
10720
11602
|
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
10721
11603
|
const abs = join$1(dir, entry.name);
|
|
10722
|
-
if (entry.isDirectory()) out.push(...
|
|
11604
|
+
if (entry.isDirectory()) out.push(...filesUnder2(abs, base));
|
|
10723
11605
|
else if (entry.isFile()) out.push(abs.slice(base.length + 1).split("\\").join("/"));
|
|
10724
11606
|
}
|
|
10725
11607
|
return out.sort();
|
|
@@ -10732,7 +11614,7 @@ function loadClass(packRoot, skillClass, names, version, base) {
|
|
|
10732
11614
|
for (const skill of names) {
|
|
10733
11615
|
const dir = join$1(packRoot, skillClass, skill);
|
|
10734
11616
|
if (!existsSync(dir)) throw new Error(`skill pack is missing ${skillClass}/${skill} under ${packRoot}`);
|
|
10735
|
-
for (const rel of orderSkillFiles(
|
|
11617
|
+
for (const rel of orderSkillFiles(filesUnder2(dir))) {
|
|
10736
11618
|
const raw = readFileSync(join$1(dir, rel), "utf8");
|
|
10737
11619
|
files.push({
|
|
10738
11620
|
skill,
|
|
@@ -10852,9 +11734,10 @@ function createNodeAgentFs() {
|
|
|
10852
11734
|
return content === void 0 || content.includes(0) ? void 0 : content.toString("utf8");
|
|
10853
11735
|
},
|
|
10854
11736
|
readRawText: (path) => readBytes(path)?.toString("utf8"),
|
|
10855
|
-
|
|
11737
|
+
// Session exports hold transcripts, so only the owner reads them whatever the umask is.
|
|
11738
|
+
write: (path, text) => writeFileSync(path, text, { mode: 384 }),
|
|
10856
11739
|
copy: (from, to) => copyFileSync(from, to),
|
|
10857
|
-
makeDir: (path) => void mkdirSync(path, { recursive: true }),
|
|
11740
|
+
makeDir: (path) => void mkdirSync(path, { recursive: true, mode: 448 }),
|
|
10858
11741
|
list: (dir) => readdirSync(dir),
|
|
10859
11742
|
link: (target, path) => symlinkSync(target, path),
|
|
10860
11743
|
readLink: (path) => readlinkSync(path),
|
|
@@ -10871,7 +11754,7 @@ function createNodeAgentIO() {
|
|
|
10871
11754
|
async run(program, args, options) {
|
|
10872
11755
|
const { execFile } = await import('child_process');
|
|
10873
11756
|
return new Promise((resolve) => {
|
|
10874
|
-
const child = execFile(program, [...args], { cwd: options?.cwd, env: options?.env === void 0 ? process.env : { ...process.env, ...options.env }, encoding: "utf8" }, (error, stdout, stderr) => {
|
|
11757
|
+
const child = execFile(program, [...args], { cwd: options?.cwd, env: options?.env === void 0 ? process.env : { ...process.env, ...options.env }, encoding: "utf8", maxBuffer: Infinity }, (error, stdout, stderr) => {
|
|
10875
11758
|
const code = error === null ? 0 : typeof error.code === "number" ? error.code : 1;
|
|
10876
11759
|
resolve({ code, stdout, stderr });
|
|
10877
11760
|
});
|