hinacode 0.3.0-alpha.7 → 0.3.0-alpha.9

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.
@@ -2,20 +2,20 @@ import { createRequire as __createRequire } from "node:module";
2
2
  globalThis.require ??= __createRequire(import.meta.url);
3
3
  import { execFile, spawn } from "node:child_process";
4
4
  import * as NFS from "node:fs";
5
- import NFS__default, { createReadStream, existsSync, readFileSync, mkdirSync, writeFileSync, renameSync, mkdtempSync, rmSync, watch, chmodSync, statSync, createWriteStream, readlinkSync } from "node:fs";
5
+ import NFS__default, { createReadStream, rmSync, existsSync, readFileSync, mkdirSync, writeFileSync, renameSync, mkdtempSync, watch, chmodSync, statSync, createWriteStream, readlinkSync } from "node:fs";
6
6
  import { createRequire } from "node:module";
7
- import { homedir, networkInterfaces, tmpdir, userInfo, hostname, loadavg, cpus, totalmem } from "node:os";
7
+ import { homedir, tmpdir, networkInterfaces, userInfo, hostname, loadavg, cpus, totalmem } from "node:os";
8
8
  import path__default, { join as join$1, sep, resolve as resolve$1, basename, relative, dirname, isAbsolute, extname, delimiter } from "node:path";
9
9
  import NodeUrl__default, { fileURLToPath } from "node:url";
10
- import { bk as Tuple, d as dual, ai as assignProperty, b6 as isFailure, au as succeed, av as fail$1, K as some, N as none, bl as hash, bm as equals, ad as pipeArguments, bn as NodeInspectSymbol, bo as toJson, g as format$2, Z as isSome, bp as withFiber, bq as uninterruptibleMask, br as get$6, bs as Scope, bt as flow$1, bu as fromInputUnsafe, bv as constant, bw as zero, bd as as, bx as addFinalizerExit, v as void_, b2 as forEach, by as exit, bz as tap$1, $ as sync, aw as interrupt, p as fail$2, bA as ExceededCapacityError, bB as makeUnsafe$5, bC as makeUnsafe$6, bD as makeUnsafe$7, H as suspend, bE as runForkWith, bF as runIn, bG as hasInterrupts, bH as doneUnsafe, bI as getUnsafe$1, bJ as addFinalizer, ax as andThen, bK as _await, bL as getCurrent, bM as interrupt$1, bN as close, bO as isZero, bP as isFinite$1, bQ as Clock, bR as toMillis, _ as flatMap, bS as millis, a8 as ensuring, bT as void_$1, bU as BaseProto, bV as toSeconds, aI as TaggedError, bW as Error$1, bX as symbol$2, bY as structure, bZ as symbol$3, b_ as redact$1, b$ as symbolRedactable, O as make$1o, R as Reference, c0 as strictEqual, e as hasProperty, c1 as fromIterable$2, c2 as PipeInspectableProto, c3 as array$2, c4 as make$1p, c5 as makeEquivalence$2, c6 as getOrThrow, c7 as map$1, c8 as try_, c9 as flatMap$1, ca as combine, cb as string$2, cc as number$4, cd as optimize, n as succeed$1, ce as Random$1, cf as contextWith, cg as infinity, w as withFiber$1, b as sync$1, ch as updateContext, ci as merge$3, cj as succeed$2, ck as exitHasInterrupts, cl as ClockRef, cm as forkUnsafe, cn as onExitUnsafe, co as void_$2, cp as fiberInterrupt, cq as fiberJoin, cr as filterMap, cs as failVoid, ct as isGreaterThanOrEqualTo$1, cu as LogLevelOrder, aN as acquireRelease, i as isEffect, cv as interruptAs, r as runFork, cw as isFailure$1, h as hasInterruptsOnly, cx as into, cy as asVoid, cz as done, cA as filterInterruptors, cB as interruptAllAs, cC as interruptAll, cD as empty$5, cE as forkUnsafe$1, cF as runPromise, cG as runPromiseWith, cH as runPromiseExit, cI as runPromiseExitWith, cJ as runSync, cK as runSyncWith, cL as runSyncExit, cM as runSyncExitWith, cN as runCallback, cO as runCallbackWith, cP as makeMemoMapUnsafe, aB as provideContext, cQ as buildWithMemoMap, cR as flatten, cS as await_, cT as scopeRemoveFinalizerUnsafe, cU as die, cV as isResult, cW as isSuccess, m as identity, cX as effect, aj as Service$1, cY as contextWith$1, cZ as getOrUndefined, am as gen, c_ as context, c$ as make$1q, V as map$2, d0 as fromQueue, d1 as unwrap, aq as provideService, d2 as onExit, d3 as failCauseUnsafe, aV as offerUnsafe, T as TaggedError$1, U as Union, S as String$1, o as optional$7, D as Defect, P as Prototype, d4 as makeSpanUnsafe, d5 as TracerTimingEnabled, d6 as endSpan, d7 as makeSpanScoped, d8 as useSpan, d9 as constUndefined, da as provideService$1, db as ParentSpan, z as scoped, t as tapCause, y as fnUntraced, dc as serviceOption, a3 as match, dd as make$1r, de as provide$1, df as onError, dg as catchIf, dh as scope$1, di as getOption, dj as onExitPrimitive, a as isSuccess$1, dk as catchCause, dl as matchCauseEffect, dm as failCause, dn as combine$1, a9 as orDie, dp as add$1, dq as makeUnsafe$8, dr as fromReasons, ds as isFailReason, dt as makeDieReason, du as reasonAnnotations, dv as failCause$1, dw as yieldNow, dx as constTrue, dy as normalizeNonEmpty, dz as unbounded, dA as publishUnsafe, dB as fromPubSub, dC as getDefaultExportFromCjs, a$ as all$1, M as match$1, b5 as promise$1, b4 as ProviderId, dD as now, dE as formatIso, a2 as pipe$2, dF as sort, Y as map$3, dG as flatMapNullishOr, dH as catch_, bg as map$4, dI as fromNullishOr, x as mapError, dJ as logDebug, dK as annotateLogs, dL as withSpan, ay as catchTag, dM as logInfo, dN as catchDefect, dO as filterOrFail, dP as make$1s, dQ as Number$1, dR as encodeEffect, k as decodeUnknownEffect, aZ as succeedNone, a7 as isReadonlyArrayNonEmpty, dS as asSome, dT as mutable, A as ArraySchema, dU as NoSuchElementError, dV as Literals, b1 as Number$2, ba as NullOr, aD as Struct, dW as FileSystem, dX as orElseSucceed, dY as chatFolder, dZ as Boolean$1, d_ as ProjectKind, d$ as ignore$1, e0 as logWarning, aT as callback, e1 as sleep$3, e2 as forkDetach, e3 as succeed$3, e4 as signedOutFailure, e5 as decodeUnknownOption, an as isNone, aL as fromJsonString, L as Literal, e6 as Unknown, e7 as toArray, aJ as seconds, f as optionalKey, e8 as cachedWithTTL, e9 as minutes, aO as unbounded$1, ea as toAsyncIterable, bf as tryPromise, eb as timeout, ec as addFinalizer$1, ed as callback$1, ee as offer, ef as withPermit, eg as acquireUseRelease, aP as endUnsafe, eh as shutdownUnsafe, ei as make$1t, bc as try_$1, ej as forkIn, ek as fromAsyncIterable, el as runForEach, s as squash, em as CLAUDE_EFFORT_LEVELS, en as ensuring$1, eo as currentTimeMillis, ep as sum, eq as race, er as publishedArtifactId, es as PUBLISH_DOCUMENT_TOOL, et as PUBLISH_ARTIFACT_TOOL, eu as PUBLISH_WHITEBOARD_TOOL, ev as isDone, ew as empty$6, ex as succeed$4, ey as fromIterable$3, ez as flatMap$2, eA as interruptWhen, eB as concat, eC as fromEffectDrain, eD as fromEffect, eE as fromIterableEffect, eF as suspend$1, eG as unlistedModel, eH as make$1u, eI as tap$2, eJ as tick, eK as map$5, eL as drop, eM as merge$4, eN as onInterrupt, aS as timeoutOrElse, eO as format$3, eP as getOrNull, eQ as Record, eR as make$1v, aa as take, eS as join$2, ab as raceFirst, eT as end, eU as forkScoped, eV as isObject$2, J as getOrElse, eW as repeat, ao as succeed$5, eX as subscribe, eY as fromSubscription, eZ as publish, e_ as defaultSettings, e$ as Settings$2, f0 as flatMapNullishOr$1, f1 as option, f2 as delay, f3 as effectContext, aA as make$1w, f4 as provide$2, f5 as monotonicTimeNanos, f6 as retry$3, f7 as spaced, f8 as die$1, f9 as PRIVATE_NETWORKS, fa as effectDiscard, fb as provideMerge, fc as UpdatableProviderId, fd as decodeUnknownSync, fe as spawnsSubagent, ff as isPublishArtifactTool, fg as outputText, fh as publishedArtifact, fi as toolArgument, fj as isPublishDocumentTool, fk as AgentProfile, fl as Void, fm as AccountProviderId, fn as filter$1, fo as AgentAccount, fp as commonjsGlobal, fq as isRunAgentTool, fr as presetModels, fs as encodeSync, ft as mergeAll, b9 as PushEvent, fu as filter$2, fv as take$1, fw as runDrain, fx as forever, fy as never$1, fz as min, l as logError, fA as ChildProcessSpawner, fB as make$1x, fC as mkString, fD as decodeText$1, fE as ForkPoint, fF as TokenUsage, fG as MessagePart, fH as Message, fI as sliding, fJ as parseGitHubPullRequestUrl, fK as PullRequestReviewer, fL as PullRequestLabel, fM as PullRequestComment, fN as DiffSide, fO as omit$1, fP as subtract, fQ as PULL_REQUEST_REFRESH, ae as catchTags, fR as parseGitHubRepository, I as Int, fS as request$2, fT as Class, fU as ProjectAction, fV as Project, fW as BooleanFromBit, fX as Worktree, fY as timeoutOption, be as isThreadBusy, bb as ThreadStatus, fZ as ScheduledMessage, f_ as QueuedMessage, f$ as UsageLimit, aH as Thread, g0 as getOrThrow$1, g1 as PullRequestWatch, g2 as PullRequestLink, g3 as PullRequestStatus, g4 as allWatchEventKinds, g5 as enabledProviders, g6 as transcriptThreadId, g7 as resumeGraceMs, g8 as fail$3, g9 as WAIT_AGENT_TOOL, bh as tapError, ga as filter$3, gb as isMaxLength, gc as schedule, aR as RpcMethods, gd as BrowserFrame, ge as PagePick, gf as defaultClientSettings, gg as ClientSettings$1, gh as parsePairingUrl, gi as pairingUrl, gj as Environment, ah as getOrUndefined$1, az as result$1, gk as relayWebSocketUrl, gl as remoteWebSocketUrl, aW as WebSocket, aM as ServerFrame, gm as CHALLENGE_WAIT_MS, aU as methodKind, gn as dialPlan, go as REMOTE_PROTOCOL_VERSION, gp as DIRECT_CHECK_INTERVAL_MS, gq as DIRECT_CHECK_TIMEOUT_MS, gr as LinearIssue, gs as externalSpan, af as fromUndefinedOr, gt as zero$1, gu as fromInput$2, gv as badArgument, gw as isSchemaError, gx as isNoSuchElementError, gy as StackTrace, gz as mapEager, gA as updateContext$1, gB as makeUnsafe$9, gC as tag$2, gD as Error$2, gE as fromInputUnsafe$1, gF as Path, gG as run$6, gH as mebibytes, gI as Class$1, gJ as constFalse, gK as withLogSpan, gL as log, gM as Tracer, gN as nativeTracer, gO as hasInterrupts$1, gP as succeed$6, gQ as setStackTraceLimit, gR as fail$4, gS as getStackTraceLimit, gT as fiberEnterUninterruptibleUnsafe, gU as contA, gV as effectIsExit, gW as closeUnsafe, gX as contE, gY as reportCauseUnsafe, gZ as matchCauseEffectEager, g_ as flatMapEager, g$ as fromReadable, h0 as toArrayBuffer, G as cached$1, h1 as layer$W, h2 as pipeThroughDuplex, h3 as toUint8Array, bj as layer$X, b0 as fromResult, h4 as WebSocketServer, h5 as orDie$1, h6 as runForEachArray, h7 as interruptible, h8 as die$2, h9 as merge$5, ha as succeedContext, hb as unwrap$1, hc as withFiberSucceed, hd as reverse, he as getOrUndefinedUnsafe, hf as CurrentMemoMap, a0 as empty$7, hg as fiberEnterInterruptibleUnsafe, hh as compose$1, hi as Timestamp, hj as AutomationTrigger, hk as AutomationRun, hl as isPolledTrigger, hm as launch, hn as Duration, ho as DateTimeUtc, hp as withConstructorDefault, hq as withDecodingDefault, hr as Redacted, hs as Tuple$1, ht as isRedacted, hu as MutableJson, ag as isNotUndefined, hv as Never, ak as empty$8, hw as toJsonSchemaDocument, hx as annotateCurrentSpan, hy as isUndefined, hz as failCause$2, hA as forkChild, hB as catch_$1, hC as isSchemaError$1, hD as failCause$3, hE as mapEffect, hF as onEnd, hG as isSchema, aQ as encodeUnknownEffect, hH as annotate, hI as fail$5, hJ as make$1y, hK as declare, hL as isStream, hM as Class$2, hN as Exit, bi as provide$3, hO as provideContext$1, hP as StructWithRest, hQ as JsonObject$3, hR as Opaque, hS as decodeTo, hT as transformOptional, hU as flatMap$3, hV as toType, hW as Any, hX as UndefinedOr, hY as Finite, hZ as passthrough, h_ as Uint8ArrayFromBase64, h$ as Json, i0 as TemplateLiteral, i1 as decode$3, i2 as withDefault, i3 as isBetween, W as taggedEnum, i4 as take$2, i5 as toCodecJson, i6 as isNullish, i7 as isString, i8 as bounded, i9 as withParentSpan, ia as die$3, ib as offerAll, ic as interrupt$2, id as interruptors, ie as decodeSync, ig as catchCauseIf, ih as NonEmptyArray, ii as decode$4, ij as decodeUnknownResult, ik as fn, il as isTagged, im as isReadonlyObject, io as IllegalArgumentError, ip as encode$1, iq as collect, ir as catchDone, is as takeAll, it as fromArray, iu as whileLoop, iv as isExit, iw as matchEffect, ix as defaultFormatter, iy as logFatal, iz as isDeferred, iA as hasDies, c as constVoid, iB as shutdown, iC as Scheduler, iD as CurrentLogLevel, q as is$2, iE as decodeEffect, iF as UnknownFromJsonString, iG as ignoreCause, iH as Class$3, iI as TaggedStruct, iJ as toEncoded, iK as when$2, iL as threadDeviceId, iM as devicePlatformOf, ap as value$2, iN as runLast, iO as fromOption, iP as RUN_AGENT_TOOL, iQ as ARTIFACT_THEME_GUIDE, iR as DeviceUrl, iS as DeviceApp, iT as DeviceButton, iU as WatchEventKind, iV as isPattern, iW as RelayHostList, iX as RelayMachineList, iY as GuideGroup, iZ as PullRequestGuide, i_ as uninterruptible, i$ as flatten$1, j0 as diskFullness, j1 as pretty, j2 as startingProvider, j3 as min$1, j4 as exponential, j5 as desktopOnlyPushes, j6 as reachesPhone, j7 as mutations, j8 as desktopOnlyMethods, j9 as isAddressNotUpYet, ja as ClientFrame, aY as REMOTE_MAX_FRAME_BYTES, aX as REMOTE_PATH, jb as empty$9, a_ as cliSocketPath, jc as BindHost, jd as take$3, je as getAugmentedNamespace, jf as make$1z, jg as NativeSpan, jh as currentTimeNanos, aC as MinimumLogLevel, ji as isPortInUse } from "./chunks/remote-iFIM3qRP.js";
11
- import Se__default from "fs";
10
+ import { bk as Tuple, d as dual, ai as assignProperty, b6 as isFailure, au as succeed, av as fail$1, K as some, N as none, bl as hash, bm as equals, ad as pipeArguments, bn as NodeInspectSymbol, bo as toJson, g as format$2, Z as isSome, bp as withFiber, bq as uninterruptibleMask, br as get$6, bs as Scope, bt as flow$1, bu as fromInputUnsafe, bv as constant, bw as zero, bd as as, bx as addFinalizerExit, v as void_, b2 as forEach, by as exit, bz as tap$1, $ as sync, aw as interrupt, p as fail$2, bA as ExceededCapacityError, bB as makeUnsafe$5, bC as makeUnsafe$6, bD as makeUnsafe$7, H as suspend, bE as runForkWith, bF as runIn, bG as hasInterrupts, bH as doneUnsafe, bI as getUnsafe$1, bJ as addFinalizer, ax as andThen, bK as _await, bL as getCurrent, bM as interrupt$1, bN as close, bO as isZero, bP as isFinite$1, bQ as Clock, bR as toMillis, _ as flatMap, bS as millis, a8 as ensuring, bT as void_$1, bU as BaseProto, bV as toSeconds, aI as TaggedError, bW as Error$1, bX as symbol$2, bY as structure, bZ as symbol$3, b_ as redact$1, b$ as symbolRedactable, O as make$1o, R as Reference, c0 as strictEqual, e as hasProperty, c1 as fromIterable$2, c2 as PipeInspectableProto, c3 as array$2, c4 as make$1p, c5 as makeEquivalence$2, c6 as getOrThrow, c7 as map$1, c8 as try_, c9 as flatMap$1, ca as combine, cb as string$2, cc as number$4, cd as optimize, n as succeed$1, ce as Random$1, cf as contextWith, cg as infinity, w as withFiber$1, b as sync$1, ch as updateContext, ci as merge$3, cj as succeed$2, ck as exitHasInterrupts, cl as ClockRef, cm as forkUnsafe, cn as onExitUnsafe, co as void_$2, cp as fiberInterrupt, cq as fiberJoin, cr as filterMap, cs as failVoid, ct as isGreaterThanOrEqualTo$1, cu as LogLevelOrder, aN as acquireRelease, i as isEffect, cv as interruptAs, r as runFork, cw as isFailure$1, h as hasInterruptsOnly, cx as into, cy as asVoid, cz as done, cA as filterInterruptors, cB as interruptAllAs, cC as interruptAll, cD as empty$5, cE as forkUnsafe$1, cF as runPromise, cG as runPromiseWith, cH as runPromiseExit, cI as runPromiseExitWith, cJ as runSync, cK as runSyncWith, cL as runSyncExit, cM as runSyncExitWith, cN as runCallback, cO as runCallbackWith, cP as makeMemoMapUnsafe, aB as provideContext, cQ as buildWithMemoMap, cR as flatten, cS as await_, cT as scopeRemoveFinalizerUnsafe, cU as die, cV as isResult, cW as isSuccess, m as identity, cX as effect, aj as Service$1, cY as contextWith$1, cZ as getOrUndefined, am as gen, c_ as context, c$ as make$1q, V as map$2, d0 as fromQueue, d1 as unwrap, aq as provideService, d2 as onExit, d3 as failCauseUnsafe, aV as offerUnsafe, T as TaggedError$1, U as Union, S as String$1, o as optional$7, D as Defect, P as Prototype, d4 as makeSpanUnsafe, d5 as TracerTimingEnabled, d6 as endSpan, d7 as makeSpanScoped, d8 as useSpan, d9 as constUndefined, da as provideService$1, db as ParentSpan, z as scoped, t as tapCause, y as fnUntraced, dc as serviceOption, a3 as match, dd as make$1r, de as provide$1, df as onError, dg as catchIf, dh as scope$1, di as getOption, dj as onExitPrimitive, a as isSuccess$1, dk as catchCause, dl as matchCauseEffect, dm as failCause, dn as combine$1, a9 as orDie, dp as add$1, dq as makeUnsafe$8, dr as fromReasons, ds as isFailReason, dt as makeDieReason, du as reasonAnnotations, dv as failCause$1, dw as yieldNow, dx as constTrue, dy as normalizeNonEmpty, dz as unbounded, dA as publishUnsafe, dB as fromPubSub, dC as getDefaultExportFromCjs, a$ as all$1, M as match$1, b5 as promise$1, b4 as ProviderId, dD as now, dE as formatIso, a2 as pipe$2, dF as sort, Y as map$3, dG as flatMapNullishOr, dH as catch_, bg as map$4, dI as fromNullishOr, x as mapError, dJ as logDebug, dK as annotateLogs, dL as withSpan, ay as catchTag, dM as logInfo, dN as catchDefect, dO as filterOrFail, dP as make$1s, dQ as Number$1, dR as encodeEffect, k as decodeUnknownEffect, aZ as succeedNone, a7 as isReadonlyArrayNonEmpty, dS as asSome, dT as mutable, A as ArraySchema, dU as NoSuchElementError, dV as Literals, b1 as Number$2, ba as NullOr, aD as Struct, dW as FileSystem, dX as orElseSucceed, dY as chatFolder, dZ as Boolean$1, d_ as ProjectKind, d$ as ignore$1, e0 as logWarning, aT as callback, e1 as sleep$3, e2 as forkDetach, e3 as succeed$3, e4 as signedOutFailure, e5 as decodeUnknownOption, an as isNone, aL as fromJsonString, L as Literal, e6 as Unknown, e7 as toArray, aJ as seconds, f as optionalKey, e8 as cachedWithTTL, e9 as minutes, aO as unbounded$1, ea as toAsyncIterable, bf as tryPromise, eb as timeout, ec as addFinalizer$1, ed as callback$1, ee as offer, ef as withPermit, eg as acquireUseRelease, aP as endUnsafe, eh as shutdownUnsafe, ei as make$1t, bc as try_$1, bh as tapError, ej as forkIn, ek as fromAsyncIterable, el as runForEach, s as squash, em as CLAUDE_EFFORT_LEVELS, en as ensuring$1, eo as currentTimeMillis, ep as sum, eq as race, er as publishedArtifactId, es as PUBLISH_DOCUMENT_TOOL, et as PUBLISH_ARTIFACT_TOOL, eu as PUBLISH_WHITEBOARD_TOOL, ev as isDone, ew as empty$6, ex as succeed$4, ey as fromIterable$3, ez as flatMap$2, eA as interruptWhen, eB as concat, eC as fromEffectDrain, eD as fromEffect, eE as fromIterableEffect, eF as suspend$1, eG as unlistedModel, eH as make$1u, eI as tap$2, eJ as tick, eK as map$5, eL as drop, eM as merge$4, eN as onInterrupt, aS as timeoutOrElse, eO as format$3, eP as getOrNull, eQ as Record, eR as make$1v, aa as take, eS as join$2, ab as raceFirst, eT as end, eU as forkScoped, eV as isObject$2, J as getOrElse, eW as repeat, ao as succeed$5, eX as subscribe, eY as fromSubscription, eZ as applySettingsPatch, e_ as publish, e$ as defaultSettings, f0 as Settings$2, f1 as flatMapNullishOr$1, f2 as option, f3 as delay, f4 as effectContext, aA as make$1w, f5 as provide$2, f6 as monotonicTimeNanos, f7 as retry$3, f8 as spaced, f9 as die$1, fa as PRIVATE_NETWORKS, fb as effectDiscard, fc as provideMerge, fd as UpdatableProviderId, fe as decodeUnknownSync, ff as spawnsSubagent, fg as isPublishArtifactTool, fh as outputText, fi as publishedArtifact, fj as toolArgument, fk as isPublishDocumentTool, fl as AgentProfile, fm as Void, fn as AccountProviderId, fo as filter$1, fp as AgentAccount, fq as commonjsGlobal, fr as isRunAgentTool, fs as presetModels, ft as encodeSync, fu as mergeAll, b9 as PushEvent, fv as filter$2, fw as take$1, fx as runDrain, fy as forever, fz as never$1, fA as min, l as logError, fB as ChildProcessSpawner, fC as make$1x, fD as mkString, fE as decodeText$1, fF as ForkPoint, fG as TokenUsage, fH as MessagePart, fI as Message, fJ as sliding, fK as parseGitHubPullRequestUrl, fL as PullRequestReviewer, fM as PullRequestLabel, fN as PullRequestComment, fO as DiffSide, fP as omit$1, fQ as subtract, fR as PULL_REQUEST_REFRESH, ae as catchTags, fS as parseGitHubRepository, I as Int, fT as request$2, fU as Class, fV as ProjectAction, fW as Project, fX as BooleanFromBit, fY as Worktree, be as isThreadBusy, fZ as timeoutOption, bb as ThreadStatus, f_ as ScheduledMessage, f$ as QueuedMessage, g0 as UsageLimit, aH as Thread, g1 as getOrThrow$1, g2 as PullRequestWatch, g3 as PullRequestLink, g4 as PullRequestStatus, g5 as allWatchEventKinds, g6 as enabledProviders, g7 as transcriptThreadId, g8 as resumeGraceMs, g9 as fail$3, ga as WAIT_AGENT_TOOL, gb as filter$3, gc as isMaxLength, gd as schedule, aR as RpcMethods, ge as BrowserFrame, gf as PagePick, gg as defaultClientSettings, gh as ClientSettings$1, gi as parsePairingUrl, gj as pairingUrl, gk as Environment, ah as getOrUndefined$1, az as result$1, gl as relayWebSocketUrl, gm as remoteWebSocketUrl, aW as WebSocket, aM as ServerFrame, gn as CHALLENGE_WAIT_MS, aU as methodKind, go as dialPlan, gp as REMOTE_PROTOCOL_VERSION, gq as DIRECT_CHECK_INTERVAL_MS, gr as DIRECT_CHECK_TIMEOUT_MS, gs as LinearIssue, gt as externalSpan, af as fromUndefinedOr, gu as zero$1, gv as fromInput$2, gw as badArgument, gx as isSchemaError, gy as isNoSuchElementError, gz as StackTrace, gA as mapEager, gB as updateContext$1, gC as makeUnsafe$9, gD as tag$2, gE as Error$2, gF as fromInputUnsafe$1, gG as Path, gH as run$6, gI as mebibytes, gJ as Class$1, gK as constFalse, gL as withLogSpan, gM as log, gN as Tracer, gO as nativeTracer, gP as hasInterrupts$1, gQ as succeed$6, gR as setStackTraceLimit, gS as fail$4, gT as getStackTraceLimit, gU as fiberEnterUninterruptibleUnsafe, gV as contA, gW as effectIsExit, gX as closeUnsafe, gY as contE, gZ as reportCauseUnsafe, g_ as matchCauseEffectEager, g$ as flatMapEager, h0 as fromReadable, h1 as toArrayBuffer, G as cached$1, h2 as layer$W, h3 as pipeThroughDuplex, h4 as toUint8Array, bj as layer$X, b0 as fromResult, h5 as WebSocketServer, h6 as orDie$1, h7 as runForEachArray, h8 as interruptible, h9 as die$2, ha as merge$5, hb as succeedContext, hc as unwrap$1, hd as withFiberSucceed, he as reverse, hf as getOrUndefinedUnsafe, hg as CurrentMemoMap, a0 as empty$7, hh as fiberEnterInterruptibleUnsafe, hi as compose$1, hj as Timestamp, hk as AutomationTrigger, hl as AutomationRun, hm as isPolledTrigger, hn as launch, ho as Duration, hp as DateTimeUtc, hq as withConstructorDefault, hr as withDecodingDefault, hs as Redacted, ht as Tuple$1, hu as isRedacted, hv as MutableJson, ag as isNotUndefined, hw as Never, ak as empty$8, hx as toJsonSchemaDocument, hy as annotateCurrentSpan, hz as isUndefined, hA as failCause$2, hB as forkChild, hC as catch_$1, hD as isSchemaError$1, hE as failCause$3, hF as mapEffect, hG as onEnd, hH as isSchema, aQ as encodeUnknownEffect, hI as annotate, hJ as fail$5, hK as make$1y, hL as declare, hM as isStream, hN as Class$2, hO as Exit, bi as provide$3, hP as provideContext$1, hQ as StructWithRest, hR as JsonObject$3, hS as Opaque, hT as decodeTo, hU as transformOptional, hV as flatMap$3, hW as toType, hX as Any, hY as UndefinedOr, hZ as Finite, h_ as passthrough, h$ as Uint8ArrayFromBase64, i0 as Json, i1 as TemplateLiteral, i2 as decode$3, i3 as withDefault, i4 as isBetween, W as taggedEnum, i5 as take$2, i6 as toCodecJson, i7 as isNullish, i8 as isString, i9 as bounded, ia as withParentSpan, ib as die$3, ic as offerAll, id as interrupt$2, ie as interruptors, ig as decodeSync, ih as catchCauseIf, ii as NonEmptyArray, ij as decode$4, ik as decodeUnknownResult, il as fn, im as isTagged, io as isReadonlyObject, ip as IllegalArgumentError, iq as encode$1, ir as collect, is as catchDone, it as takeAll, iu as fromArray, iv as whileLoop, iw as isExit, ix as matchEffect, iy as defaultFormatter, iz as logFatal, iA as isDeferred, iB as hasDies, c as constVoid, iC as shutdown, iD as Scheduler, iE as CurrentLogLevel, q as is$2, iF as decodeEffect, iG as UnknownFromJsonString, iH as ignoreCause, iI as Class$3, iJ as TaggedStruct, iK as toEncoded, iL as when$2, iM as threadDeviceId, iN as shownScreen, iO as devicePlatformOf, ap as value$2, iP as runLast, iQ as fromOption, iR as RUN_AGENT_TOOL, iS as ARTIFACT_THEME_GUIDE, iT as DeviceUrl, iU as DeviceApp, iV as DeviceButton, iW as WatchEventKind, iX as isPattern, iY as RelayHostList, iZ as RelayMachineList, i_ as GuideGroup, i$ as PullRequestGuide, j0 as uninterruptible, j1 as flatten$1, j2 as diskFullness, j3 as pretty, j4 as startingProvider, j5 as min$1, j6 as exponential, j7 as desktopOnlyPushes, j8 as reachesPhone, j9 as mutations, ja as desktopOnlyMethods, jb as isAddressNotUpYet, jc as ClientFrame, aY as REMOTE_MAX_FRAME_BYTES, aX as REMOTE_PATH, jd as empty$9, a_ as cliSocketPath, je as BindHost, jf as take$3, jg as getAugmentedNamespace, jh as make$1z, ji as NativeSpan, jj as currentTimeNanos, aC as MinimumLogLevel, jk as isPortInUse } from "./chunks/remote-CVe-bsYz.js";
11
+ import Ee__default from "fs";
12
12
  import require$$0 from "util";
13
13
  import require$$1$1 from "stream";
14
14
  import require$$0$1 from "zlib";
15
15
  import require$$0$2 from "assert";
16
16
  import require$$0$3 from "buffer";
17
17
  import fs, { readFile, realpath, readlink, stat, mkdir, cp, readdir, writeFile, rename, rm, access, copyFile, constants as constants$8, open as open$1, lstat, mkdtemp, chmod, statfs } from "node:fs/promises";
18
- import xe__default from "path";
18
+ import Pe__default from "path";
19
19
  import crypto__default, { randomUUID, createHash, randomBytes, timingSafeEqual, createHmac } from "node:crypto";
20
20
  import { createInterface } from "node:readline";
21
21
  import require$$0$5 from "node:assert";
@@ -6971,7 +6971,7 @@ function requirePng() {
6971
6971
  if (hasRequiredPng) return png$1;
6972
6972
  hasRequiredPng = 1;
6973
6973
  (function(exports) {
6974
- const fs2 = Se__default;
6974
+ const fs2 = Ee__default;
6975
6975
  const PNG = requirePng$1().PNG;
6976
6976
  const Utils = requireUtils$3();
6977
6977
  exports.render = function render(qrData, options) {
@@ -7093,7 +7093,7 @@ function requireUtf8$1() {
7093
7093
  cb = options;
7094
7094
  options = void 0;
7095
7095
  }
7096
- const fs2 = Se__default;
7096
+ const fs2 = Ee__default;
7097
7097
  const utf82 = exports.render(qrData, options);
7098
7098
  fs2.writeFile(path2, utf82, cb);
7099
7099
  };
@@ -7276,7 +7276,7 @@ function requireSvg() {
7276
7276
  cb = options;
7277
7277
  options = void 0;
7278
7278
  }
7279
- const fs2 = Se__default;
7279
+ const fs2 = Ee__default;
7280
7280
  const svgTag2 = exports.render(qrData, options);
7281
7281
  const xmlStr = '<?xml version="1.0" encoding="utf-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">' + svgTag2;
7282
7282
  fs2.writeFile(path2, xmlStr, cb);
@@ -7666,7 +7666,7 @@ function requireLib() {
7666
7666
  if (hasRequiredLib) return lib;
7667
7667
  hasRequiredLib = 1;
7668
7668
  const { isexe, sync: isexeSync } = requireIndex_min();
7669
- const { join: join2, delimiter: delimiter2, sep: sep2, posix } = xe__default;
7669
+ const { join: join2, delimiter: delimiter2, sep: sep2, posix } = Pe__default;
7670
7670
  const isWindows = process.platform === "win32";
7671
7671
  const rSlash = new RegExp(`[${posix.sep}${sep2 === posix.sep ? "" : sep2}]`.replace(/(\\)/g, "\\$1"));
7672
7672
  const rRel = new RegExp(`^\\.${rSlash.source}`);
@@ -8564,7 +8564,8 @@ function makeApprovals(provider, emit) {
8564
8564
  }
8565
8565
  const threadMention = (threadId) => `@thread:${threadId}`;
8566
8566
  const terminalMention = (terminalId) => `@terminal:${terminalId}`;
8567
- const MENTION = /@(thread|terminal):([\w-]+)/g;
8567
+ const artifactMention = (artifactId) => `@artifact:${artifactId}`;
8568
+ const MENTION = /@(thread|terminal|artifact):([\w-]+)/g;
8568
8569
  const NAME = String.raw`[\w:-]+(?:\.[\w:-]+)*`;
8569
8570
  const WHOLE_NAME = new RegExp(`^${NAME}$`);
8570
8571
  const isCommandName = (name) => WHOLE_NAME.test(name);
@@ -44862,7 +44863,7 @@ const shorten$1 = (text2, length) => {
44862
44863
  };
44863
44864
  const recordedCwd = (cwd) => realpath(cwd).catch(() => cwd);
44864
44865
  const listClaudeSessions = async (home, cwd) => {
44865
- const { listSessions: listSessions2 } = await import("./chunks/sdk-BjcPK2t_.js");
44866
+ const { listSessions: listSessions2 } = await import("./chunks/sdk-DZclv7I1.js");
44866
44867
  const folder = await recordedCwd(cwd);
44867
44868
  const sessions = await listSessions2({ dir: folder, sessionStore: homeStore(home), limit: LISTED_SESSIONS });
44868
44869
  return sessions.filter((session) => session.cwd === void 0 || session.cwd === folder).map((session) => ({
@@ -45061,7 +45062,7 @@ const fallbackModel = (id2, label) => ({
45061
45062
  });
45062
45063
  const FALLBACK_MODELS = [
45063
45064
  fallbackModel("claude-opus-5-5", "Opus 5.5"),
45064
- fallbackModel("claude-fable-5-1", "Fable 5.1"),
45065
+ fallbackModel("claude-fable-5-2", "Fable 5.2"),
45065
45066
  fallbackModel("claude-sonnet-5-5", "Sonnet 5.5"),
45066
45067
  fallbackModel("claude-haiku-5-5", "Haiku 5.5")
45067
45068
  ];
@@ -45139,6 +45140,14 @@ const sameContext = (a, b) => a.cwd === b.cwd && sameHome(a.home, b.home) && a.i
45139
45140
  const homeEnv = (home) => home === null ? { ...process.env } : { ...process.env, CLAUDE_CONFIG_DIR: home.dir };
45140
45141
  const errorMessage$1 = (cause) => cause instanceof Error ? cause.message : String(cause);
45141
45142
  const agentError = (message2) => (cause) => new AgentError({ provider: "claude", message: `${message2}: ${errorMessage$1(cause)}` });
45143
+ const writeSettingsFile = (directory, settings) => tryPromise({
45144
+ try: async () => {
45145
+ const path2 = join$1(directory ?? tmpdir(), `claude-settings-${randomUUID()}.json`);
45146
+ await writeFile(path2, JSON.stringify(settings), { mode: 384, flag: "wx" });
45147
+ return path2;
45148
+ },
45149
+ catch: agentError("Failed to write Claude Code settings")
45150
+ });
45142
45151
  const copySession$1 = (sessionId, from, to) => tryPromise({
45143
45152
  try: () => copyTranscripts(sessionId, from?.dir ?? claudeHome(), to?.dir ?? claudeHome()),
45144
45153
  catch: agentError("Failed to copy Claude transcripts")
@@ -45196,7 +45205,7 @@ const baseOptions = (home) => map$2(installedBinary("claude", home?.binary ?? "c
45196
45205
  const probe$2 = (read2, failure2, home, options = {}) => gen(function* () {
45197
45206
  const prompts = yield* unbounded$1();
45198
45207
  const base = yield* baseOptions(home);
45199
- const { query } = yield* promise$1(() => import("./chunks/sdk-BjcPK2t_.js"));
45208
+ const { query } = yield* promise$1(() => import("./chunks/sdk-DZclv7I1.js"));
45200
45209
  const cli = query({
45201
45210
  prompt: toAsyncIterable(fromQueue(prompts)),
45202
45211
  options: { ...base, settingSources: [], persistSession: false, ...options }
@@ -45314,6 +45323,7 @@ const makeClaudeHarness = ({ id: id2, listModels, launchEnv }) => gen(function*
45314
45323
  shutdownUnsafe(session.prompts);
45315
45324
  session.abort.abort();
45316
45325
  session.query.close();
45326
+ rmSync(session.settingsFile, { force: true });
45317
45327
  };
45318
45328
  const closeSession = (session) => sync(() => closeSessionUnsafe(session));
45319
45329
  const armExpiry = (session) => gen(function* () {
@@ -45484,7 +45494,13 @@ const makeClaudeHarness = ({ id: id2, listModels, launchEnv }) => gen(function*
45484
45494
  const keepsGrants = previous !== void 0 && previous.sessionId === resume && sameContext(previous, input);
45485
45495
  const base = yield* baseOptions(input.home);
45486
45496
  const effort = effortLevelOf(input.effort);
45487
- const { query } = yield* promise$1(() => import("./chunks/sdk-BjcPK2t_.js"));
45497
+ const { query } = yield* promise$1(() => import("./chunks/sdk-DZclv7I1.js"));
45498
+ const settingsFile = yield* writeSettingsFile(input.tmpDirectory, {
45499
+ ...Object.keys(launch2).length > 0 && { env: { ...launch2 } },
45500
+ fastMode: input.fastMode,
45501
+ ...input.autoCompactTokens !== null && { autoCompactWindow: input.autoCompactTokens },
45502
+ ...input.effort === ULTRACODE && { ultracode: true }
45503
+ });
45488
45504
  const handle = yield* try_$1({
45489
45505
  try: () => query({
45490
45506
  prompt: toAsyncIterable(fromQueue(prompts)),
@@ -45495,12 +45511,7 @@ const makeClaudeHarness = ({ id: id2, listModels, launchEnv }) => gen(function*
45495
45511
  cwd: input.cwd,
45496
45512
  model: input.model,
45497
45513
  ...effort === null ? {} : { effort },
45498
- settings: {
45499
- ...Object.keys(launch2).length > 0 && { env: { ...launch2 } },
45500
- fastMode: input.fastMode,
45501
- ...input.autoCompactTokens !== null && { autoCompactWindow: input.autoCompactTokens },
45502
- ...input.effort === ULTRACODE && { ultracode: true }
45503
- },
45514
+ settings: settingsFile,
45504
45515
  ...resume === void 0 ? {} : { resume },
45505
45516
  ...input.forkAt !== null && { forkSession: true, resumeSessionAt: input.forkAt },
45506
45517
  includePartialMessages: true,
@@ -45532,7 +45543,7 @@ const makeClaudeHarness = ({ id: id2, listModels, launchEnv }) => gen(function*
45532
45543
  }
45533
45544
  }),
45534
45545
  catch: agentError("Failed to start Claude Code")
45535
- });
45546
+ }).pipe(tapError(() => sync(() => rmSync(settingsFile, { force: true }))));
45536
45547
  const session = {
45537
45548
  threadId: input.threadId,
45538
45549
  cwd: input.cwd,
@@ -45543,6 +45554,7 @@ const makeClaudeHarness = ({ id: id2, listModels, launchEnv }) => gen(function*
45543
45554
  fastMode: input.fastMode,
45544
45555
  autoCompactTokens: input.autoCompactTokens,
45545
45556
  launch: launch2,
45557
+ settingsFile,
45546
45558
  permissionMode: mode2,
45547
45559
  prompts,
45548
45560
  abort,
@@ -56950,7 +56962,7 @@ const make$17 = gen(function* () {
56950
56962
  );
56951
56963
  yield* refreshTerminals(threadId, terminals);
56952
56964
  });
56953
- const listModels = gen(function* () {
56965
+ const fetchModels2 = gen(function* () {
56954
56966
  const client2 = yield* getClient(null);
56955
56967
  const models2 = [];
56956
56968
  let cursor = null;
@@ -56972,6 +56984,10 @@ const make$17 = gen(function* () {
56972
56984
  } while (cursor);
56973
56985
  return models2;
56974
56986
  });
56987
+ const listModels = yield* cachedWithTTL(
56988
+ fetchModels2,
56989
+ (exit2) => isSuccess$1(exit2) ? minutes(10) : zero
56990
+ );
56975
56991
  const planLimits2 = (home) => gen(function* () {
56976
56992
  const client2 = yield* getClient(home);
56977
56993
  const raw2 = yield* client2.request("account/rateLimits/read", void 0);
@@ -57113,7 +57129,7 @@ const make$17 = gen(function* () {
57113
57129
  yield* emit({ type: "session_bound", providerSessionId: thread2.id });
57114
57130
  const compacting2 = isCompactCommand(input.prompt);
57115
57131
  const startTurn = gen(function* () {
57116
- const skills = input.prompt.includes("$") ? yield* listSkills2(input.cwd, input.home) : [];
57132
+ const skills = input.prompt.includes("$") ? yield* listSkills2(input.cwd, input.home).pipe(orElseSucceed(() => [])) : [];
57117
57133
  const turnStart = {
57118
57134
  threadId: thread2.id,
57119
57135
  input: [...userInput$1(input.prompt, input.attachments), ...skillInputs(input.prompt, skills)],
@@ -58990,7 +59006,8 @@ const make$16 = gen(function* () {
58990
59006
  const backgroundTaskChanges = yield* unbounded$1();
58991
59007
  const threadOf = (sessionId) => [...threadSessions.entries()].find(([, session]) => session === sessionId)?.[0];
58992
59008
  const setBackgroundTasks = (entry, sessionId, tasks) => {
58993
- if ((entry.backgroundTasks.get(sessionId) ?? []) === tasks) return;
59009
+ const current2 = entry.backgroundTasks.get(sessionId);
59010
+ if (current2 === tasks || current2 === void 0 && tasks.length === 0) return;
58994
59011
  if (tasks.length === 0) entry.backgroundTasks.delete(sessionId);
58995
59012
  else entry.backgroundTasks.set(sessionId, tasks);
58996
59013
  const threadId = threadOf(sessionId);
@@ -59100,7 +59117,7 @@ const make$16 = gen(function* () {
59100
59117
  discard: release2.pipe(andThen(interruptTurn(entry.host, sessionId, turnId)), ignore$1)
59101
59118
  });
59102
59119
  };
59103
- const listModels = gen(function* () {
59120
+ const fetchModels2 = gen(function* () {
59104
59121
  const host = yield* getHost(null);
59105
59122
  const raw2 = yield* host.request("model/list", {}).pipe(mapError(toAgentError));
59106
59123
  const { models: models2 } = yield* decodeUnknownEffect(ModelList$1)(raw2).pipe(
@@ -59108,6 +59125,10 @@ const make$16 = gen(function* () {
59108
59125
  );
59109
59126
  return models2.map(toModelInfo);
59110
59127
  });
59128
+ const listModels = yield* cachedWithTTL(
59129
+ fetchModels2,
59130
+ (exit2) => isSuccess$1(exit2) ? minutes(10) : zero
59131
+ );
59111
59132
  const account2 = (home) => gen(function* () {
59112
59133
  const host = yield* getHost(home);
59113
59134
  const raw2 = yield* host.request("account/read", {}).pipe(mapError(toAgentError));
@@ -59835,7 +59856,11 @@ const makeSettingStore = (schema2, defaults2, { path: path2, own: own2 = {} }) =
59835
59856
  const shared = entries.filter(([key2]) => !ownKeys.has(key2));
59836
59857
  if (shared.length > 0) {
59837
59858
  const stored = yield* readObject(path2);
59838
- yield* writeJson(path2, { ...stored, ...Object.fromEntries(shared) });
59859
+ const next2 = applySettingsPatch(
59860
+ yield* get2,
59861
+ Object.fromEntries(shared)
59862
+ );
59863
+ yield* writeJson(path2, { ...stored, ...Object.fromEntries(shared.map(([key2]) => [key2, next2[key2]])) });
59839
59864
  }
59840
59865
  for (const [key2, file] of ownFiles) {
59841
59866
  if (patch[key2] === void 0) continue;
@@ -60055,7 +60080,7 @@ class MagpieProvider extends Service$1()("hinacode/MagpieProvider") {
60055
60080
  );
60056
60081
  return claudeGatewayEnv(connected, listed ?? { id: model }, fastMode);
60057
60082
  });
60058
- const account2 = () => match$1(connection2, {
60083
+ const account2 = () => match$1(flatMap(connection2, modelsOf), {
60059
60084
  onFailure: () => ({ type: "signedOut" }),
60060
60085
  onSuccess: () => ({ type: "external", service: "magpie" })
60061
60086
  });
@@ -60469,6 +60494,7 @@ const makeAcpClient = (options) => gen(function* () {
60469
60494
  );
60470
60495
  });
60471
60496
  const client2 = {
60497
+ pid: () => child.pid,
60472
60498
  isAlive: () => exitError === void 0,
60473
60499
  request: request2,
60474
60500
  notify: (method2, params2) => sync(() => write({ method: method2, params: params2 })),
@@ -60541,8 +60567,7 @@ const toModelInfos = (setup2, provider, efforts = /* @__PURE__ */ new Map()) =>
60541
60567
  const CLIENT_VERSION = "0.1.0";
60542
60568
  const INITIALIZE_TIMEOUT = seconds(30);
60543
60569
  const INTERRUPT_GRACE = seconds(5);
60544
- const MAX_IMAGE_BYTES = 5 * 1024 * 1024;
60545
- const IMAGE_TYPES = /* @__PURE__ */ new Set(["image/png", "image/jpeg", "image/gif", "image/webp"]);
60570
+ const COMMANDS_WAIT = seconds(5);
60546
60571
  const interruptedEvent = { type: "turn_failed", message: "Turn interrupted" };
60547
60572
  const textBlock = (text2) => ({ type: "text", text: text2 });
60548
60573
  const instructionsBlock = (text2) => ({
@@ -60553,6 +60578,19 @@ const instructionsBlock = (text2) => ({
60553
60578
  const decodeNotification = decodeUnknownOption(SessionNotification);
60554
60579
  const decodeCommands = decodeUnknownOption(AvailableCommandsUpdate);
60555
60580
  const decodePermission = decodeUnknownOption(RequestPermissionParams);
60581
+ const commandsOf = (message2) => {
60582
+ if (message2.kind !== "notification" || message2.method !== "session/update") return void 0;
60583
+ const notification = decodeNotification(message2.params);
60584
+ if (notification._tag === "None") return void 0;
60585
+ const update2 = decodeCommands(notification.value.update);
60586
+ if (update2._tag === "None") return void 0;
60587
+ return update2.value.availableCommands.map((command) => ({
60588
+ trigger: "/",
60589
+ name: command.name,
60590
+ description: command.description ?? "",
60591
+ argumentHint: command.input?.hint ?? ""
60592
+ }));
60593
+ };
60556
60594
  const mcpServers = (input) => [
60557
60595
  {
60558
60596
  type: "http",
@@ -60598,20 +60636,8 @@ const makeAcpProvider = (config2) => gen(function* () {
60598
60636
  const commands2 = /* @__PURE__ */ new Map();
60599
60637
  const runOfSession = (sessionId) => [...runs.values()].find((run2) => run2.sessionId === sessionId);
60600
60638
  const trackCommands = (threadId, message2) => {
60601
- if (message2.kind !== "notification" || message2.method !== "session/update") return;
60602
- const notification = decodeNotification(message2.params);
60603
- if (notification._tag === "None") return;
60604
- const update2 = decodeCommands(notification.value.update);
60605
- if (update2._tag === "None") return;
60606
- commands2.set(
60607
- threadId,
60608
- update2.value.availableCommands.map((command) => ({
60609
- trigger: "/",
60610
- name: command.name,
60611
- description: command.description ?? "",
60612
- argumentHint: command.input?.hint ?? ""
60613
- }))
60614
- );
60639
+ const announced = commandsOf(message2);
60640
+ if (announced !== void 0) commands2.set(threadId, announced);
60615
60641
  };
60616
60642
  const answerUnowned = (client2, message2) => {
60617
60643
  if (message2.kind !== "request") return;
@@ -60669,7 +60695,7 @@ const makeAcpProvider = (config2) => gen(function* () {
60669
60695
  return selector.current === wanted ? void_ : setOption(client2, sessionId, selector.configId, wanted);
60670
60696
  };
60671
60697
  const promptBlocks = (text2, attachments, images) => forEach(attachments, (attachment2) => {
60672
- const fitsImage = images && attachment2.kind === "image" && IMAGE_TYPES.has(attachment2.mime) && attachment2.bytes <= MAX_IMAGE_BYTES;
60698
+ const fitsImage = images && attachment2.kind === "image" && AGENT_IMAGE_TYPES.includes(attachment2.mime) && attachment2.bytes <= AGENT_IMAGE_MAX_BYTES;
60673
60699
  if (!fitsImage) return succeed$1([textBlock(`Attached file: ${attachment2.path}`)]);
60674
60700
  return tryPromise({
60675
60701
  try: () => readFile(attachment2.path),
@@ -60781,6 +60807,10 @@ const makeAcpProvider = (config2) => gen(function* () {
60781
60807
  if (input.home !== null) return yield* agentError2(`${name} runs on its CLI login only`);
60782
60808
  accessModes.set(input.threadId, input.accessMode);
60783
60809
  const { client: client2, capabilities: capabilities2 } = yield* startAgent;
60810
+ yield* acquireRelease(
60811
+ sync(() => registerAgentPid(input.threadId, client2.pid)),
60812
+ (unregister) => sync(unregister)
60813
+ );
60784
60814
  yield* client2.subscribe((message2) => {
60785
60815
  trackCommands(input.threadId, message2);
60786
60816
  answerUnowned(client2, message2);
@@ -60843,7 +60873,23 @@ const makeAcpProvider = (config2) => gen(function* () {
60843
60873
  return probedModels;
60844
60874
  }).pipe(scoped)
60845
60875
  );
60846
- const listCommands = ({ threadId }) => sync(() => commands2.get(threadId) ?? []);
60876
+ const probeCommands2 = (cwd) => gen(function* () {
60877
+ const { client: client2 } = yield* startAgent;
60878
+ const announced = yield* make$1t();
60879
+ yield* client2.subscribe((message2) => {
60880
+ const update2 = commandsOf(message2);
60881
+ if (update2 !== void 0) doneUnsafe(announced, succeed$1(update2));
60882
+ });
60883
+ yield* call2(client2, "session/new", { cwd, mcpServers: [] }, NewSessionResponse);
60884
+ return yield* _await(announced).pipe(
60885
+ timeoutOrElse({ duration: COMMANDS_WAIT, orElse: () => succeed$1([]) })
60886
+ );
60887
+ }).pipe(scoped);
60888
+ const probedCommands = yield* make$1j({ lookup: probeCommands2, capacity: 32, timeToLive: minutes(1) });
60889
+ const listCommands = ({ threadId, cwd }) => suspend(() => {
60890
+ const tracked = commands2.get(threadId);
60891
+ return tracked === void 0 ? get$3(probedCommands, cwd) : succeed$1(tracked);
60892
+ });
60847
60893
  const interrupt2 = (threadId) => suspend(() => {
60848
60894
  const run2 = runs.get(threadId);
60849
60895
  if (run2 === void 0) return void_;
@@ -62404,8 +62450,7 @@ class AgentLogins extends Service$1()("hinacode/AgentLogins") {
62404
62450
  const CachedAccount = fromJsonString(
62405
62451
  Struct({
62406
62452
  accountId: NullOr(String$1),
62407
- account: AgentAccount,
62408
- fetchedAt: String$1
62453
+ account: AgentAccount
62409
62454
  })
62410
62455
  );
62411
62456
  const decodeCached = decodeUnknownEffect(CachedAccount);
@@ -62418,7 +62463,7 @@ const readCached = (path2, accountId) => tryPromise(() => readFile(path2, "utf8"
62418
62463
  );
62419
62464
  const remove = (path2) => tryPromise(() => rm(path2, { force: true })).pipe(ignore$1);
62420
62465
  const writeCached = (path2, accountId, account2) => gen(function* () {
62421
- const content = yield* encodeCached({ accountId, account: account2, fetchedAt: yield* nowIso });
62466
+ const content = yield* encodeCached({ accountId, account: account2 });
62422
62467
  const temp = `${path2}.${process.pid}.tmp`;
62423
62468
  yield* tryPromise(async () => {
62424
62469
  await mkdir(dirname(path2), { recursive: true });
@@ -63006,7 +63051,7 @@ var hasRequiredGracefulFs;
63006
63051
  function requireGracefulFs() {
63007
63052
  if (hasRequiredGracefulFs) return gracefulFs;
63008
63053
  hasRequiredGracefulFs = 1;
63009
- var fs2 = Se__default;
63054
+ var fs2 = Ee__default;
63010
63055
  var polyfills2 = requirePolyfills();
63011
63056
  var legacy = requireLegacyStreams();
63012
63057
  var clone2 = requireClone();
@@ -63833,7 +63878,7 @@ var hasRequiredLockfile;
63833
63878
  function requireLockfile() {
63834
63879
  if (hasRequiredLockfile) return lockfile;
63835
63880
  hasRequiredLockfile = 1;
63836
- const path2 = xe__default;
63881
+ const path2 = Pe__default;
63837
63882
  const fs2 = requireGracefulFs();
63838
63883
  const retry2 = requireRetry();
63839
63884
  const onExit2 = requireSignalExit();
@@ -65515,6 +65560,8 @@ Artifacts:
65515
65560
  - When you make something the user should look at, such as a report, chart, diagram or prototype, publish it with the hinacode \`publish_artifact\` tool instead of writing an HTML file into the repository. Pass \`auto_open: true\` when it is what the user asked for, so it opens beside the thread.
65516
65561
  - To change it, publish again with the id the tool returned.
65517
65562
  - For prose the user may want to edit, such as a plan, spec or checklist, publish a Markdown document with \`publish_document\` instead. The user edits it beside the thread, so pass the revision you last saw when you update it.
65563
+ - \`${artifactMention("<id>")}\` in a user message names an artifact. Call \`read_artifact\` with that id before you act on it.
65564
+ - To point the user at an artifact, write \`${artifactMention("<id>")}\` in your reply. HinaCode turns it into a link that opens it beside the thread.
65518
65565
 
65519
65566
  Scratch directory:
65520
65567
  - Put temporary files, experiments, downloads and throwaway scripts in the scratch directory that \`<environment>\` names, not in \`/tmp\`.
@@ -67016,7 +67063,7 @@ const make$_ = gen(function* () {
67016
67063
  secondaryHits = 0;
67017
67064
  return { body: response2.body, errors: errors2 };
67018
67065
  });
67019
- const auth2 = gh(homedir(), ["auth", "status", "--json", "hosts"]).pipe(
67066
+ const auth2 = ghUnpaused(homedir(), ["auth", "status", "--json", "hosts"]).pipe(
67020
67067
  flatMap(decodeAuthStatus),
67021
67068
  map$2(parseAuthStatus),
67022
67069
  catchTags({
@@ -67384,7 +67431,6 @@ const toPullRequest = ({ url: url2, mergeRequest, approvals: approvals2, diffs }
67384
67431
  });
67385
67432
  const jobStatus = ({ status, allow_failure }) => {
67386
67433
  if (status === "failed" && allow_failure) return "skipped";
67387
- if (NOT_RUN.has(status)) return "skipped";
67388
67434
  return pipelineChecks(status) ?? "skipped";
67389
67435
  };
67390
67436
  const CHECK_RUN_ORDER = { failing: 0, pending: 1, passing: 2, skipped: 3 };
@@ -67456,18 +67502,20 @@ const make$Z = gen(function* () {
67456
67502
  return api2(hostname2, ["version"], { timeout: PROBE_TIMEOUT }).pipe(
67457
67503
  as(true),
67458
67504
  catchTag("GitLabSignedOutError", () => succeed$1(true)),
67459
- orElseSucceed(() => false),
67460
- tap$1((answer) => sync(() => hostAnswers.set(hostname2, answer)))
67505
+ catchTag("GitLabApiError", () => succeed$1(false)),
67506
+ tap$1((answer) => sync(() => hostAnswers.set(hostname2, answer))),
67507
+ orElseSucceed(() => false)
67461
67508
  );
67462
67509
  };
67463
67510
  const viewers = /* @__PURE__ */ new Map();
67464
67511
  const viewer = (hostname2) => {
67465
- if (viewers.has(hostname2)) return succeed$1(viewers.get(hostname2) ?? null);
67512
+ const known = viewers.get(hostname2);
67513
+ if (known !== void 0) return succeed$1(known);
67466
67514
  return api2(hostname2, ["user"]).pipe(
67467
67515
  flatMap(decodeUser),
67468
67516
  map$2((user) => user.username),
67469
- orElseSucceed(() => null),
67470
- tap$1((username) => sync(() => viewers.set(hostname2, username)))
67517
+ tap$1((username) => sync(() => viewers.set(hostname2, username))),
67518
+ orElseSucceed(() => null)
67471
67519
  );
67472
67520
  };
67473
67521
  const readMergeRequest = (mergeRequest) => api2(mergeRequest.hostname, [mergeRequestApi(mergeRequest)]).pipe(flatMap(decodeMergeRequest));
@@ -68713,10 +68761,12 @@ Setup script exited with code ${exitCode}
68713
68761
  const { rootPath } = yield* projects.get(worktree.projectId);
68714
68762
  return yield* sourceControl.branchPullRequest(rootPath, worktree.branch);
68715
68763
  });
68716
- const currentBranch2 = (projectId) => projects.get(projectId).pipe(
68717
- flatMap(({ rootPath }) => git2.run(rootPath, ["rev-parse", "--abbrev-ref", "HEAD"])),
68718
- map$2((output) => output.trim())
68719
- );
68764
+ const currentBranch2 = (projectId) => gen(function* () {
68765
+ const { rootPath } = yield* projects.get(projectId);
68766
+ const branch = (yield* git2.run(rootPath, ["rev-parse", "--abbrev-ref", "HEAD"])).trim();
68767
+ if (branch !== "HEAD") return branch;
68768
+ return (yield* git2.run(rootPath, ["rev-parse", "HEAD"])).trim();
68769
+ });
68720
68770
  const branches = (projectId) => projects.get(projectId).pipe(
68721
68771
  flatMap(
68722
68772
  ({ rootPath }) => git2.run(rootPath, [
@@ -68745,12 +68795,31 @@ Setup script exited with code ${exitCode}
68745
68795
  )
68746
68796
  )
68747
68797
  );
68798
+ const fastForwardDefaultBranch = (projectId, rootPath) => gen(function* () {
68799
+ const upstream = (yield* git2.run(rootPath, ["symbolic-ref", "--quiet", "refs/remotes/origin/HEAD"])).trim();
68800
+ const branch = `refs/heads/${upstream.slice("refs/remotes/origin/".length)}`;
68801
+ const checkedOut = (yield* registeredCheckouts(rootPath)).find((candidate) => candidate.ref === branch);
68802
+ if (checkedOut === void 0) {
68803
+ yield* git2.run(rootPath, ["fetch", "--quiet", ".", `${upstream}:${branch}`]);
68804
+ return;
68805
+ }
68806
+ if (checkedOut.path !== (yield* resolve2(rootPath))) return;
68807
+ const users = yield* findRootUsers(projectId).pipe(mapError(persistence("worktrees.fetch")));
68808
+ if (users.some((thread2) => isThreadBusy(thread2.status))) return;
68809
+ if ((yield* git2.run(rootPath, ["status", "--porcelain"])).trim() !== "") return;
68810
+ yield* git2.run(rootPath, ["merge", "--ff-only", "--quiet", upstream], { timeout: LONG_TIMEOUT });
68811
+ }).pipe(exclusive, ignore$1);
68748
68812
  const fetches = yield* make$1j({
68749
- lookup: (rootPath) => git2.remote(rootPath, ["fetch", "--quiet", "origin"]).pipe(andThen(currentTimeMillis)),
68813
+ lookup: (projectId) => gen(function* () {
68814
+ const { rootPath } = yield* projects.get(projectId);
68815
+ yield* git2.remote(rootPath, ["fetch", "--quiet", "origin"]);
68816
+ yield* fastForwardDefaultBranch(projectId, rootPath);
68817
+ return yield* currentTimeMillis;
68818
+ }),
68750
68819
  capacity: 64,
68751
68820
  timeToLive: FETCH_INTERVAL
68752
68821
  });
68753
- const fetch2 = (projectId) => projects.get(projectId).pipe(flatMap(({ rootPath }) => get$3(fetches, rootPath)));
68822
+ const fetch2 = (projectId) => get$3(fetches, projectId);
68754
68823
  return Worktrees.of({
68755
68824
  list: findAll$1(void 0).pipe(mapError(persistence("worktrees.list"))),
68756
68825
  checkouts,
@@ -69630,7 +69699,7 @@ const suggest$1 = (model, prompt) => gen(function* () {
69630
69699
  try: async (signal2) => {
69631
69700
  const abortController = new AbortController();
69632
69701
  signal2.addEventListener("abort", () => abortController.abort());
69633
- const { query } = await import("./chunks/sdk-BjcPK2t_.js");
69702
+ const { query } = await import("./chunks/sdk-DZclv7I1.js");
69634
69703
  const stream2 = query({
69635
69704
  prompt: `<messages>
69636
69705
  ${firstAndLatest(prompt)}
@@ -69810,15 +69879,13 @@ const make$R = gen(function* () {
69810
69879
  orElseSucceed(() => null)
69811
69880
  );
69812
69881
  const subagentInstructions = (experimental2, environment2) => gen(function* () {
69813
- const [listed, settingsValue] = yield* all$1(
69814
- [all$1(map(providers, listedModels), { concurrency: "unbounded" }), settings.get],
69882
+ const settingsValue = yield* settings.get;
69883
+ const enabled = enabledProviders(settingsValue);
69884
+ const listed = yield* all$1(
69885
+ map(providers, (provider, id2) => enabled.includes(id2) ? listedModels(provider) : succeed$1(null)),
69815
69886
  { concurrency: "unbounded" }
69816
69887
  );
69817
- return agentInstructions(
69818
- experimental2,
69819
- environment2,
69820
- subagentChoices(listed, settingsValue.modelPresets, enabledProviders(settingsValue))
69821
- );
69888
+ return agentInstructions(experimental2, environment2, subagentChoices(listed, settingsValue.modelPresets, enabled));
69822
69889
  });
69823
69890
  const cachedLimits = yield* make$1j({
69824
69891
  lookup: (key2) => {
@@ -69848,7 +69915,6 @@ const make$R = gen(function* () {
69848
69915
  const transcriptSeqs = /* @__PURE__ */ new Map();
69849
69916
  yield* messages.closeInterrupted;
69850
69917
  yield* threads.resetInterrupted;
69851
- const providerFor = (id2) => succeed$1(providers[id2]);
69852
69918
  const updateThread = (input) => threads.update(input).pipe(tap$1((thread2) => push.publish({ type: "thread.updated", thread: thread2 })));
69853
69919
  const removeScheduled = (threadId, id2) => gen(function* () {
69854
69920
  const thread2 = yield* threads.get(threadId);
@@ -70159,7 +70225,7 @@ const make$R = gen(function* () {
70159
70225
  })
70160
70226
  )
70161
70227
  );
70162
- const interrupt2 = gen(function* () {
70228
+ const interrupt22 = gen(function* () {
70163
70229
  yield* succeed$3(stop, void 0);
70164
70230
  yield* provider.interrupt(thread2.id);
70165
70231
  });
@@ -70169,7 +70235,7 @@ const make$R = gen(function* () {
70169
70235
  run: run2,
70170
70236
  follow,
70171
70237
  handle,
70172
- interrupt: interrupt2,
70238
+ interrupt: interrupt22,
70173
70239
  messages: () => turnMessages,
70174
70240
  isFinishing: () => finishing
70175
70241
  };
@@ -70407,7 +70473,7 @@ const make$R = gen(function* () {
70407
70473
  if (thread2.status === "archived") {
70408
70474
  return yield* new AgentError({ provider: "hinacode", message: "Cannot send to an archived thread" });
70409
70475
  }
70410
- const provider = yield* providerFor(thread2.provider);
70476
+ const provider = providers[thread2.provider];
70411
70477
  const home = yield* accounts.home(thread2.accountId);
70412
70478
  const workspace = yield* activeWorkspace(threadId);
70413
70479
  const { cwd, worktreeId } = workspace;
@@ -70885,6 +70951,16 @@ const make$R = gen(function* () {
70885
70951
  return some(yield* whileIdle);
70886
70952
  }).pipe(exclusive(threadId));
70887
70953
  });
70954
+ const interrupt2 = (threadId) => stopBackgroundWork(threadId).pipe(
70955
+ andThen(
70956
+ suspend(() => {
70957
+ const turn = activeTurns.get(threadId);
70958
+ if (turn !== void 0) return turn.interrupt;
70959
+ const pending = pendingSends.get(threadId);
70960
+ return pending === void 0 ? void_ : succeed$3(pending, void 0).pipe(asVoid);
70961
+ })
70962
+ )
70963
+ );
70888
70964
  const requestSecret = (threadId, name, description2) => gen(function* () {
70889
70965
  const turn = activeTurns.get(threadId);
70890
70966
  if (turn === void 0) {
@@ -70916,7 +70992,7 @@ const make$R = gen(function* () {
70916
70992
  const thread2 = yield* threads.get(threadId);
70917
70993
  if (thread2.status === "archived") return;
70918
70994
  if (thread2.sideOf !== null && !(yield* threads.started(threadId))) return;
70919
- const provider = yield* providerFor(thread2.provider);
70995
+ const provider = providers[thread2.provider];
70920
70996
  if (provider.warm === void 0) return;
70921
70997
  const home = yield* accounts.home(thread2.accountId);
70922
70998
  const workspace = yield* activeWorkspace(threadId);
@@ -70937,15 +71013,11 @@ const make$R = gen(function* () {
70937
71013
  switchAgent,
70938
71014
  steer: (threadId, text2, attachments2) => steerWhen({ threadId, text: text2, attachments: attachments2, when: succeed$1(true) }).pipe(asVoid),
70939
71015
  steerWhen,
70940
- interrupt: (threadId) => stopBackgroundWork(threadId).pipe(
70941
- andThen(
70942
- suspend(() => {
70943
- const turn = activeTurns.get(threadId);
70944
- if (turn !== void 0) return turn.interrupt;
70945
- const pending = pendingSends.get(threadId);
70946
- return pending === void 0 ? void_ : succeed$3(pending, void 0).pipe(asVoid);
70947
- })
70948
- )
71016
+ interrupt: interrupt2,
71017
+ stop: (threadId) => interrupt2(threadId).pipe(
71018
+ andThen(get$2(turns, threadId)),
71019
+ flatMap(match({ onNone: () => void_, onSome: await_ })),
71020
+ asVoid
70949
71021
  ),
70950
71022
  isBusy: (threadId) => sync(() => isBusy(threadId)),
70951
71023
  release: release2,
@@ -70989,7 +71061,7 @@ const make$R = gen(function* () {
70989
71061
  );
70990
71062
  return live?.type === "tool_call" && live.output !== void 0 ? succeed$1(live.output) : persisted2;
70991
71063
  },
70992
- listModels: (id2) => providers[id2]?.listModels ?? succeed$1([]),
71064
+ listModels: (id2) => providers[id2].listModels,
70993
71065
  limits: gen(function* () {
70994
71066
  const added = yield* accounts.list;
70995
71067
  const keys2 = Object.values(providers).flatMap(({ id: id2 }) => [
@@ -71063,11 +71135,10 @@ const artifactFeedbackPrompt = ({ artifact: artifact2, comment, elements, mentio
71063
71135
  answerLine(kind, comment)
71064
71136
  ].join("\n");
71065
71137
  };
71066
- const feedbackTargets = (body2, ownerThreadId) => {
71138
+ const feedbackTargets = (body2) => {
71067
71139
  const mentioned = /* @__PURE__ */ new Set();
71068
71140
  for (const [, kind, id2] of body2.matchAll(MENTION)) if (kind === "thread" && id2 !== void 0) mentioned.add(id2);
71069
- if (mentioned.size > 0) return [...mentioned];
71070
- return ownerThreadId === void 0 ? [] : [ownerThreadId];
71141
+ return [...mentioned];
71071
71142
  };
71072
71143
  const MANIFEST = "artifact.json";
71073
71144
  const FEEDBACK = "feedback.json";
@@ -71294,7 +71365,7 @@ const make$P = gen(function* () {
71294
71365
  );
71295
71366
  const recipients = (body2, ownerThreadId) => gen(function* () {
71296
71367
  const owner2 = ownerThreadId === void 0 ? void 0 : yield* threads.get(ownerThreadId).pipe(catch_(() => succeed$1(void 0)));
71297
- const mentioned = yield* filter$3(feedbackTargets(body2, void 0), inProject(owner2?.projectId));
71368
+ const mentioned = yield* filter$3(feedbackTargets(body2), inProject(owner2?.projectId));
71298
71369
  if (mentioned.length > 0) return mentioned;
71299
71370
  return owner2 === void 0 ? [] : [owner2.id];
71300
71371
  });
@@ -73157,6 +73228,7 @@ const make$M = gen(function* () {
73157
73228
  let nextCallId2 = 1;
73158
73229
  let answer = () => succeed$1(notAnswering);
73159
73230
  const now2 = () => clock.currentTimeMillisUnsafe();
73231
+ const nowIso2 = () => new Date(now2()).toISOString();
73160
73232
  const findAll$1 = findAll({
73161
73233
  Request: Void,
73162
73234
  Result: Environment,
@@ -73437,7 +73509,7 @@ const make$M = gen(function* () {
73437
73509
  port,
73438
73510
  relay: relay2,
73439
73511
  source: "pairing",
73440
- createdAt: (/* @__PURE__ */ new Date()).toISOString()
73512
+ createdAt: nowIso2()
73441
73513
  };
73442
73514
  const write = existing2 ? sql`UPDATE environment SET name = ${environment2.name}, host = ${host}, port = ${port}, relay = ${relay2} WHERE id = ${id2}` : sql`INSERT INTO environment ${sql.insert(environment2)}`;
73443
73515
  yield* write.pipe(
@@ -73479,7 +73551,7 @@ const make$M = gen(function* () {
73479
73551
  port,
73480
73552
  relay: relay2,
73481
73553
  source: "relay",
73482
- createdAt: (/* @__PURE__ */ new Date()).toISOString()
73554
+ createdAt: nowIso2()
73483
73555
  };
73484
73556
  yield* sql`INSERT INTO environment ${sql.insert(environment22)}`.pipe(
73485
73557
  andThen(secrets.set(tokenSecret(id2), token)),
@@ -73626,7 +73698,11 @@ const assetMimes = {
73626
73698
  ttf: "font/ttf",
73627
73699
  otf: "font/otf"
73628
73700
  };
73629
- const extensionOf = (name) => name.slice(name.lastIndexOf(".") + 1).toLowerCase();
73701
+ const extensionOf = (path2) => {
73702
+ const name = path2.slice(path2.lastIndexOf("/") + 1);
73703
+ const dot = name.lastIndexOf(".");
73704
+ return dot === -1 ? "" : name.slice(dot + 1).toLowerCase();
73705
+ };
73630
73706
  const previewMimeOf = (name) => previewMimes[extensionOf(name)];
73631
73707
  const mimeOf = (name) => previewMimeOf(name) ?? assetMimes[extensionOf(name)] ?? "application/octet-stream";
73632
73708
  const reasons = {
@@ -87359,16 +87435,17 @@ const make$g = (options) => gen(function* () {
87359
87435
  const { state, live } = await chosen(threadId, device);
87360
87436
  const frame2 = live.latest ?? await newestFrame(live, 0, 5e3);
87361
87437
  if (!frame2) throw new DevicesError({ message: "The device has not sent a frame yet. Try again in a moment." });
87362
- return { frame: frame2, state };
87438
+ return { frame: frame2, state, screen: shownScreen(frame2, state.screen) };
87363
87439
  });
87364
87440
  const pick2 = (input) => attempt2(async () => {
87365
- const { state } = await ready(input.threadId, input.deviceId);
87441
+ const { state, live } = await ready(input.threadId, input.deviceId);
87366
87442
  const elements = await driverOf(state.device.id).describe(state.device.id);
87367
- const x = input.x * state.screen.width;
87368
- const y = input.y * state.screen.height;
87443
+ const screen = live.latest ? shownScreen(live.latest, state.screen) : state.screen;
87444
+ const x = input.x * screen.width;
87445
+ const y = input.y * screen.height;
87369
87446
  const under = elements.filter(
87370
87447
  ({ frame: frame2 }) => x >= frame2.x && x <= frame2.x + frame2.width && y >= frame2.y && y <= frame2.y + frame2.height
87371
- ).filter(({ frame: frame2 }) => frame2.width < state.screen.width || frame2.height < state.screen.height).sort((a, b) => a.frame.width * a.frame.height - b.frame.width * b.frame.height)[0];
87448
+ ).filter(({ frame: frame2 }) => frame2.width < screen.width || frame2.height < screen.height).sort((a, b) => a.frame.width * a.frame.height - b.frame.width * b.frame.height)[0];
87372
87449
  return under ? { device: state.device.name, platform: state.device.platform, element: under } : null;
87373
87450
  });
87374
87451
  const expireLeases = sync(() => {
@@ -87605,6 +87682,8 @@ const readBody = (response2, maxBytes = Number.POSITIVE_INFINITY) => tryPromise(
87605
87682
  message: cause instanceof BodyTooLarge ? `the archive is larger than ${Math.round(maxBytes / 1024 / 1024)} MB` : `The connection to sbx broke: ${describeCause$2(cause)}`
87606
87683
  })
87607
87684
  });
87685
+ const leaveFailuresToClose = () => {
87686
+ };
87608
87687
  const filesPath = (id2, guestPath) => `/v1/sandboxes/${encodeURIComponent(id2)}/files?path=${encodeURIComponent(guestPath)}`;
87609
87688
  const sbxClient = (login) => {
87610
87689
  const base = login.url.replace(/\/+$/, "");
@@ -87724,6 +87803,7 @@ Upgrade: tcp\r
87724
87803
  const code2 = Number(statusLine.split(" ")[1]);
87725
87804
  if (code2 !== 101) return fail2(errorOf2(code2, received.subarray(end2 + 4).toString(), id2));
87726
87805
  cleanup();
87806
+ socket.on("error", leaveFailuresToClose);
87727
87807
  resume(succeed$1({ socket, head: received.subarray(end2 + 4) }));
87728
87808
  };
87729
87809
  const onError2 = (cause) => fail2(new SbxError({ message: `Could not reach sbx at ${base}: ${describeCause$2(cause)}` }));
@@ -88189,7 +88269,7 @@ const boatClient = (input) => {
88189
88269
  if (baseName.length === 0)
88190
88270
  return yield* fail$2(new BoatError({ message: `boat: cannot download ${guestPath}` }));
88191
88271
  const tmpPath = `/tmp/.hinacode-${randomUUID()}.tar`;
88192
- const command = `tar -cf ${shellQuote$1(tmpPath)} -C ${shellQuote$1(parent)} ${shellQuote$1(baseName)} && stat -c%s ${shellQuote$1(tmpPath)}`;
88272
+ const command = `tar -cf ${shellQuote$1(tmpPath)} --format=pax -C ${shellQuote$1(parent)} ${shellQuote$1(baseName)} && stat -c%s ${shellQuote$1(tmpPath)}`;
88193
88273
  const result2 = yield* rawCommand(id2, command);
88194
88274
  if (result2.exitCode !== 0) {
88195
88275
  yield* cleanupGuestFiles(id2, [tmpPath]);
@@ -88726,6 +88806,11 @@ const decodeTar = (bytes) => {
88726
88806
  entries.push({ type: "symlink", path: path2, target: linkTarget, mode: mode2, mtime });
88727
88807
  } else if (typeflag === "0" || typeflag === "\0") {
88728
88808
  entries.push({ type: "file", path: path2, data, mode: mode2, mtime });
88809
+ } else if (typeflag === "1") {
88810
+ const original = entries.find((entry) => entry.type === "file" && entry.path === linkTarget);
88811
+ if (original?.type !== "file")
88812
+ throw new TarError({ message: `hard link "${path2}" points at "${linkTarget}", which is not an earlier file` });
88813
+ entries.push({ type: "file", path: path2, data: original.data, mode: mode2, mtime });
88729
88814
  } else {
88730
88815
  throw new TarError({ message: `unsupported tar entry type "${typeflag}" for "${path2}"` });
88731
88816
  }
@@ -88925,6 +89010,11 @@ const FLUSH_SIZE = 256 * 1024;
88925
89010
  const HAND_BACK_GRACE = "2 seconds";
88926
89011
  const NONE = { status: "none" };
88927
89012
  const toVmError = (error2) => new VmError({ message: error2.message });
89013
+ const releasedThreadOf = (event) => {
89014
+ if (event.type === "thread.removed") return event.id;
89015
+ if (event.type === "thread.updated" && event.thread.status === "archived") return event.thread.id;
89016
+ return void 0;
89017
+ };
88928
89018
  const endGracefully = (socket) => callback((resume) => {
88929
89019
  socket.once("close", () => resume(void_));
88930
89020
  socket.end();
@@ -88950,6 +89040,7 @@ const writeStoredProfile = (dataDir, bytes, template2) => tryPromise({
88950
89040
  const make$e = (source, dataDir, desktopRedirect = true) => gen(function* () {
88951
89041
  const scope2 = yield* scope$1;
88952
89042
  const events2 = yield* Events;
89043
+ const broadcast = yield* PushBroadcast;
88953
89044
  const settings = yield* Settings$1;
88954
89045
  const boatService = yield* serviceOption(Boat);
88955
89046
  const vms = /* @__PURE__ */ new Map();
@@ -89655,8 +89746,6 @@ ${output}` : ""}`
89655
89746
  own2(owner2, streamId);
89656
89747
  buffer2(streamId, screen, head2);
89657
89748
  socket.on("data", (data) => buffer2(streamId, screen, data));
89658
- socket.on("error", () => {
89659
- });
89660
89749
  socket.once("close", () => screenClosed(streamId, screen, owner2));
89661
89750
  }).pipe(ensuring(sync(() => openingScreens.delete(streamId))));
89662
89751
  const sendScreen = (streamId, data) => sync(() => {
@@ -89664,6 +89753,14 @@ ${output}` : ""}`
89664
89753
  if (socket?.writable) socket.write(data);
89665
89754
  });
89666
89755
  const closeScreen = (streamId) => sync(() => screens.get(streamId)?.socket.destroy());
89756
+ const release2 = (threadId) => tryPromise(() => rm(join$1(dataDir, PULLED_DIR, threadId), { recursive: true, force: true })).pipe(
89757
+ catch_((error2) => logWarning("tiny vm: cannot delete pulled files", String(error2))),
89758
+ andThen(stop(threadId))
89759
+ );
89760
+ yield* broadcast.subscribe((event) => {
89761
+ const threadId = releasedThreadOf(event);
89762
+ if (threadId !== void 0) runFork2(release2(threadId));
89763
+ });
89667
89764
  yield* (yield* settings.changes).pipe(
89668
89765
  runForEach(
89669
89766
  (value2) => suspend(() => {
@@ -89963,9 +90060,9 @@ const deviceToolsLayer = DeviceTools.toLayer(
89963
90060
  const devices = yield* Devices;
89964
90061
  const attachments = yield* Attachments;
89965
90062
  const screen = (threadId, device, caption, save = false) => gen(function* () {
89966
- const { frame: frame2, state } = yield* devices.screenshot(threadId, device);
90063
+ const { frame: frame2, state, screen: screen2 } = yield* devices.screenshot(threadId, device);
89967
90064
  const data = Buffer.from(frame2.data, "base64");
89968
- const size2 = `${Math.round(state.screen.width)}×${Math.round(state.screen.height)} points`;
90065
+ const size2 = `${Math.round(screen2.width)}×${Math.round(screen2.height)} points`;
89969
90066
  const about = `${caption} ${state.device.name} (${state.device.id}), ${state.device.osVersion}, screen ${size2}${frame2.orientation === "landscape" ? " (landscape)" : ""}.`;
89970
90067
  const blocks = [{ type: "text", text: about }];
89971
90068
  if (save) {
@@ -89978,9 +90075,9 @@ const deviceToolsLayer = DeviceTools.toLayer(
89978
90075
  blocks.push({ type: "image", data, mimeType: frame2.mime });
89979
90076
  return blocks;
89980
90077
  });
89981
- const at = (threadId, device, x, y) => map$2(devices.screenshot(threadId, device), ({ state }) => ({
89982
- x: Math.min(1, Math.max(0, x / state.screen.width)),
89983
- y: Math.min(1, Math.max(0, y / state.screen.height)),
90078
+ const at = (threadId, device, x, y) => map$2(devices.screenshot(threadId, device), ({ state, screen: screen2 }) => ({
90079
+ x: Math.min(1, Math.max(0, x / screen2.width)),
90080
+ y: Math.min(1, Math.max(0, y / screen2.height)),
89984
90081
  deviceId: state.device.id
89985
90082
  }));
89986
90083
  const actAndLook = (threadId, device, action, input, done2) => gen(function* () {
@@ -94757,7 +94854,7 @@ const analyze = (detail, diff, options) => gen(function* () {
94757
94854
  try: async (signal2) => {
94758
94855
  const abortController = new AbortController();
94759
94856
  signal2.addEventListener("abort", () => abortController.abort());
94760
- const { query } = await import("./chunks/sdk-BjcPK2t_.js");
94857
+ const { query } = await import("./chunks/sdk-DZclv7I1.js");
94761
94858
  const stream2 = query({
94762
94859
  prompt: buildAnalysisPrompt(payload, options.locale),
94763
94860
  options: {
@@ -95570,9 +95667,10 @@ const handlers = {
95570
95667
  flatMap(
95571
95668
  match({
95572
95669
  onNone: () => void_,
95573
- onSome: (sidechat) => AgentRunner.use((runner) => runner.interrupt(sidechat.id))
95670
+ onSome: (sidechat) => AgentRunner.use((runner) => runner.stop(sidechat.id))
95574
95671
  })
95575
95672
  ),
95673
+ andThen(AgentRunner.use((runner) => runner.stop(id2))),
95576
95674
  andThen(closeTerminals(id2)),
95577
95675
  andThen(Threads.use((threads) => threads.remove(id2, { removeWorktree }))),
95578
95676
  andThen(Events.use((events2) => events2.publish({ type: "thread.removed", id: id2 })))
@@ -96501,11 +96599,18 @@ const eventLines = (detail, previous, kind) => {
96501
96599
  }
96502
96600
  }
96503
96601
  };
96504
- const watchMessage = (detail, previous, events2) => [
96602
+ const closingLines = (events2, ended) => {
96603
+ if (events2.includes("mergedOrClosed")) return [];
96604
+ if (ended) return ["Act on this in this thread."];
96605
+ return [
96606
+ "Act on this in this thread. The watch stays on, so the next push, failure, review or comment will be reported here too."
96607
+ ];
96608
+ };
96609
+ const watchMessage = (detail, previous, events2, { ended = false } = {}) => [
96505
96610
  `Pull request watch: news on ${detail.url} (branch ${detail.headRef}, base ${detail.baseRef}).`,
96506
96611
  "",
96507
96612
  ...events2.flatMap((kind) => [...eventLines(detail, previous, kind), ""]),
96508
- "Act on this in this thread. The watch stays on, so the next push, failure, review or comment will be reported here too."
96613
+ ...closingLines(events2, ended)
96509
96614
  ].join("\n").trimEnd();
96510
96615
  const watchStoppedMessage = (url2, reason) => [
96511
96616
  `Pull request watch: watching ${url2} has ended. ${reason}`,
@@ -96595,7 +96700,7 @@ const make$1 = gen(function* () {
96595
96700
  if (!(yield* stillCurrent(link.id, watch2.generation))) return;
96596
96701
  const wakes = watch2.wakes + 1;
96597
96702
  const capped = !terminal2 && wakes >= MAX_WAKES;
96598
- const text2 = capped ? `${watchMessage(detail, watch2.snapshot, events2)}
96703
+ const text2 = capped ? `${watchMessage(detail, watch2.snapshot, events2, { ended: true })}
96599
96704
 
96600
96705
  Watching has ended after ${MAX_WAKES} updates. Call the hinacode \`watch_pull_request\` tool to watch it again.` : watchMessage(detail, watch2.snapshot, events2);
96601
96706
  if (!(yield* wake(link, watch2.generation, text2))) {
@@ -97200,7 +97305,7 @@ function requireTlsHelpers() {
97200
97305
  Object.defineProperty(tlsHelpers, "__esModule", { value: true });
97201
97306
  tlsHelpers.CIPHER_SUITES = void 0;
97202
97307
  tlsHelpers.getDefaultRootsData = getDefaultRootsData;
97203
- const fs2 = Se__default;
97308
+ const fs2 = Ee__default;
97204
97309
  tlsHelpers.CIPHER_SUITES = process.env.GRPC_SSL_CIPHER_SUITES;
97205
97310
  const DEFAULT_ROOTS_FILE_PATH = process.env.GRPC_DEFAULT_SSL_ROOTS_FILE_PATH;
97206
97311
  let defaultRootsData = null;
@@ -108558,8 +108663,8 @@ function requireUtil() {
108558
108663
  hasRequiredUtil = 1;
108559
108664
  Object.defineProperty(util, "__esModule", { value: true });
108560
108665
  util.addCommonProtos = util.loadProtosWithOptionsSync = util.loadProtosWithOptions = void 0;
108561
- const fs2 = Se__default;
108562
- const path2 = xe__default;
108666
+ const fs2 = Ee__default;
108667
+ const path2 = Pe__default;
108563
108668
  const Protobuf = requireProtobufjs();
108564
108669
  function addIncludePathResolver(root2, includePaths) {
108565
108670
  const originalResolvePath = root2.resolvePath;
@@ -117715,7 +117820,7 @@ function requireCertificateProvider() {
117715
117820
  hasRequiredCertificateProvider = 1;
117716
117821
  Object.defineProperty(certificateProvider, "__esModule", { value: true });
117717
117822
  certificateProvider.FileWatcherCertificateProvider = void 0;
117718
- const fs2 = Se__default;
117823
+ const fs2 = Ee__default;
117719
117824
  const logging2 = requireLogging();
117720
117825
  const constants_1 = requireConstants();
117721
117826
  const util_1 = require$$0;
@@ -120305,6 +120410,7 @@ const frameReader = (onFrame, onCorrupt) => {
120305
120410
  const makeIosDriver = (options) => {
120306
120411
  let developerDir;
120307
120412
  let helper;
120413
+ const orientations = /* @__PURE__ */ new Map();
120308
120414
  const xcodeDeveloperDir = () => developerDir ??= run("xcode-select", ["-p"]).then(
120309
120415
  (stdout) => stdout.toString().trim(),
120310
120416
  (error2) => {
@@ -120399,7 +120505,8 @@ const makeIosDriver = (options) => {
120399
120505
  if (line.startsWith("touch down")) lastTouchDown = lastInput;
120400
120506
  }
120401
120507
  };
120402
- let orientation = PORTRAIT;
120508
+ let orientation = orientations.get(id2) ?? PORTRAIT;
120509
+ if (orientation !== PORTRAIT) await input(`rotate ${orientation}`);
120403
120510
  const shownPoints = () => shown2 ?? (orientation === PORTRAIT ? { width: screen.width, height: screen.height } : { width: screen.height, height: screen.width });
120404
120511
  let scroll = null;
120405
120512
  const endScroll = async () => {
@@ -120451,6 +120558,7 @@ const makeIosDriver = (options) => {
120451
120558
  }
120452
120559
  case "rotate":
120453
120560
  orientation = orientation === PORTRAIT ? LANDSCAPE_LEFT : PORTRAIT;
120561
+ orientations.set(id2, orientation);
120454
120562
  return input(`rotate ${orientation}`);
120455
120563
  case "posture":
120456
120564
  return input(`hinge ${HINGE_DEGREES[command.posture]}`);