hinacode 0.3.0-alpha.4 → 0.3.0-alpha.5
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/out/server/chunks/{remote-B2NssK2N.js → remote-D8e1VZmR.js} +348 -294
- package/out/server/cli.js +1 -1
- package/out/server/daemon.js +701 -202
- package/package.json +1 -1
package/out/server/daemon.js
CHANGED
|
@@ -7,7 +7,7 @@ import { createRequire } from "node:module";
|
|
|
7
7
|
import { homedir, networkInterfaces, tmpdir, userInfo, hostname, loadavg, cpus, totalmem } from "node:os";
|
|
8
8
|
import path__default, { sep, join as join$1, 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, 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$1l, R as Reference, c0 as strictEqual, e as hasProperty, c1 as fromIterable$2, c2 as PipeInspectableProto, c3 as array$2, c4 as make$1m, 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$1n, 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$1o, 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, 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, a$ as all$1, 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$1p, 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, aD as Struct, ba as NullOr, dW as FileSystem, dX as orElseSucceed, dY as chatFolder, dZ as ProjectKind, b5 as promise$1, aT as callback, d_ as sleep$3, d$ as forkDetach, e0 as succeed$3, e1 as loginCommand, e2 as decodeUnknownOption, an as isNone, e3 as Boolean$1, aL as fromJsonString, L as Literal, e4 as Unknown, e5 as toArray, aJ as seconds, f as optionalKey, aO as unbounded$1, e6 as minutes, e7 as cachedWithTTL, e8 as addFinalizer$1, e9 as acquireUseRelease, ea as callback$1, eb as offer, bf as tryPromise, ec as withPermit, ed as toAsyncIterable, ee as timeout, aP as endUnsafe, ef as ignore$1, eg as shutdownUnsafe, bc as try_$1, eh as forkIn, ei as fromAsyncIterable, ej as runForEach, ek as pretty, el as ensuring$1, em as currentTimeMillis, en as sum, eo as CLAUDE_EFFORT_LEVELS, ep as publishedArtifactId, eq as PUBLISH_DOCUMENT_TOOL, er as PUBLISH_ARTIFACT_TOOL, es as isDone, et as empty$6, eu as succeed$4, ev as fromIterable$3, ew as flatMap$2, ex as interruptWhen, ey as concat, ez as fromEffectDrain, eA as fromIterableEffect, eB as fromEffect, eC as suspend$1, eD as unlistedModel, eE as tap$2, eF as make$1q, eG as tick, eH as map$5, eI as drop, eJ as merge$4, eK as onInterrupt, aS as timeoutOrElse, eL as format$3, eM as getOrNull, eN as Record, eO as make$1r, eP as make$1s, aa as take, eQ as join$2, ab as raceFirst, eR as end, eS as forkScoped, eT as isObject$2, J as getOrElse, eU as logWarning, eV as repeat, eW as option, eX as delay, eY as effectContext, aA as make$1t, eZ as provide$2, e_ as monotonicTimeNanos, e$ as retry$3, f0 as spaced, f1 as die$1, f2 as PRIVATE_NETWORKS, f3 as effectDiscard, f4 as provideMerge, f5 as UpdatableProviderId, f6 as decodeUnknownSync, f7 as spawnsSubagent, f8 as isPublishArtifactTool, f9 as outputText, fa as publishedArtifact, fb as toolArgument, fc as isPublishDocumentTool, fd as subscribe, fe as fromSubscription, ff as publish, fg as defaultSettings, fh as Settings$1, fi as AgentProfile, fj as Void, fk as AccountProviderId, fl as filter$1, fm as AgentAccount, fn as commonjsGlobal, fo as isRunAgentTool, b4 as ProviderId, fp as presetModels, fq as encodeSync, ao as succeed$5, fr as mergeAll, b9 as PushEvent, fs as filter$2, ft as take$1, fu as runDrain, fv as forever, fw as never$1, fx as min, l as logError, fy as ChildProcessSpawner, fz as make$1u, fA as mkString, fB as decodeText$1, fC as ForkPoint, fD as TokenUsage, fE as MessagePart, fF as Message, fG as sliding, fH as PullRequestComment, fI as DiffSide, fJ as omit$1, fK as subtract, fL as PULL_REQUEST_REFRESH, ae as catchTags, fM as parseGitHubRepository, fN as parseGitHubPullRequestUrl, I as Int, fO as request$2, fP as Class, fQ as ProjectAction, fR as Project, fS as BooleanFromBit, fT as Worktree, fU as timeoutOption, be as isThreadBusy, bb as ThreadStatus, fV as ScheduledMessage, fW as QueuedMessage, fX as UsageLimit, aH as Thread, fY as PullRequestWatch, fZ as PullRequestLink, f_ as PullRequestStatus, f$ as allWatchEventKinds, g0 as transcriptThreadId, g1 as resumeGraceMs, g2 as fail$3, g3 as WAIT_AGENT_TOOL, bh as tapError, g4 as isMaxLength, g5 as schedule, aR as RpcMethods, g6 as BrowserFrame, g7 as PagePick, g8 as defaultClientSettings, g9 as ClientSettings$1, ga as parsePairingUrl, gb as pairingUrl, gc as Environment, ah as getOrUndefined$1, az as result$1, gd as relayWebSocketUrl, ge as remoteWebSocketUrl, aW as WebSocket, aM as ServerFrame, gf as CHALLENGE_WAIT_MS, aU as methodKind, gg as race, gh as dialPlan, gi as REMOTE_PROTOCOL_VERSION, gj as DIRECT_CHECK_INTERVAL_MS, gk as DIRECT_CHECK_TIMEOUT_MS, gl as LinearIssue, gm as externalSpan, af as fromUndefinedOr, gn as zero$1, go as fromInput$2, gp as badArgument, gq as isSchemaError, gr as isNoSuchElementError, gs as StackTrace, gt as mapEager, gu as updateContext$1, gv as makeUnsafe$9, gw as tag$2, gx as Error$2, gy as fromInputUnsafe$1, gz as Path, gA as run$6, gB as mebibytes, gC as Class$1, gD as constFalse, gE as withLogSpan, gF as log, gG as Tracer, gH as nativeTracer, gI as hasInterrupts$1, gJ as succeed$6, gK as setStackTraceLimit, gL as fail$4, gM as getStackTraceLimit, gN as fiberEnterUninterruptibleUnsafe, gO as contA, gP as effectIsExit, gQ as closeUnsafe, gR as contE, gS as reportCauseUnsafe, gT as matchCauseEffectEager, gU as flatMapEager, gV as fromReadable, gW as toArrayBuffer, G as cached$1, gX as layer$T, gY as pipeThroughDuplex, gZ as toUint8Array, bj as layer$U, b0 as fromResult, g_ as WebSocketServer, g$ as orDie$1, h0 as runForEachArray, h1 as interruptible, h2 as die$2, h3 as merge$5, h4 as succeedContext, h5 as unwrap$1, h6 as withFiberSucceed, h7 as reverse, h8 as getOrUndefinedUnsafe, h9 as CurrentMemoMap, a0 as empty$7, ha as fiberEnterInterruptibleUnsafe, hb as compose$1, hc as Timestamp, hd as AutomationTrigger, he as AutomationRun, hf as isPolledTrigger, hg as launch, s as squash, hh as Duration, hi as DateTimeUtc, hj as withConstructorDefault, hk as withDecodingDefault, hl as Redacted, hm as Tuple$1, hn as isRedacted, ho as MutableJson, ag as isNotUndefined, hp as Never, ak as empty$8, hq as toJsonSchemaDocument, hr as annotateCurrentSpan, hs as isUndefined, ht as failCause$2, hu as forkChild, hv as catch_$1, hw as isSchemaError$1, hx as failCause$3, hy as mapEffect, hz as onEnd, hA as isSchema, aQ as encodeUnknownEffect, hB as annotate, hC as fail$5, hD as make$1v, hE as declare, hF as isStream, hG as Class$2, hH as Exit, bi as provide$3, hI as provideContext$1, hJ as StructWithRest, hK as Opaque, hL as decodeTo, hM as transformOptional, hN as flatMap$3, hO as toType, hP as Any, hQ as UndefinedOr, hR as Finite, hS as passthrough, hT as JsonObject$3, hU as Uint8ArrayFromBase64, hV as Json, hW as TemplateLiteral, hX as decode$3, hY as withDefault, hZ as isBetween, W as taggedEnum, h_ as take$2, h$ as toCodecJson, i0 as isNullish, i1 as isString, i2 as bounded, i3 as withParentSpan, i4 as die$3, i5 as offerAll, i6 as interrupt$2, i7 as interruptors, i8 as decodeSync, i9 as catchCauseIf, ia as NonEmptyArray, ib as decode$4, ic as decodeUnknownResult, id as fn, ie as isTagged, ig as isReadonlyObject, ih as IllegalArgumentError, ii as encode$1, ij as collect, ik as catchDone, il as takeAll, im as fromArray, io as whileLoop, ip as isExit, iq as matchEffect, ir as defaultFormatter, is as logFatal, it as isDeferred, iu as hasDies, c as constVoid, iv as shutdown, iw as Scheduler, ix as CurrentLogLevel, q as is$2, iy as decodeEffect, iz as UnknownFromJsonString, iA as ignoreCause, iB as Class$3, iC as TaggedStruct, iD as toEncoded, iE as when$2, iF as threadDeviceId, iG as devicePlatformOf, ap as value$2, M as match$1, iH as runLast, iI as fromOption, iJ as RUN_AGENT_TOOL, iK as ARTIFACT_THEME_GUIDE, iL as DeviceUrl, iM as DeviceApp, iN as DeviceButton, iO as WatchEventKind, iP as isPattern, iQ as RelayHostList, iR as RelayMachineList, iS as GuideGroup, iT as PullRequestGuide, iU as uninterruptible, iV as diskFullness, iW as min$1, iX as exponential, iY as desktopOnlyPushes, iZ as reachesPhone, i_ as mutations, i$ as desktopOnlyMethods, j0 as isAddressNotUpYet, j1 as ClientFrame, aY as REMOTE_MAX_FRAME_BYTES, aX as REMOTE_PATH, j2 as empty$9, a_ as cliSocketPath, j3 as BindHost, j4 as take$3, j5 as getAugmentedNamespace, j6 as make$1w, j7 as NativeSpan, j8 as currentTimeNanos, aC as MinimumLogLevel, j9 as isPortInUse } from "./chunks/remote-B2NssK2N.js";
|
|
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, 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$1l, R as Reference, c0 as strictEqual, e as hasProperty, c1 as fromIterable$2, c2 as PipeInspectableProto, c3 as array$2, c4 as make$1m, 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$1n, 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$1o, 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, 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, a$ as all$1, 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$1p, 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, b5 as promise$1, 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, aO as unbounded$1, e8 as minutes, e9 as cachedWithTTL, ea as addFinalizer$1, eb as acquireUseRelease, ec as callback$1, ed as offer, bf as tryPromise, ee as withPermit, ef as toAsyncIterable, eg as timeout, aP as endUnsafe, eh as shutdownUnsafe, bc as try_$1, ei as forkIn, ej as fromAsyncIterable, ek as runForEach, el as pretty, em as ensuring$1, en as currentTimeMillis, eo as sum, ep as CLAUDE_EFFORT_LEVELS, eq as publishedArtifactId, er as PUBLISH_DOCUMENT_TOOL, es as PUBLISH_ARTIFACT_TOOL, et as isDone, eu as empty$6, ev as succeed$4, ew as fromIterable$3, ex as flatMap$2, ey as interruptWhen, ez as concat, eA as fromEffectDrain, eB as fromIterableEffect, eC as fromEffect, eD as suspend$1, eE as unlistedModel, eF as tap$2, eG as make$1q, eH as tick, eI as map$5, eJ as drop, eK as merge$4, eL as onInterrupt, aS as timeoutOrElse, eM as format$3, eN as getOrNull, eO as Record, eP as make$1r, eQ as make$1s, aa as take, eR as join$2, ab as raceFirst, eS as end, eT as forkScoped, eU as isObject$2, J as getOrElse, eV as repeat, eW as option, eX as delay, eY as effectContext, aA as make$1t, eZ as provide$2, e_ as monotonicTimeNanos, e$ as retry$3, f0 as spaced, f1 as die$1, f2 as PRIVATE_NETWORKS, f3 as effectDiscard, f4 as provideMerge, f5 as UpdatableProviderId, f6 as decodeUnknownSync, f7 as spawnsSubagent, f8 as isPublishArtifactTool, f9 as outputText, fa as publishedArtifact, fb as toolArgument, fc as isPublishDocumentTool, fd as subscribe, fe as fromSubscription, ff as publish, fg as defaultSettings, fh as Settings$1, fi as AgentProfile, fj as Void, fk as AccountProviderId, fl as filter$1, fm as AgentAccount, fn as commonjsGlobal, fo as isRunAgentTool, b4 as ProviderId, fp as presetModels, fq as encodeSync, ao as succeed$5, fr as mergeAll, b9 as PushEvent, fs as filter$2, ft as take$1, fu as runDrain, fv as forever, fw as never$1, fx as min, l as logError, fy as ChildProcessSpawner, fz as make$1u, fA as mkString, fB as decodeText$1, fC as ForkPoint, fD as TokenUsage, fE as MessagePart, fF as Message, fG as sliding, fH as PullRequestReviewer, fI as PullRequestLabel, fJ as PullRequestComment, fK as DiffSide, fL as omit$1, fM as subtract, fN as PULL_REQUEST_REFRESH, ae as catchTags, fO as parseGitHubRepository, fP as parseGitHubPullRequestUrl, I as Int, fQ as request$2, fR as Class, fS as ProjectAction, fT as Project, fU as BooleanFromBit, fV as Worktree, fW as timeoutOption, be as isThreadBusy, bb as ThreadStatus, fX as ScheduledMessage, fY as QueuedMessage, fZ as UsageLimit, aH as Thread, f_ as getOrThrow$1, f$ as PullRequestWatch, g0 as PullRequestLink, g1 as PullRequestStatus, g2 as allWatchEventKinds, g3 as transcriptThreadId, g4 as resumeGraceMs, g5 as fail$3, g6 as WAIT_AGENT_TOOL, bh as tapError, g7 as isMaxLength, g8 as schedule, aR as RpcMethods, g9 as BrowserFrame, ga as PagePick, gb as defaultClientSettings, gc as ClientSettings$1, gd as parsePairingUrl, ge as pairingUrl, gf as Environment, ah as getOrUndefined$1, az as result$1, gg as relayWebSocketUrl, gh as remoteWebSocketUrl, aW as WebSocket, aM as ServerFrame, gi as CHALLENGE_WAIT_MS, aU as methodKind, gj as race, gk as dialPlan, gl as REMOTE_PROTOCOL_VERSION, gm as DIRECT_CHECK_INTERVAL_MS, gn as DIRECT_CHECK_TIMEOUT_MS, go as LinearIssue, gp as externalSpan, af as fromUndefinedOr, gq as zero$1, gr as fromInput$2, gs as badArgument, gt as isSchemaError, gu as isNoSuchElementError, gv as StackTrace, gw as mapEager, gx as updateContext$1, gy as makeUnsafe$9, gz as tag$2, gA as Error$2, gB as fromInputUnsafe$1, gC as Path, gD as run$6, gE as mebibytes, gF as Class$1, gG as constFalse, gH as withLogSpan, gI as log, gJ as Tracer, gK as nativeTracer, gL as hasInterrupts$1, gM as succeed$6, gN as setStackTraceLimit, gO as fail$4, gP as getStackTraceLimit, gQ as fiberEnterUninterruptibleUnsafe, gR as contA, gS as effectIsExit, gT as closeUnsafe, gU as contE, gV as reportCauseUnsafe, gW as matchCauseEffectEager, gX as flatMapEager, gY as fromReadable, gZ as toArrayBuffer, G as cached$1, g_ as layer$T, g$ as pipeThroughDuplex, h0 as toUint8Array, bj as layer$U, b0 as fromResult, h1 as WebSocketServer, h2 as orDie$1, h3 as runForEachArray, h4 as interruptible, h5 as die$2, h6 as merge$5, h7 as succeedContext, h8 as unwrap$1, h9 as withFiberSucceed, ha as reverse, hb as getOrUndefinedUnsafe, hc as CurrentMemoMap, a0 as empty$7, hd as fiberEnterInterruptibleUnsafe, he as compose$1, hf as Timestamp, hg as AutomationTrigger, hh as AutomationRun, hi as isPolledTrigger, hj as launch, s as squash, hk as Duration, hl as DateTimeUtc, hm as withConstructorDefault, hn as withDecodingDefault, ho as Redacted, hp as Tuple$1, hq as isRedacted, hr as MutableJson, ag as isNotUndefined, hs as Never, ak as empty$8, ht as toJsonSchemaDocument, hu as annotateCurrentSpan, hv as isUndefined, hw as failCause$2, hx as forkChild, hy as catch_$1, hz as isSchemaError$1, hA as failCause$3, hB as mapEffect, hC as onEnd, hD as isSchema, aQ as encodeUnknownEffect, hE as annotate, hF as fail$5, hG as make$1v, hH as declare, hI as isStream, hJ as Class$2, hK as Exit, bi as provide$3, hL as provideContext$1, hM as StructWithRest, hN as Opaque, hO as decodeTo, hP as transformOptional, hQ as flatMap$3, hR as toType, hS as Any, hT as UndefinedOr, hU as Finite, hV as passthrough, hW as JsonObject$3, hX as Uint8ArrayFromBase64, hY as Json, hZ as TemplateLiteral, h_ as decode$3, h$ as withDefault, i0 as isBetween, W as taggedEnum, i1 as take$2, i2 as toCodecJson, i3 as isNullish, i4 as isString, i5 as bounded, i6 as withParentSpan, i7 as die$3, i8 as offerAll, i9 as interrupt$2, ia as interruptors, ib as decodeSync, ic as catchCauseIf, id as NonEmptyArray, ie as decode$4, ig as decodeUnknownResult, ih as fn, ii as isTagged, ij as isReadonlyObject, ik as IllegalArgumentError, il as encode$1, im as collect, io as catchDone, ip as takeAll, iq as fromArray, ir as whileLoop, is as isExit, it as matchEffect, iu as defaultFormatter, iv as logFatal, iw as isDeferred, ix as hasDies, c as constVoid, iy as shutdown, iz as Scheduler, iA as CurrentLogLevel, q as is$2, iB as decodeEffect, iC as UnknownFromJsonString, iD as ignoreCause, iE as Class$3, iF as TaggedStruct, iG as toEncoded, iH as when$2, iI as threadDeviceId, iJ as devicePlatformOf, ap as value$2, M as match$1, iK as runLast, iL as fromOption, iM as RUN_AGENT_TOOL, iN as ARTIFACT_THEME_GUIDE, iO as DeviceUrl, iP as DeviceApp, iQ as DeviceButton, iR as WatchEventKind, iS as isPattern, iT as RelayHostList, iU as RelayMachineList, iV as GuideGroup, iW as PullRequestGuide, iX as uninterruptible, iY as flatten$1, iZ as diskFullness, i_ as min$1, i$ as exponential, j0 as desktopOnlyPushes, j1 as reachesPhone, j2 as mutations, j3 as desktopOnlyMethods, j4 as isAddressNotUpYet, j5 as ClientFrame, aY as REMOTE_MAX_FRAME_BYTES, aX as REMOTE_PATH, j6 as empty$9, a_ as cliSocketPath, j7 as BindHost, j8 as take$3, j9 as getAugmentedNamespace, ja as make$1w, jb as NativeSpan, jc as currentTimeNanos, aC as MinimumLogLevel, jd as isPortInUse } from "./chunks/remote-D8e1VZmR.js";
|
|
11
11
|
import Se__default from "fs";
|
|
12
12
|
import require$$0 from "util";
|
|
13
13
|
import require$$1$1 from "stream";
|
|
@@ -7746,6 +7746,14 @@ class ProjectFolderNotEmptyError extends TaggedError$1()(
|
|
|
7746
7746
|
return `${this.rootPath} already holds other files`;
|
|
7747
7747
|
}
|
|
7748
7748
|
}
|
|
7749
|
+
class ProjectCloneCancelledError extends TaggedError$1()(
|
|
7750
|
+
"ProjectCloneCancelledError",
|
|
7751
|
+
{ rootPath: String$1 }
|
|
7752
|
+
) {
|
|
7753
|
+
get message() {
|
|
7754
|
+
return `Cancelled cloning into ${this.rootPath}`;
|
|
7755
|
+
}
|
|
7756
|
+
}
|
|
7749
7757
|
class UnknownRootError extends TaggedError$1()("UnknownRootError", {
|
|
7750
7758
|
root: String$1
|
|
7751
7759
|
}) {
|
|
@@ -7818,15 +7826,17 @@ class WorktreeBusyError extends TaggedError$1()("WorktreeBusyError", {
|
|
|
7818
7826
|
}
|
|
7819
7827
|
}
|
|
7820
7828
|
const persistence = (operation) => (cause) => new PersistenceError({ operation, cause });
|
|
7821
|
-
const
|
|
7829
|
+
const workspaceFields = {
|
|
7822
7830
|
cwd: String$1,
|
|
7823
7831
|
rootPath: String$1,
|
|
7824
7832
|
worktreeId: NullOr(String$1),
|
|
7825
7833
|
baseRef: NullOr(String$1),
|
|
7826
7834
|
branch: NullOr(String$1)
|
|
7827
|
-
}
|
|
7835
|
+
};
|
|
7836
|
+
Struct({ ...workspaceFields, worktreeRemoved: Boolean$1 });
|
|
7828
7837
|
const WorkspaceRow = Struct({
|
|
7829
|
-
...
|
|
7838
|
+
...workspaceFields,
|
|
7839
|
+
assignedWorktreeId: NullOr(String$1),
|
|
7830
7840
|
kind: ProjectKind,
|
|
7831
7841
|
folderOwner: String$1
|
|
7832
7842
|
});
|
|
@@ -7845,7 +7855,7 @@ const makeActiveWorkspace = gen(function* () {
|
|
|
7845
7855
|
Result: WorkspaceRow,
|
|
7846
7856
|
execute: (threadId) => sql`
|
|
7847
7857
|
SELECT COALESCE(worktree.path, project.root_path) AS cwd, project.root_path, project.kind, worktree.id AS worktree_id, worktree.base_ref, worktree.branch,
|
|
7848
|
-
COALESCE(thread.side_of, thread.id) AS folder_owner
|
|
7858
|
+
thread.worktree_id AS assigned_worktree_id, COALESCE(thread.side_of, thread.id) AS folder_owner
|
|
7849
7859
|
FROM thread
|
|
7850
7860
|
JOIN project ON project.id = thread.project_id
|
|
7851
7861
|
LEFT JOIN worktree ON worktree.id = thread.worktree_id AND worktree.status != 'removed'
|
|
@@ -7857,7 +7867,8 @@ const makeActiveWorkspace = gen(function* () {
|
|
|
7857
7867
|
flatMap(
|
|
7858
7868
|
match({
|
|
7859
7869
|
onNone: () => fail$2(new NotFoundError({ entity: "thread", id: threadId })),
|
|
7860
|
-
onSome: ({ kind, folderOwner, ...
|
|
7870
|
+
onSome: ({ kind, folderOwner, assignedWorktreeId, ...row }) => {
|
|
7871
|
+
const workspace = { ...row, worktreeRemoved: assignedWorktreeId !== null && row.worktreeId === null };
|
|
7861
7872
|
const folder = chatFolder(workspace.rootPath, folderOwner);
|
|
7862
7873
|
return succeed$1(kind === "chats" ? { ...workspace, cwd: folder, rootPath: folder } : workspace);
|
|
7863
7874
|
}
|
|
@@ -8003,7 +8014,7 @@ const belongsToWorkspace = ({
|
|
|
8003
8014
|
}) => (proc) => {
|
|
8004
8015
|
if (proc.pid === selfPid || agentPids.has(proc.pid)) return false;
|
|
8005
8016
|
if (proc.ancestors.some((pid) => agentPids.has(pid))) return true;
|
|
8006
|
-
if (proc.ancestors.includes(selfPid)) return false;
|
|
8017
|
+
if (proc.ancestors.includes(selfPid) || workspacePath === null) return false;
|
|
8007
8018
|
return proc.cwd !== null && isInside$1(proc.cwd, workspacePath);
|
|
8008
8019
|
};
|
|
8009
8020
|
const agentPidsByThread = /* @__PURE__ */ new Map();
|
|
@@ -8034,22 +8045,24 @@ const signal = (pid, name) => {
|
|
|
8034
8045
|
};
|
|
8035
8046
|
class Ports extends Service$1()("hinacode/Ports") {
|
|
8036
8047
|
}
|
|
8037
|
-
const
|
|
8038
|
-
const listening2 = yield* scanListening((proc) => proc.pid === pid);
|
|
8039
|
-
if (listening2.length === 0) {
|
|
8040
|
-
return yield* new PortsError({ message: `Process ${pid} is not listening on a port` });
|
|
8041
|
-
}
|
|
8048
|
+
const terminate = (pid) => gen(function* () {
|
|
8042
8049
|
if (!signal(pid, "SIGTERM")) return yield* new PortsError({ message: `Could not stop process ${pid}` });
|
|
8043
8050
|
yield* sleep$3(KILL_GRACE).pipe(
|
|
8044
8051
|
andThen(sync(() => signal(pid, 0) && signal(pid, "SIGKILL"))),
|
|
8045
8052
|
forkDetach
|
|
8046
8053
|
);
|
|
8047
8054
|
});
|
|
8055
|
+
const kill = (pid) => gen(function* () {
|
|
8056
|
+
const listening2 = yield* scanListening((proc) => proc.pid === pid);
|
|
8057
|
+
if (listening2.length === 0) {
|
|
8058
|
+
return yield* new PortsError({ message: `Process ${pid} is not listening on a port` });
|
|
8059
|
+
}
|
|
8060
|
+
yield* terminate(pid);
|
|
8061
|
+
});
|
|
8048
8062
|
const make$15 = gen(function* () {
|
|
8049
8063
|
const activeWorkspace = yield* makeActiveWorkspace;
|
|
8050
|
-
const
|
|
8051
|
-
const
|
|
8052
|
-
const workspacePath = yield* promise$1(() => realpath(workspace.cwd).catch(() => workspace.cwd));
|
|
8064
|
+
const listListening = (threadId, workspaceCwd) => gen(function* () {
|
|
8065
|
+
const workspacePath = workspaceCwd === null ? null : yield* promise$1(() => realpath(workspaceCwd).catch(() => workspaceCwd));
|
|
8053
8066
|
const listening2 = yield* scanListening(
|
|
8054
8067
|
belongsToWorkspace({
|
|
8055
8068
|
workspacePath,
|
|
@@ -8059,7 +8072,19 @@ const make$15 = gen(function* () {
|
|
|
8059
8072
|
);
|
|
8060
8073
|
return listening2.map(({ port, pid, command, cwd }) => ({ port, pid, command, cwd }));
|
|
8061
8074
|
});
|
|
8062
|
-
|
|
8075
|
+
const listForThread = (threadId) => activeWorkspace(threadId).pipe(flatMap((workspace) => listListening(threadId, workspace.cwd)));
|
|
8076
|
+
const listOwnedByThread = (threadId) => activeWorkspace(threadId).pipe(
|
|
8077
|
+
flatMap((workspace) => listListening(threadId, workspace.worktreeRemoved ? null : workspace.cwd))
|
|
8078
|
+
);
|
|
8079
|
+
const closeThread = (threadId) => listOwnedByThread(threadId).pipe(
|
|
8080
|
+
flatMap(
|
|
8081
|
+
(ports) => forEach(new Set(ports.map((port) => port.pid)), (pid) => terminate(pid).pipe(ignore$1), {
|
|
8082
|
+
discard: true
|
|
8083
|
+
})
|
|
8084
|
+
),
|
|
8085
|
+
catch_((error2) => logWarning("could not stop the ports of a thread", threadId, error2))
|
|
8086
|
+
);
|
|
8087
|
+
return Ports.of({ listForThread, kill, closeThread });
|
|
8063
8088
|
});
|
|
8064
8089
|
const layer$R = effect(Ports, make$15);
|
|
8065
8090
|
var index_min = {};
|
|
@@ -8466,9 +8491,6 @@ const toCommand$2 = (command) => {
|
|
|
8466
8491
|
...(scope2 === "user" || scope2 === "project") && { scope: scope2 }
|
|
8467
8492
|
};
|
|
8468
8493
|
};
|
|
8469
|
-
const hideUserCommands = (commands2) => Object.fromEntries(
|
|
8470
|
-
commands2.filter((command) => toCommand$2(command).scope === "user").flatMap((command) => [command.name, ...command.aliases ?? []].map((name) => [name, "off"]))
|
|
8471
|
-
);
|
|
8472
8494
|
const FILE_EDIT_TOOLS$1 = /* @__PURE__ */ new Set(["Edit", "Write", "MultiEdit", "NotebookEdit"]);
|
|
8473
8495
|
const isTerminal$1 = (event) => event.type === "turn_completed" || event.type === "turn_failed" || event.type === "turn_limited";
|
|
8474
8496
|
function resetTurnLimits(state) {
|
|
@@ -8684,7 +8706,7 @@ function mapResult(result2, state) {
|
|
|
8684
8706
|
return {
|
|
8685
8707
|
type: "turn_failed",
|
|
8686
8708
|
message: message2,
|
|
8687
|
-
...state.signedOut &&
|
|
8709
|
+
...state.signedOut && signedOutFailure("claude", state.home, state.model)
|
|
8688
8710
|
};
|
|
8689
8711
|
}
|
|
8690
8712
|
return { type: "turn_completed", usage: toUsage(result2, state) };
|
|
@@ -44374,8 +44396,14 @@ function foldEvent(message2, event, now2) {
|
|
|
44374
44396
|
}
|
|
44375
44397
|
const failurePart = (event) => {
|
|
44376
44398
|
if (event.stopped) return [];
|
|
44377
|
-
if (event.
|
|
44378
|
-
return [
|
|
44399
|
+
if (event.signedOut)
|
|
44400
|
+
return [
|
|
44401
|
+
{
|
|
44402
|
+
type: "signed_out",
|
|
44403
|
+
message: event.message,
|
|
44404
|
+
...event.loginCommand !== void 0 && { loginCommand: event.loginCommand }
|
|
44405
|
+
}
|
|
44406
|
+
];
|
|
44379
44407
|
return [{ type: "text", text: `**Error:** ${event.message}` }];
|
|
44380
44408
|
};
|
|
44381
44409
|
function foldTranscript(messages, event, now2) {
|
|
@@ -44885,7 +44913,6 @@ const layer$Q = effect(
|
|
|
44885
44913
|
capacity: 32,
|
|
44886
44914
|
timeToLive: minutes(1)
|
|
44887
44915
|
});
|
|
44888
|
-
const skillOverrides = (input) => input.userSkills ? succeed$1(null) : get$3(probedCommands, commandsKey(input.cwd, input.home)).pipe(map$2(hideUserCommands));
|
|
44889
44916
|
const emit = (session, event) => {
|
|
44890
44917
|
if (session.turn === null) return;
|
|
44891
44918
|
if ((event.type === "turn_failed" || event.type === "turn_limited") && session.interrupted)
|
|
@@ -45080,7 +45107,6 @@ const layer$Q = effect(
|
|
|
45080
45107
|
const resume = input.resumeSessionId ?? previous?.sessionId;
|
|
45081
45108
|
const keepsGrants = previous !== void 0 && previous.sessionId === resume && sameContext(previous, input);
|
|
45082
45109
|
const base = yield* baseOptions(input.home);
|
|
45083
|
-
const hidden = yield* skillOverrides(input);
|
|
45084
45110
|
const effort = effortLevelOf(input.effort);
|
|
45085
45111
|
const { query } = yield* promise$1(() => import("./chunks/sdk-BjcPK2t_.js"));
|
|
45086
45112
|
const handle = yield* try_$1({
|
|
@@ -45096,8 +45122,7 @@ const layer$Q = effect(
|
|
|
45096
45122
|
settings: {
|
|
45097
45123
|
fastMode: input.fastMode,
|
|
45098
45124
|
...input.autoCompactTokens !== null && { autoCompactWindow: input.autoCompactTokens },
|
|
45099
|
-
...input.effort === ULTRACODE && { ultracode: true }
|
|
45100
|
-
...hidden !== null && { skillOverrides: hidden }
|
|
45125
|
+
...input.effort === ULTRACODE && { ultracode: true }
|
|
45101
45126
|
},
|
|
45102
45127
|
...resume === void 0 ? {} : { resume },
|
|
45103
45128
|
...input.forkAt !== null && { forkSession: true, resumeSessionAt: input.forkAt },
|
|
@@ -45133,7 +45158,6 @@ const layer$Q = effect(
|
|
|
45133
45158
|
model: input.model,
|
|
45134
45159
|
effort: input.effort,
|
|
45135
45160
|
fastMode: input.fastMode,
|
|
45136
|
-
userSkills: input.userSkills,
|
|
45137
45161
|
autoCompactTokens: input.autoCompactTokens,
|
|
45138
45162
|
permissionMode: mode2,
|
|
45139
45163
|
prompts,
|
|
@@ -45177,7 +45201,7 @@ const layer$Q = effect(
|
|
|
45177
45201
|
const reuseOrStartSession = (input, mode2) => gen(function* () {
|
|
45178
45202
|
const existing2 = sessions.get(input.threadId);
|
|
45179
45203
|
if (existing2 !== void 0) {
|
|
45180
|
-
if (sameContext(existing2, input) && existing2.
|
|
45204
|
+
if (sameContext(existing2, input) && existing2.autoCompactTokens === input.autoCompactTokens)
|
|
45181
45205
|
return claim2(existing2);
|
|
45182
45206
|
yield* closeSession(existing2);
|
|
45183
45207
|
}
|
|
@@ -45335,7 +45359,7 @@ const layer$Q = effect(
|
|
|
45335
45359
|
home
|
|
45336
45360
|
}) => suspend(() => {
|
|
45337
45361
|
const session = sessions.get(threadId);
|
|
45338
|
-
return session !== void 0 && session.
|
|
45362
|
+
return session !== void 0 && session.cwd === cwd && sameHome(session.home, home) ? lease(
|
|
45339
45363
|
session,
|
|
45340
45364
|
(leased) => tryPromise({
|
|
45341
45365
|
try: () => leased.query.supportedCommands(),
|
|
@@ -55139,6 +55163,7 @@ function play(steps, controls) {
|
|
|
55139
55163
|
subagents: /* @__PURE__ */ new Map(),
|
|
55140
55164
|
lastRequest: null,
|
|
55141
55165
|
home: null,
|
|
55166
|
+
model: mockModel,
|
|
55142
55167
|
limitMessage: null,
|
|
55143
55168
|
limitResetAt: null,
|
|
55144
55169
|
signedOut: false
|
|
@@ -55432,6 +55457,7 @@ const usageLimitLayer = (defaultScenario = "usage-limit", resetAfterMs = 6e4) =>
|
|
|
55432
55457
|
subagents: /* @__PURE__ */ new Map(),
|
|
55433
55458
|
lastRequest: null,
|
|
55434
55459
|
home: null,
|
|
55460
|
+
model: mockModel,
|
|
55435
55461
|
limitMessage: null,
|
|
55436
55462
|
limitResetAt: null,
|
|
55437
55463
|
signedOut: false
|
|
@@ -56194,7 +56220,9 @@ const textInput = (text2) => ({ type: "text", text: text2, text_elements: [] });
|
|
|
56194
56220
|
const userInput$1 = (text2, attachments) => [
|
|
56195
56221
|
...text2 === "" ? [] : [textInput(text2)],
|
|
56196
56222
|
...attachments.flatMap((attachment2) => {
|
|
56197
|
-
if (attachment2.kind !== "image"
|
|
56223
|
+
if (attachment2.kind !== "image" || !AGENT_IMAGE_TYPES.includes(attachment2.mime)) {
|
|
56224
|
+
return [textInput(`Attached file: ${attachment2.path}`)];
|
|
56225
|
+
}
|
|
56198
56226
|
const image = { type: "localImage", path: attachment2.path };
|
|
56199
56227
|
const context2 = attachmentContext(attachment2);
|
|
56200
56228
|
return context2 === null ? [image] : [image, textInput(context2)];
|
|
@@ -56255,6 +56283,7 @@ const make$14 = gen(function* () {
|
|
|
56255
56283
|
const threadsInTurn = /* @__PURE__ */ new Set();
|
|
56256
56284
|
const subagentChanges = yield* unbounded$1();
|
|
56257
56285
|
const loadedCompactLimits = /* @__PURE__ */ new Map();
|
|
56286
|
+
const loadedSessions = /* @__PURE__ */ new Map();
|
|
56258
56287
|
const terminalsByThread = /* @__PURE__ */ new Map();
|
|
56259
56288
|
const backgroundTaskChanges = yield* unbounded$1();
|
|
56260
56289
|
const parentOf = (childThreadId) => {
|
|
@@ -56344,8 +56373,19 @@ const make$14 = gen(function* () {
|
|
|
56344
56373
|
yield* interruptTurn$1(client2, { threadId: childThreadId, turnId }).pipe(ignore$1);
|
|
56345
56374
|
}
|
|
56346
56375
|
});
|
|
56376
|
+
const unloadSession = (threadId) => suspend(() => {
|
|
56377
|
+
const loaded = loadedSessions.get(threadId);
|
|
56378
|
+
if (loaded === void 0) return void_;
|
|
56379
|
+
loadedSessions.delete(threadId);
|
|
56380
|
+
loadedCompactLimits.delete(loaded.codexThreadId);
|
|
56381
|
+
return loaded.client.request("thread/unsubscribe", { threadId: loaded.codexThreadId }).pipe(ignore$1);
|
|
56382
|
+
});
|
|
56347
56383
|
const closeSession = (threadId, home) => gen(function* () {
|
|
56348
56384
|
yield* stopSubagents(threadId, home);
|
|
56385
|
+
yield* stopBackgroundTerminals(threadId);
|
|
56386
|
+
yield* unloadSession(threadId);
|
|
56387
|
+
});
|
|
56388
|
+
const stopBackgroundTerminals = (threadId) => gen(function* () {
|
|
56349
56389
|
const terminals = terminalsByThread.get(threadId);
|
|
56350
56390
|
if (terminals === void 0) return;
|
|
56351
56391
|
if (terminals.poll) yield* interrupt$1(terminals.poll);
|
|
@@ -56485,7 +56525,6 @@ const make$14 = gen(function* () {
|
|
|
56485
56525
|
sync(() => threadsInTurn.add(input.threadId)),
|
|
56486
56526
|
() => sync(() => threadsInTurn.delete(input.threadId))
|
|
56487
56527
|
);
|
|
56488
|
-
const hiddenSkills = input.userSkills ? null : (yield* listSkills2(input.cwd, input.home)).filter((skill) => skill.scope === "user");
|
|
56489
56528
|
const overrides = {
|
|
56490
56529
|
cwd: input.cwd,
|
|
56491
56530
|
model: input.model,
|
|
@@ -56494,9 +56533,6 @@ const make$14 = gen(function* () {
|
|
|
56494
56533
|
tools: { update_plan: { enabled: true } },
|
|
56495
56534
|
...input.tmpDirectory !== null && { shell_environment_policy: { set: tmpEnv(input.tmpDirectory) } },
|
|
56496
56535
|
...input.autoCompactTokens !== null && { model_auto_compact_token_limit: input.autoCompactTokens },
|
|
56497
|
-
...hiddenSkills !== null && {
|
|
56498
|
-
skills: { config: hiddenSkills.map((skill) => ({ path: skill.path, enabled: false })) }
|
|
56499
|
-
},
|
|
56500
56536
|
mcp_servers: {
|
|
56501
56537
|
hinacode: {
|
|
56502
56538
|
url: input.mcpServer.url,
|
|
@@ -56523,10 +56559,11 @@ const make$14 = gen(function* () {
|
|
|
56523
56559
|
excludeTurns: true
|
|
56524
56560
|
});
|
|
56525
56561
|
loadedCompactLimits.set(thread2.id, input.autoCompactTokens);
|
|
56562
|
+
loadedSessions.set(input.threadId, { client: client2, codexThreadId: thread2.id });
|
|
56526
56563
|
yield* emit({ type: "session_bound", providerSessionId: thread2.id });
|
|
56527
56564
|
const compacting2 = isCompactCommand(input.prompt);
|
|
56528
56565
|
const startTurn = gen(function* () {
|
|
56529
|
-
const skills = input.prompt.includes("$") ?
|
|
56566
|
+
const skills = input.prompt.includes("$") ? yield* listSkills2(input.cwd, input.home) : [];
|
|
56530
56567
|
const turnStart = {
|
|
56531
56568
|
threadId: thread2.id,
|
|
56532
56569
|
input: [...userInput$1(input.prompt, input.attachments), ...skillInputs(input.prompt, skills)],
|
|
@@ -56843,9 +56880,7 @@ const make$14 = gen(function* () {
|
|
|
56843
56880
|
status === "completed" ? { type: "turn_completed", usage: usage2, forkPoint: { sessionId: thread2.id, checkpoint: turn.turnId } } : {
|
|
56844
56881
|
type: "turn_failed",
|
|
56845
56882
|
message: error2?.message ?? `Turn ${status}`,
|
|
56846
|
-
...error2?.codexErrorInfo === "unauthorized" &&
|
|
56847
|
-
loginCommand: loginCommand("codex", input.home)
|
|
56848
|
-
}
|
|
56883
|
+
...error2?.codexErrorInfo === "unauthorized" && signedOutFailure("codex", input.home, input.model)
|
|
56849
56884
|
}
|
|
56850
56885
|
);
|
|
56851
56886
|
return true;
|
|
@@ -58894,7 +58929,7 @@ const make$13 = gen(function* () {
|
|
|
58894
58929
|
yield* emit({
|
|
58895
58930
|
type: "turn_failed",
|
|
58896
58931
|
message: params2.error?.message ?? params2.reason ?? `Turn ${params2.terminal}`,
|
|
58897
|
-
...params2.error?.kind === "authRequired" && { loginCommand: "muse login" }
|
|
58932
|
+
...params2.error?.kind === "authRequired" && { signedOut: true, loginCommand: "muse login" }
|
|
58898
58933
|
});
|
|
58899
58934
|
});
|
|
58900
58935
|
const handle = (message2) => gen(function* () {
|
|
@@ -59226,8 +59261,13 @@ const TextContent$4 = Struct({
|
|
|
59226
59261
|
type: Literal("content"),
|
|
59227
59262
|
content: Struct({ type: Literal("text"), text: String$1 })
|
|
59228
59263
|
});
|
|
59264
|
+
const ImageContent$4 = Struct({
|
|
59265
|
+
type: Literal("content"),
|
|
59266
|
+
content: Struct({ type: Literal("image"), data: String$1, mimeType: String$1 })
|
|
59267
|
+
});
|
|
59229
59268
|
const DiffContent$1 = Struct({ type: Literal("diff"), path: String$1 });
|
|
59230
59269
|
const decodeTextContent = decodeUnknownOption(TextContent$4);
|
|
59270
|
+
const decodeImageContent = decodeUnknownOption(ImageContent$4);
|
|
59231
59271
|
const decodeDiffContent$1 = decodeUnknownOption(DiffContent$1);
|
|
59232
59272
|
const record = (value2) => isObject$2(value2) ? { ...value2 } : {};
|
|
59233
59273
|
const stringField = (value2, key2) => {
|
|
@@ -59265,6 +59305,10 @@ const toolOutput = (tool2) => {
|
|
|
59265
59305
|
const texts = tool2.content.flatMap(
|
|
59266
59306
|
(block) => match(decodeTextContent(block), { onNone: () => [], onSome: ({ content }) => [content.text] })
|
|
59267
59307
|
);
|
|
59308
|
+
const images = tool2.content.flatMap(
|
|
59309
|
+
(block) => match(decodeImageContent(block), { onNone: () => [], onSome: ({ content }) => [content] })
|
|
59310
|
+
);
|
|
59311
|
+
if (images.length > 0) return [...texts.map((text2) => ({ type: "text", text: text2 })), ...images];
|
|
59268
59312
|
if (texts.length > 0) return texts.join("\n");
|
|
59269
59313
|
return stringField(tool2.rawOutput, "output") ?? tool2.rawOutput ?? "";
|
|
59270
59314
|
};
|
|
@@ -60707,6 +60751,10 @@ const pullRequestObservedStatus = gen(function* () {
|
|
|
60707
60751
|
const sql = yield* SqlClient;
|
|
60708
60752
|
yield* sql`ALTER TABLE pull_request_link ADD COLUMN observed_status TEXT`;
|
|
60709
60753
|
});
|
|
60754
|
+
const dropThreadUserSkills = gen(function* () {
|
|
60755
|
+
const sql = yield* SqlClient;
|
|
60756
|
+
yield* sql`ALTER TABLE thread DROP COLUMN user_skills`;
|
|
60757
|
+
});
|
|
60710
60758
|
const run$2 = make$16({});
|
|
60711
60759
|
const runMigrations = run$2({
|
|
60712
60760
|
loader: fromRecord({
|
|
@@ -60751,7 +60799,8 @@ const runMigrations = run$2({
|
|
|
60751
60799
|
"40_remote_private_networks": remotePrivateNetworks,
|
|
60752
60800
|
"41_thread_work_started": threadWorkStarted,
|
|
60753
60801
|
"42_thread_settled": threadSettled,
|
|
60754
|
-
"43_pull_request_observed_status": pullRequestObservedStatus
|
|
60802
|
+
"43_pull_request_observed_status": pullRequestObservedStatus,
|
|
60803
|
+
"44_drop_thread_user_skills": dropThreadUserSkills
|
|
60755
60804
|
})
|
|
60756
60805
|
}).pipe(
|
|
60757
60806
|
tap$1(
|
|
@@ -60811,6 +60860,7 @@ const routes = {
|
|
|
60811
60860
|
"artifacts.delete": owner("artifact", "id"),
|
|
60812
60861
|
"artifacts.readDocument": owner("artifact", "id"),
|
|
60813
60862
|
"artifacts.saveDocument": owner("artifact", "id"),
|
|
60863
|
+
"artifacts.addDocumentImage": owner("artifact", "id"),
|
|
60814
60864
|
"artifacts.createDocument": thread,
|
|
60815
60865
|
"artifacts.rename": owner("artifact", "id"),
|
|
60816
60866
|
"shell.reveal": client$1,
|
|
@@ -60867,6 +60917,8 @@ const routes = {
|
|
|
60867
60917
|
"github.merge": named,
|
|
60868
60918
|
"github.close": named,
|
|
60869
60919
|
"github.comment": named,
|
|
60920
|
+
"github.pullRequestCandidates": named,
|
|
60921
|
+
"github.editPullRequest": named,
|
|
60870
60922
|
"github.fileContent": named,
|
|
60871
60923
|
"github.reviewComment": named,
|
|
60872
60924
|
"vm.host": named,
|
|
@@ -60875,10 +60927,9 @@ const routes = {
|
|
|
60875
60927
|
"remote.status": named,
|
|
60876
60928
|
"remote.pairing": named,
|
|
60877
60929
|
"remote.rotateToken": named,
|
|
60878
|
-
"remote.setupRelay": named,
|
|
60879
|
-
"remote.removeRelay": named,
|
|
60880
60930
|
"projects.create": named,
|
|
60881
60931
|
"projects.clone": named,
|
|
60932
|
+
"projects.cancelClone": named,
|
|
60882
60933
|
"ports.kill": named,
|
|
60883
60934
|
"automations.list": named,
|
|
60884
60935
|
"projects.update": project,
|
|
@@ -60909,6 +60960,7 @@ const routes = {
|
|
|
60909
60960
|
"threads.unarchive": thread,
|
|
60910
60961
|
"threads.settle": thread,
|
|
60911
60962
|
"threads.unsettle": thread,
|
|
60963
|
+
"threads.regenerateTitle": thread,
|
|
60912
60964
|
"threads.transcript": thread,
|
|
60913
60965
|
"threads.toolOutput": thread,
|
|
60914
60966
|
"threads.send": thread,
|
|
@@ -63316,6 +63368,30 @@ const titleOf = (title2) => {
|
|
|
63316
63368
|
if (trimmed === "") throw new ArtifactError("An artifact needs a title.");
|
|
63317
63369
|
return trimmed;
|
|
63318
63370
|
};
|
|
63371
|
+
const IMAGE_DIRECTORY = "images";
|
|
63372
|
+
const imageExtensions = {
|
|
63373
|
+
"image/png": "png",
|
|
63374
|
+
"image/jpeg": "jpg",
|
|
63375
|
+
"image/gif": "gif",
|
|
63376
|
+
"image/webp": "webp"
|
|
63377
|
+
};
|
|
63378
|
+
const isDocumentImagePath = (path2) => {
|
|
63379
|
+
const [directory, name, ...rest] = path2.split("/");
|
|
63380
|
+
return directory === IMAGE_DIRECTORY && name !== void 0 && rest.length === 0;
|
|
63381
|
+
};
|
|
63382
|
+
const imageName = ({ bytes, type: type2 }) => {
|
|
63383
|
+
const extension = imageExtensions[type2];
|
|
63384
|
+
if (extension === void 0) {
|
|
63385
|
+
throw new ArtifactError(`A document image cannot be ${type2}. Paste a PNG, JPEG, GIF or WebP image.`);
|
|
63386
|
+
}
|
|
63387
|
+
if (bytes.byteLength === 0) throw new ArtifactError("The image is empty. Paste an image with content.");
|
|
63388
|
+
if (bytes.byteLength > MAX_ARTIFACT_BYTES) {
|
|
63389
|
+
throw new ArtifactError(
|
|
63390
|
+
`The image is ${bytes.byteLength} bytes. An image holds at most ${MAX_ARTIFACT_BYTES} bytes.`
|
|
63391
|
+
);
|
|
63392
|
+
}
|
|
63393
|
+
return `${createHash("sha256").update(bytes).digest("hex")}.${extension}`;
|
|
63394
|
+
};
|
|
63319
63395
|
const missing = (id2) => new ArtifactError(`No artifact has the id "${id2}". Omit id to publish a new artifact.`);
|
|
63320
63396
|
const openArtifactStore = (root2, options = {}) => {
|
|
63321
63397
|
const now2 = options.now ?? (() => /* @__PURE__ */ new Date());
|
|
@@ -63430,8 +63506,11 @@ const openArtifactStore = (root2, options = {}) => {
|
|
|
63430
63506
|
let missingVersion;
|
|
63431
63507
|
for (; ; ) {
|
|
63432
63508
|
const artifact2 = await get2(id2);
|
|
63433
|
-
|
|
63434
|
-
|
|
63509
|
+
if (!artifact2) return null;
|
|
63510
|
+
const listed = artifact2.files.find((candidate) => candidate.path === normalized);
|
|
63511
|
+
if (!listed)
|
|
63512
|
+
return artifact2.kind === "document" && isDocumentImagePath(normalized) ? image(artifact2, normalized) : null;
|
|
63513
|
+
if (artifact2.version === missingVersion) return null;
|
|
63435
63514
|
try {
|
|
63436
63515
|
const bytes = await readFile(join$1(root2, id2, String(artifact2.version), listed.path));
|
|
63437
63516
|
return { bytes, type: listed.type, version: artifact2.version, revision: artifact2.revision, kind: artifact2.kind };
|
|
@@ -63441,6 +63520,39 @@ const openArtifactStore = (root2, options = {}) => {
|
|
|
63441
63520
|
}
|
|
63442
63521
|
}
|
|
63443
63522
|
};
|
|
63523
|
+
const image = async (artifact2, path2) => {
|
|
63524
|
+
try {
|
|
63525
|
+
const bytes = await readFile(join$1(root2, artifact2.id, path2));
|
|
63526
|
+
return {
|
|
63527
|
+
bytes,
|
|
63528
|
+
type: contentType(path2),
|
|
63529
|
+
version: artifact2.version,
|
|
63530
|
+
revision: artifact2.revision,
|
|
63531
|
+
kind: artifact2.kind
|
|
63532
|
+
};
|
|
63533
|
+
} catch {
|
|
63534
|
+
return null;
|
|
63535
|
+
}
|
|
63536
|
+
};
|
|
63537
|
+
const addDocumentImage = async (id2, input) => {
|
|
63538
|
+
const name = imageName(input);
|
|
63539
|
+
if (!isArtifactId(id2)) throw missing(id2);
|
|
63540
|
+
return withLock(id2, async (assertLocked) => {
|
|
63541
|
+
const artifact2 = await get2(id2);
|
|
63542
|
+
if (artifact2 === null) throw missing(id2);
|
|
63543
|
+
if (artifact2.kind !== "document") {
|
|
63544
|
+
throw new ArtifactError(`Artifact ${id2} is a ${artifact2.kind}. Only a document stores pasted images.`);
|
|
63545
|
+
}
|
|
63546
|
+
const path2 = `${IMAGE_DIRECTORY}/${name}`;
|
|
63547
|
+
const target = join$1(root2, id2, path2);
|
|
63548
|
+
await mkdir(dirname(target), { recursive: true });
|
|
63549
|
+
const temporary = `${target}.${randomUUID()}.tmp`;
|
|
63550
|
+
await writeFile(temporary, input.bytes);
|
|
63551
|
+
assertLocked();
|
|
63552
|
+
await rename(temporary, target);
|
|
63553
|
+
return path2;
|
|
63554
|
+
});
|
|
63555
|
+
};
|
|
63444
63556
|
const remove2 = async (id2) => {
|
|
63445
63557
|
if (!isArtifactId(id2)) return false;
|
|
63446
63558
|
return withLock(id2, async (assertLocked) => {
|
|
@@ -63461,7 +63573,7 @@ const openArtifactStore = (root2, options = {}) => {
|
|
|
63461
63573
|
return artifact2;
|
|
63462
63574
|
});
|
|
63463
63575
|
};
|
|
63464
|
-
return { root: root2, publish: publish2, get: get2, list, file, remove: remove2, rename: renameArtifact };
|
|
63576
|
+
return { root: root2, publish: publish2, get: get2, list, file, remove: remove2, rename: renameArtifact, addDocumentImage };
|
|
63465
63577
|
};
|
|
63466
63578
|
const tool = (definition) => definition;
|
|
63467
63579
|
const existing = async (store2, id2) => {
|
|
@@ -64473,7 +64585,9 @@ const makeExec = (spawner) => (command, args, cwd, options) => gen(function* ()
|
|
|
64473
64585
|
const [stdout, stderr, exitCode] = yield* all$1(
|
|
64474
64586
|
[
|
|
64475
64587
|
mkString(decodeText$1(handle.stdout)),
|
|
64476
|
-
mkString(
|
|
64588
|
+
mkString(
|
|
64589
|
+
decodeText$1(handle.stderr).pipe(tap$2((chunk) => options?.onStderr?.(chunk) ?? void_))
|
|
64590
|
+
),
|
|
64477
64591
|
handle.exitCode
|
|
64478
64592
|
],
|
|
64479
64593
|
{ concurrency: "unbounded" }
|
|
@@ -64982,10 +65096,32 @@ class PullRequestDiffTooLargeError extends TaggedError$1()(
|
|
|
64982
65096
|
return "GitHub does not serve diffs over 20,000 lines or 300 files.";
|
|
64983
65097
|
}
|
|
64984
65098
|
}
|
|
65099
|
+
const CLONE_PROGRESS_LINE = /^(?:remote: )?(\S[^:]*):\s+(\d{1,3})%/;
|
|
65100
|
+
const parseCloneProgress = (chunk) => {
|
|
65101
|
+
const lines = chunk.split(/[\r\n]/).toReversed();
|
|
65102
|
+
for (const line of lines) {
|
|
65103
|
+
const match2 = CLONE_PROGRESS_LINE.exec(line.trim());
|
|
65104
|
+
if (match2?.[1] && match2[2]) return { phase: match2[1], percent: Number(match2[2]) };
|
|
65105
|
+
}
|
|
65106
|
+
return void 0;
|
|
65107
|
+
};
|
|
64985
65108
|
const requirePullRequestUrl = (raw2) => {
|
|
64986
65109
|
const url2 = parseGitHubPullRequestUrl(raw2.trim());
|
|
64987
65110
|
return url2 === void 0 ? fail$2(new PullRequestUrlInvalidError({ url: raw2 })) : succeed$1(url2);
|
|
64988
65111
|
};
|
|
65112
|
+
const EDIT_FLAGS = {
|
|
65113
|
+
labels: { add: "--add-label", remove: "--remove-label" },
|
|
65114
|
+
assignees: { add: "--add-assignee", remove: "--remove-assignee" },
|
|
65115
|
+
reviewers: { add: "--add-reviewer", remove: "--remove-reviewer" }
|
|
65116
|
+
};
|
|
65117
|
+
const csvField = (value2) => `"${value2.replaceAll('"', '""')}"`;
|
|
65118
|
+
const editPullRequestArgs = (url2, { field: field2, add: add2, remove: remove2 }) => [
|
|
65119
|
+
"pr",
|
|
65120
|
+
"edit",
|
|
65121
|
+
url2,
|
|
65122
|
+
...add2.map((value2) => `${EDIT_FLAGS[field2].add}=${csvField(value2)}`),
|
|
65123
|
+
...remove2.map((value2) => `${EDIT_FLAGS[field2].remove}=${csvField(value2)}`)
|
|
65124
|
+
];
|
|
64989
65125
|
const reviewCommentArgs = (url2, comment) => {
|
|
64990
65126
|
const { pathname } = new URL(url2);
|
|
64991
65127
|
const [, owner2, repo, , number2] = pathname.split("/");
|
|
@@ -65057,7 +65193,10 @@ const PullRequestDetailFields = Struct({
|
|
|
65057
65193
|
headRefOid: String$1,
|
|
65058
65194
|
createdAt: String$1,
|
|
65059
65195
|
changedFiles: Number$2,
|
|
65060
|
-
comments: ArraySchema(PullRequestComment)
|
|
65196
|
+
comments: ArraySchema(PullRequestComment),
|
|
65197
|
+
labels: ArraySchema(PullRequestLabel),
|
|
65198
|
+
assignees: ArraySchema(String$1),
|
|
65199
|
+
reviewers: ArraySchema(PullRequestReviewer)
|
|
65061
65200
|
});
|
|
65062
65201
|
const PULL_REQUEST_FRAGMENTS = `fragment PullRequestFields on PullRequest {
|
|
65063
65202
|
url number title state isDraft reviewDecision mergeable
|
|
@@ -65070,6 +65209,11 @@ const PULL_REQUEST_FRAGMENTS = `fragment PullRequestFields on PullRequest {
|
|
|
65070
65209
|
comments(last: 50) { nodes { ...Comment url } }
|
|
65071
65210
|
reviews(last: 50) { nodes { ...Comment url } }
|
|
65072
65211
|
reviewThreads(last: 50) { nodes { isResolved diffSide comments(first: 20) { nodes { ...Comment url path line } } } }
|
|
65212
|
+
labels(first: 50) { nodes { name color } }
|
|
65213
|
+
assignees(first: 50) { nodes { login } }
|
|
65214
|
+
reviewRequests(first: 50) { nodes { requestedReviewer { ... on Actor { login } ... on Team { combinedSlug } } } }
|
|
65215
|
+
latestOpinionatedReviews(first: 50) { nodes { state author { login } } }
|
|
65216
|
+
latestReviews(first: 50) { nodes { state author { login } } }
|
|
65073
65217
|
}
|
|
65074
65218
|
|
|
65075
65219
|
fragment Comment on Comment {
|
|
@@ -65121,8 +65265,26 @@ const GraphQLReviewComment = Struct({
|
|
|
65121
65265
|
path: String$1,
|
|
65122
65266
|
line: NullOr(Number$2)
|
|
65123
65267
|
});
|
|
65268
|
+
const GraphQLReviews = Struct({
|
|
65269
|
+
nodes: ArraySchema(Struct({ state: String$1, author: GraphQLAuthor }))
|
|
65270
|
+
});
|
|
65124
65271
|
const GraphQLPullRequest = Struct({
|
|
65125
|
-
...PullRequestDetailFields.mapFields(
|
|
65272
|
+
...PullRequestDetailFields.mapFields(
|
|
65273
|
+
omit$1(["reviewDecision", "author", "statusCheckRollup", "comments", "labels", "assignees", "reviewers"])
|
|
65274
|
+
).fields,
|
|
65275
|
+
labels: Struct({ nodes: ArraySchema(PullRequestLabel) }),
|
|
65276
|
+
assignees: Struct({ nodes: ArraySchema(Struct({ login: String$1 })) }),
|
|
65277
|
+
reviewRequests: Struct({
|
|
65278
|
+
nodes: ArraySchema(
|
|
65279
|
+
Struct({
|
|
65280
|
+
requestedReviewer: NullOr(
|
|
65281
|
+
Struct({ login: optionalKey(String$1), combinedSlug: optionalKey(String$1) })
|
|
65282
|
+
)
|
|
65283
|
+
})
|
|
65284
|
+
)
|
|
65285
|
+
}),
|
|
65286
|
+
latestOpinionatedReviews: GraphQLReviews,
|
|
65287
|
+
latestReviews: GraphQLReviews,
|
|
65126
65288
|
reviewDecision: NullOr(String$1),
|
|
65127
65289
|
author: GraphQLAuthor,
|
|
65128
65290
|
comments: Struct({ nodes: ArraySchema(GraphQLComment) }),
|
|
@@ -65197,6 +65359,34 @@ const toComments = ({
|
|
|
65197
65359
|
)
|
|
65198
65360
|
)
|
|
65199
65361
|
].toSorted((a, b) => a.createdAt.localeCompare(b.createdAt));
|
|
65362
|
+
const REVIEWER_STATE = {
|
|
65363
|
+
APPROVED: "approved",
|
|
65364
|
+
CHANGES_REQUESTED: "changesRequested",
|
|
65365
|
+
COMMENTED: "commented"
|
|
65366
|
+
};
|
|
65367
|
+
const toReviewers = ({
|
|
65368
|
+
reviewRequests,
|
|
65369
|
+
latestOpinionatedReviews,
|
|
65370
|
+
latestReviews
|
|
65371
|
+
}, author) => {
|
|
65372
|
+
const requested = new Set(
|
|
65373
|
+
reviewRequests.nodes.flatMap(({ requestedReviewer }) => {
|
|
65374
|
+
const login = requestedReviewer?.login ?? requestedReviewer?.combinedSlug;
|
|
65375
|
+
return login === void 0 ? [] : [login];
|
|
65376
|
+
})
|
|
65377
|
+
);
|
|
65378
|
+
const reviewed = /* @__PURE__ */ new Map();
|
|
65379
|
+
for (const { state, author: reviewer } of [...latestOpinionatedReviews.nodes, ...latestReviews.nodes]) {
|
|
65380
|
+
const reviewerState = REVIEWER_STATE[state];
|
|
65381
|
+
if (reviewer === null || reviewerState === void 0) continue;
|
|
65382
|
+
if (reviewer.login === author || requested.has(reviewer.login) || reviewed.has(reviewer.login)) continue;
|
|
65383
|
+
reviewed.set(reviewer.login, reviewerState);
|
|
65384
|
+
}
|
|
65385
|
+
return [
|
|
65386
|
+
...[...requested].map((login) => ({ login, state: "requested" })),
|
|
65387
|
+
...[...reviewed].map(([login, state]) => ({ login, state }))
|
|
65388
|
+
];
|
|
65389
|
+
};
|
|
65200
65390
|
const fromGraphQL = ({
|
|
65201
65391
|
commits,
|
|
65202
65392
|
reviewDecision,
|
|
@@ -65204,13 +65394,21 @@ const fromGraphQL = ({
|
|
|
65204
65394
|
comments,
|
|
65205
65395
|
reviews,
|
|
65206
65396
|
reviewThreads,
|
|
65397
|
+
labels,
|
|
65398
|
+
assignees,
|
|
65399
|
+
reviewRequests,
|
|
65400
|
+
latestOpinionatedReviews,
|
|
65401
|
+
latestReviews,
|
|
65207
65402
|
...fields
|
|
65208
65403
|
}) => ({
|
|
65209
65404
|
...fields,
|
|
65210
65405
|
reviewDecision: reviewDecision ?? "",
|
|
65211
65406
|
author: author ?? { login: "ghost" },
|
|
65212
65407
|
statusCheckRollup: (commits.nodes[0]?.commit.statusCheckRollup?.contexts.nodes ?? []).map(toRollupEntry),
|
|
65213
|
-
comments: toComments({ comments, reviews, reviewThreads })
|
|
65408
|
+
comments: toComments({ comments, reviews, reviewThreads }),
|
|
65409
|
+
labels: labels.nodes,
|
|
65410
|
+
assignees: assignees.nodes.map(({ login }) => login),
|
|
65411
|
+
reviewers: toReviewers({ reviewRequests, latestOpinionatedReviews, latestReviews }, author?.login ?? "ghost")
|
|
65214
65412
|
});
|
|
65215
65413
|
const FAILED = /* @__PURE__ */ new Set(["FAILURE", "ERROR", "TIMED_OUT", "CANCELLED", "ACTION_REQUIRED", "STARTUP_FAILURE"]);
|
|
65216
65414
|
const checkOutcome = (entry) => {
|
|
@@ -65270,6 +65468,9 @@ const toPullRequestDetail = (json2) => ({
|
|
|
65270
65468
|
head: json2.headRefOid,
|
|
65271
65469
|
changedFiles: json2.changedFiles,
|
|
65272
65470
|
comments: json2.comments,
|
|
65471
|
+
labels: json2.labels,
|
|
65472
|
+
assignees: json2.assignees,
|
|
65473
|
+
reviewers: json2.reviewers,
|
|
65273
65474
|
checkRuns: json2.statusCheckRollup.map(toCheckRun).toSorted((a, b) => CHECK_RUN_ORDER[a.status] - CHECK_RUN_ORDER[b.status])
|
|
65274
65475
|
});
|
|
65275
65476
|
const pullRequestFiles = (diff) => forEach(
|
|
@@ -65362,6 +65563,24 @@ const contentsPath = (url2, ref2, path2) => {
|
|
|
65362
65563
|
const file = path2.split("/").map(encodeURIComponent).join("/");
|
|
65363
65564
|
return `repos/${owner2}/${repo}/contents/${file}?ref=${encodeURIComponent(ref2)}`;
|
|
65364
65565
|
};
|
|
65566
|
+
const CANDIDATES_QUERY = `query Candidates($owner: String!, $name: String!) {
|
|
65567
|
+
repository(owner: $owner, name: $name) {
|
|
65568
|
+
labels(first: 100, orderBy: { field: NAME, direction: ASC }) { nodes { name color } }
|
|
65569
|
+
assignableUsers(first: 100) { nodes { login } }
|
|
65570
|
+
}
|
|
65571
|
+
}`;
|
|
65572
|
+
const decodeCandidates = decodeUnknownEffect(
|
|
65573
|
+
fromJsonString(
|
|
65574
|
+
Struct({
|
|
65575
|
+
data: Struct({
|
|
65576
|
+
repository: Struct({
|
|
65577
|
+
labels: Struct({ nodes: ArraySchema(PullRequestLabel) }),
|
|
65578
|
+
assignableUsers: Struct({ nodes: ArraySchema(Struct({ login: String$1 })) })
|
|
65579
|
+
})
|
|
65580
|
+
})
|
|
65581
|
+
})
|
|
65582
|
+
)
|
|
65583
|
+
);
|
|
65365
65584
|
const decodePullRequestHead = decodeUnknownEffect(fromJsonString(PullRequestHead));
|
|
65366
65585
|
const decodeOpenPullRequests = decodeUnknownEffect(
|
|
65367
65586
|
fromJsonString(
|
|
@@ -65521,13 +65740,24 @@ const make$Y = gen(function* () {
|
|
|
65521
65740
|
const createRepository = (cwd, visibility) => gh(cwd, ["repo", "create", "--source", cwd, "--remote", "origin", `--${visibility}`, "--push"], {
|
|
65522
65741
|
timeout: LONG_TIMEOUT
|
|
65523
65742
|
}).pipe(asVoid);
|
|
65524
|
-
const clone2 = ({ owner: owner2, name }, dest) => {
|
|
65743
|
+
const clone2 = ({ owner: owner2, name }, dest, onProgress) => {
|
|
65525
65744
|
const url2 = `https://github.com/${owner2}/${name}.git`;
|
|
65526
|
-
|
|
65745
|
+
let last;
|
|
65746
|
+
const onStderr = (chunk) => {
|
|
65747
|
+
const progress = parseCloneProgress(chunk);
|
|
65748
|
+
if (progress === void 0 || isDeepStrictEqual(progress, last)) return void_;
|
|
65749
|
+
last = progress;
|
|
65750
|
+
return onProgress(progress);
|
|
65751
|
+
};
|
|
65752
|
+
const gitClone = () => exec2("git", [...REMOTE_GIT_ARGS, "clone", "--progress", url2, dest], dirname(dest), {
|
|
65527
65753
|
env: REMOTE_GIT_ENV,
|
|
65528
|
-
timeout: LONG_TIMEOUT
|
|
65754
|
+
timeout: LONG_TIMEOUT,
|
|
65755
|
+
onStderr
|
|
65529
65756
|
});
|
|
65530
|
-
return gh(dirname(dest), ["repo", "clone", url2, dest], {
|
|
65757
|
+
return gh(dirname(dest), ["repo", "clone", url2, dest, "--", "--progress"], {
|
|
65758
|
+
timeout: LONG_TIMEOUT,
|
|
65759
|
+
onStderr
|
|
65760
|
+
}).pipe(
|
|
65531
65761
|
catchTags({
|
|
65532
65762
|
GitHubCliMissingError: gitClone,
|
|
65533
65763
|
GitHubSignedOutError: gitClone,
|
|
@@ -65660,6 +65890,21 @@ const make$Y = gen(function* () {
|
|
|
65660
65890
|
merge: (raw2, method2) => ghWrite(raw2, (url2) => ["pr", "merge", url2, `--${method2}`], openInRepository),
|
|
65661
65891
|
close: (raw2) => ghWrite(raw2, (url2) => ["pr", "close", url2]),
|
|
65662
65892
|
comment: (raw2, body2) => ghWrite(raw2, (url2) => ["pr", "comment", url2, "--body", body2]),
|
|
65893
|
+
pullRequestCandidates: (raw2) => gen(function* () {
|
|
65894
|
+
const [, owner2 = "", name = ""] = new URL(yield* requirePullRequestUrl(raw2)).pathname.split("/");
|
|
65895
|
+
const { body: body2 } = yield* ghApi([
|
|
65896
|
+
"graphql",
|
|
65897
|
+
"-f",
|
|
65898
|
+
`query=${CANDIDATES_QUERY}`,
|
|
65899
|
+
"-f",
|
|
65900
|
+
`owner=${owner2}`,
|
|
65901
|
+
"-f",
|
|
65902
|
+
`name=${name}`
|
|
65903
|
+
]);
|
|
65904
|
+
const { labels, assignableUsers } = (yield* decodeCandidates(body2)).data.repository;
|
|
65905
|
+
return { labels: labels.nodes, users: assignableUsers.nodes.map(({ login }) => login) };
|
|
65906
|
+
}),
|
|
65907
|
+
editPullRequest: (raw2, edit) => ghWrite(raw2, (url2) => editPullRequestArgs(url2, edit)),
|
|
65663
65908
|
reviewComment: (raw2, comment) => ghWrite(raw2, (url2) => reviewCommentArgs(url2, comment)),
|
|
65664
65909
|
branchPullRequest,
|
|
65665
65910
|
pullRequestHead: (cwd, selector) => gh(cwd, ["pr", "view", selector, "--json", "url,number,headRefName,baseRefName,isCrossRepository"]).pipe(
|
|
@@ -65755,6 +66000,8 @@ const make$X = gen(function* () {
|
|
|
65755
66000
|
const fs2 = yield* FileSystem;
|
|
65756
66001
|
const git2 = yield* Git;
|
|
65757
66002
|
const github = yield* GitHub;
|
|
66003
|
+
const events2 = yield* Events;
|
|
66004
|
+
const cloneCancels = /* @__PURE__ */ new Map();
|
|
65758
66005
|
const findAll$1 = findAll({
|
|
65759
66006
|
Request: Void,
|
|
65760
66007
|
Result: ProjectRow,
|
|
@@ -65853,16 +66100,31 @@ const make$X = gen(function* () {
|
|
|
65853
66100
|
)
|
|
65854
66101
|
)
|
|
65855
66102
|
);
|
|
65856
|
-
const
|
|
66103
|
+
const cloneInto = (cloneId, repository, rootPath) => gen(function* () {
|
|
66104
|
+
if (yield* holdsClone(rootPath, repository)) return;
|
|
66105
|
+
yield* makeDirectory(rootPath);
|
|
66106
|
+
const entries = yield* fs2.readDirectory(rootPath).pipe(mapError(() => new ProjectRootInvalidError({ rootPath })));
|
|
66107
|
+
if (entries.length > 0) return yield* new ProjectFolderNotEmptyError({ rootPath });
|
|
66108
|
+
yield* github.clone(
|
|
66109
|
+
repository,
|
|
66110
|
+
rootPath,
|
|
66111
|
+
(progress) => events2.publish({ type: "project.cloneProgress", cloneId, progress })
|
|
66112
|
+
);
|
|
66113
|
+
});
|
|
66114
|
+
const clone2 = ({ cloneId, repository, ...input }) => gen(function* () {
|
|
66115
|
+
const cancel = yield* make$1s();
|
|
66116
|
+
cloneCancels.set(cloneId, cancel);
|
|
65857
66117
|
const rootPath = yield* resolveRoot(input.rootPath);
|
|
65858
|
-
|
|
65859
|
-
|
|
65860
|
-
|
|
65861
|
-
|
|
65862
|
-
yield* github.clone(repository, rootPath);
|
|
65863
|
-
}
|
|
66118
|
+
const cancelled = _await(cancel).pipe(
|
|
66119
|
+
andThen(fail$2(new ProjectCloneCancelledError({ rootPath })))
|
|
66120
|
+
);
|
|
66121
|
+
yield* raceFirst(cloneInto(cloneId, repository, rootPath), cancelled);
|
|
65864
66122
|
return yield* insert({ ...input, rootPath });
|
|
65865
|
-
});
|
|
66123
|
+
}).pipe(ensuring(sync(() => cloneCancels.delete(cloneId))));
|
|
66124
|
+
const cancelClone = (cloneId) => suspend(() => {
|
|
66125
|
+
const cancel = cloneCancels.get(cloneId);
|
|
66126
|
+
return cancel === void 0 ? void_ : succeed$3(cancel, void 0);
|
|
66127
|
+
}).pipe(asVoid);
|
|
65866
66128
|
const findChats = findOne({
|
|
65867
66129
|
Request: Void,
|
|
65868
66130
|
Result: ProjectRow,
|
|
@@ -65931,6 +66193,7 @@ const make$X = gen(function* () {
|
|
|
65931
66193
|
get: get2,
|
|
65932
66194
|
create,
|
|
65933
66195
|
clone: clone2,
|
|
66196
|
+
cancelClone,
|
|
65934
66197
|
update: update2,
|
|
65935
66198
|
icon,
|
|
65936
66199
|
ensureChats,
|
|
@@ -66686,7 +66949,6 @@ const randomName = () => `thread-${randomUUID().slice(0, 5)}`;
|
|
|
66686
66949
|
const ThreadRow$1 = Struct({
|
|
66687
66950
|
...Thread.fields,
|
|
66688
66951
|
fastMode: BooleanFromBit,
|
|
66689
|
-
userSkills: BooleanFromBit,
|
|
66690
66952
|
usageLimit: NullOr(fromJsonString(UsageLimit)),
|
|
66691
66953
|
forkedFrom: NullOr(fromJsonString(ForkPoint)),
|
|
66692
66954
|
queue: fromJsonString(ArraySchema(QueuedMessage)),
|
|
@@ -66703,7 +66965,6 @@ const arranging = /* @__PURE__ */ new Set([
|
|
|
66703
66965
|
"model",
|
|
66704
66966
|
"effort",
|
|
66705
66967
|
"fastMode",
|
|
66706
|
-
"userSkills",
|
|
66707
66968
|
"accessMode"
|
|
66708
66969
|
]);
|
|
66709
66970
|
const startsWork = (from, to) => (from === "idle" || from === "limited") && to === "running" || from === "archived" && to !== "archived";
|
|
@@ -66761,10 +67022,14 @@ const make$U = gen(function* () {
|
|
|
66761
67022
|
Result: Struct({ next: Number$2 }),
|
|
66762
67023
|
execute: (projectId) => sql`SELECT COALESCE(MAX(sort_index) + 1, 0) AS next FROM thread WHERE project_id = ${projectId}`
|
|
66763
67024
|
});
|
|
66764
|
-
const
|
|
66765
|
-
Request: Struct({ threadId: String$1, messageId: String$1 }),
|
|
66766
|
-
Result: Struct({ forkPoint: fromJsonString(ForkPoint) }),
|
|
66767
|
-
execute: ({ threadId, messageId }) => sql`
|
|
67025
|
+
const findForkPoints = findAll({
|
|
67026
|
+
Request: Struct({ threadId: String$1, messageId: NullOr(String$1) }),
|
|
67027
|
+
Result: Struct({ id: String$1, forkPoint: fromJsonString(ForkPoint) }),
|
|
67028
|
+
execute: ({ threadId, messageId }) => sql`
|
|
67029
|
+
SELECT id, fork_point FROM message
|
|
67030
|
+
WHERE thread_id = ${threadId} AND fork_point IS NOT NULL AND (${messageId} IS NULL OR id = ${messageId})
|
|
67031
|
+
ORDER BY created_at DESC, rowid DESC
|
|
67032
|
+
`
|
|
66768
67033
|
});
|
|
66769
67034
|
const findTurnBase = findOneOption({
|
|
66770
67035
|
Request: String$1,
|
|
@@ -66796,7 +67061,7 @@ const make$U = gen(function* () {
|
|
|
66796
67061
|
)
|
|
66797
67062
|
);
|
|
66798
67063
|
const insertThread = ({ worktree: worktreeInput, createdBy = "user", effort = null, fastMode = false, parentId, ...input }, status) => gen(function* () {
|
|
66799
|
-
|
|
67064
|
+
yield* projects.get(input.projectId);
|
|
66800
67065
|
const parent = parentId === void 0 ? void 0 : yield* get2(parentId);
|
|
66801
67066
|
const worktree = worktreeInput ? yield* worktrees.create({ projectId: input.projectId, ...worktreeInput }) : void 0;
|
|
66802
67067
|
const { next } = yield* nextSortIndex(input.projectId).pipe(mapError(persistence("threads.create")));
|
|
@@ -66808,7 +67073,6 @@ const make$U = gen(function* () {
|
|
|
66808
67073
|
worktreeId: worktree?.id ?? null,
|
|
66809
67074
|
effort,
|
|
66810
67075
|
fastMode,
|
|
66811
|
-
userSkills: project2.kind === "folder",
|
|
66812
67076
|
accessMode: defaultAccessMode,
|
|
66813
67077
|
accountId: defaultAccount[input.provider],
|
|
66814
67078
|
providerSessionId: null,
|
|
@@ -66875,11 +67139,13 @@ const make$U = gen(function* () {
|
|
|
66875
67139
|
});
|
|
66876
67140
|
const fork2 = (threadId, messageId) => gen(function* () {
|
|
66877
67141
|
const source = yield* get2(threadId);
|
|
66878
|
-
const
|
|
66879
|
-
|
|
66880
|
-
|
|
66881
|
-
const
|
|
66882
|
-
if (
|
|
67142
|
+
const points = yield* findForkPoints({ threadId, messageId: messageId ?? null }).pipe(
|
|
67143
|
+
mapError(persistence("threads.fork"))
|
|
67144
|
+
);
|
|
67145
|
+
const found2 = points.find((point) => (point.forkPoint.owner?.provider ?? source.provider) === source.provider);
|
|
67146
|
+
if (found2 === void 0) return yield* new NotFoundError({ entity: "fork point", id: messageId ?? threadId });
|
|
67147
|
+
const { owner: owner2, ...forkedFrom } = found2.forkPoint;
|
|
67148
|
+
const { accountId } = owner2 ?? source;
|
|
66883
67149
|
if (accountId !== null) yield* accounts.get(accountId);
|
|
66884
67150
|
const { next } = yield* nextSortIndex(source.projectId).pipe(mapError(persistence("threads.fork")));
|
|
66885
67151
|
const worktreeId = yield* forkWorktree(source);
|
|
@@ -66915,7 +67181,7 @@ const make$U = gen(function* () {
|
|
|
66915
67181
|
SELECT lower(hex(randomblob(16))), ${thread2.id}, role, parts, created_at, completed_at, usage, fork_point
|
|
66916
67182
|
FROM message
|
|
66917
67183
|
WHERE thread_id = ${threadId}
|
|
66918
|
-
AND (created_at, rowid) <= (SELECT created_at, rowid FROM message WHERE id = ${
|
|
67184
|
+
AND (created_at, rowid) <= (SELECT created_at, rowid FROM message WHERE id = ${found2.id})
|
|
66919
67185
|
ORDER BY created_at, rowid
|
|
66920
67186
|
`;
|
|
66921
67187
|
})
|
|
@@ -66965,7 +67231,6 @@ const make$U = gen(function* () {
|
|
|
66965
67231
|
fastMode: parent.fastMode
|
|
66966
67232
|
},
|
|
66967
67233
|
worktreeId: parent.worktreeId,
|
|
66968
|
-
userSkills: parent.userSkills,
|
|
66969
67234
|
accountId: forkPoint?.owner?.accountId ?? parent.accountId,
|
|
66970
67235
|
forkedFrom: forkPoint === null ? null : { sessionId: forkPoint.sessionId, checkpoint: forkPoint.checkpoint },
|
|
66971
67236
|
updatedAt: yield* nowIso
|
|
@@ -66973,13 +67238,14 @@ const make$U = gen(function* () {
|
|
|
66973
67238
|
yield* sql`
|
|
66974
67239
|
UPDATE thread
|
|
66975
67240
|
SET worktree_id = ${next.worktreeId}, provider = ${next.provider}, model = ${next.model}, effort = ${next.effort},
|
|
66976
|
-
fast_mode = ${next.fastMode ? 1 : 0},
|
|
67241
|
+
fast_mode = ${next.fastMode ? 1 : 0}, account_id = ${next.accountId},
|
|
66977
67242
|
forked_from = ${next.forkedFrom === null ? null : JSON.stringify(next.forkedFrom)}, updated_at = ${next.updatedAt}
|
|
66978
67243
|
WHERE id = ${id2}
|
|
66979
67244
|
`.pipe(mapError(persistence("threads.rebaseSidechat")));
|
|
66980
67245
|
return next;
|
|
66981
67246
|
});
|
|
66982
|
-
const update2 = (input) =>
|
|
67247
|
+
const update2 = (input) => input.pinned === true ? worktrees.exclusive(updateNow(input)) : updateNow(input);
|
|
67248
|
+
const updateNow = (input) => gen(function* () {
|
|
66983
67249
|
const current = yield* get2(input.id);
|
|
66984
67250
|
const switchesAgent = input.provider !== void 0 && input.provider !== current.provider;
|
|
66985
67251
|
const provider = input.provider ?? current.provider;
|
|
@@ -67006,7 +67272,6 @@ const make$U = gen(function* () {
|
|
|
67006
67272
|
model: input.model ?? current.model,
|
|
67007
67273
|
effort: input.effort === void 0 ? current.effort : input.effort,
|
|
67008
67274
|
fastMode: input.fastMode ?? current.fastMode,
|
|
67009
|
-
userSkills: input.userSkills ?? current.userSkills,
|
|
67010
67275
|
accessMode: input.accessMode ?? current.accessMode,
|
|
67011
67276
|
status: input.status ?? current.status,
|
|
67012
67277
|
usageLimit: input.status !== void 0 && input.status !== "limited" ? null : input.usageLimit === void 0 ? current.usageLimit : input.usageLimit,
|
|
@@ -67023,7 +67288,7 @@ const make$U = gen(function* () {
|
|
|
67023
67288
|
yield* sql`
|
|
67024
67289
|
UPDATE thread
|
|
67025
67290
|
SET title = ${next.title}, provider = ${next.provider}, account_id = ${next.accountId}, model = ${next.model},
|
|
67026
|
-
effort = ${next.effort}, fast_mode = ${next.fastMode ? 1 : 0},
|
|
67291
|
+
effort = ${next.effort}, fast_mode = ${next.fastMode ? 1 : 0},
|
|
67027
67292
|
access_mode = ${next.accessMode}, status = ${next.status},
|
|
67028
67293
|
sort_index = ${next.sortIndex}, pinned_at = ${next.pinnedAt}, snoozed_until = ${next.snoozedUntil}, settled_at = ${next.settledAt},
|
|
67029
67294
|
provider_session_id = ${next.providerSessionId},
|
|
@@ -67151,10 +67416,11 @@ const make$U = gen(function* () {
|
|
|
67151
67416
|
)
|
|
67152
67417
|
);
|
|
67153
67418
|
});
|
|
67154
|
-
const
|
|
67419
|
+
const archiveIf = (id2, stillDue) => worktrees.exclusive(
|
|
67155
67420
|
gen(function* () {
|
|
67156
67421
|
const thread2 = yield* get2(id2);
|
|
67157
67422
|
if (isThreadBusy(thread2.status)) return yield* new ThreadBusyError({ id: id2 });
|
|
67423
|
+
if (!(yield* stillDue(thread2))) return none();
|
|
67158
67424
|
yield* removeWorktreeIfSet(thread2);
|
|
67159
67425
|
yield* terminals.closeThread(id2);
|
|
67160
67426
|
yield* sql`
|
|
@@ -67163,9 +67429,10 @@ const make$U = gen(function* () {
|
|
|
67163
67429
|
yield* detachChildren(id2);
|
|
67164
67430
|
yield* syncChatFolder(thread2, false);
|
|
67165
67431
|
yield* scratch.remove(id2);
|
|
67166
|
-
return yield* get2(id2);
|
|
67432
|
+
return some(yield* get2(id2));
|
|
67167
67433
|
})
|
|
67168
67434
|
);
|
|
67435
|
+
const archive2 = (id2) => archiveIf(id2, () => succeed$1(true)).pipe(map$2(getOrThrow$1));
|
|
67169
67436
|
const unarchive = (id2) => gen(function* () {
|
|
67170
67437
|
const thread2 = yield* get2(id2);
|
|
67171
67438
|
yield* syncChatFolder(thread2, true);
|
|
@@ -67191,9 +67458,11 @@ const make$U = gen(function* () {
|
|
|
67191
67458
|
return some(yield* write(after.value, { id: id2, settled: true }));
|
|
67192
67459
|
})
|
|
67193
67460
|
);
|
|
67194
|
-
const unsettle = (id2) =>
|
|
67195
|
-
|
|
67196
|
-
|
|
67461
|
+
const unsettle = (id2) => worktrees.exclusive(
|
|
67462
|
+
gen(function* () {
|
|
67463
|
+
return yield* write(yield* get2(id2), { id: id2, settled: false });
|
|
67464
|
+
})
|
|
67465
|
+
);
|
|
67197
67466
|
const workStartedAt = (id2) => sql`SELECT work_started_at AS startedAt FROM thread WHERE id = ${id2}`.pipe(
|
|
67198
67467
|
map$2((rows) => rows[0]?.startedAt ?? null),
|
|
67199
67468
|
mapError(persistence("threads.workStartedAt"))
|
|
@@ -67226,6 +67495,7 @@ const make$U = gen(function* () {
|
|
|
67226
67495
|
captureTurnBase,
|
|
67227
67496
|
recordTurnBase,
|
|
67228
67497
|
archive: archive2,
|
|
67498
|
+
archiveIf,
|
|
67229
67499
|
unarchive,
|
|
67230
67500
|
settle: settle2,
|
|
67231
67501
|
settleMerged,
|
|
@@ -67414,6 +67684,7 @@ const MIME_BY_EXTENSION = {
|
|
|
67414
67684
|
".jpeg": "image/jpeg",
|
|
67415
67685
|
".gif": "image/gif",
|
|
67416
67686
|
".webp": "image/webp",
|
|
67687
|
+
".svg": "image/svg+xml",
|
|
67417
67688
|
".pdf": "application/pdf",
|
|
67418
67689
|
".txt": "text/plain",
|
|
67419
67690
|
".md": "text/markdown",
|
|
@@ -67432,6 +67703,7 @@ class AttachmentError extends TaggedError$1()("AttachmentError", {
|
|
|
67432
67703
|
}) {
|
|
67433
67704
|
}
|
|
67434
67705
|
const safeName = (name) => basename(name).replace(/[^\w.-]+/g, "_").slice(-100) || "file";
|
|
67706
|
+
const extensionOf$1 = (mime) => Object.entries(MIME_BY_EXTENSION).find(([, known]) => known === mime)?.[0] ?? "";
|
|
67435
67707
|
const mimeOf$1 = (name) => MIME_BY_EXTENSION[extname(name).toLowerCase()] ?? "application/octet-stream";
|
|
67436
67708
|
const decodeDataUrl = (dataUrl2) => {
|
|
67437
67709
|
const match2 = /^data:([^;,]+);base64,(.*)$/s.exec(dataUrl2);
|
|
@@ -67494,10 +67766,13 @@ const SUGGESTION_JSON_SCHEMA = {
|
|
|
67494
67766
|
required: ["title", "branch"],
|
|
67495
67767
|
additionalProperties: false
|
|
67496
67768
|
};
|
|
67497
|
-
const SYSTEM_PROMPT = `You name coding tasks in a developer's sidebar. Given the
|
|
67769
|
+
const SYSTEM_PROMPT = `You name coding tasks in a developer's sidebar. Given the developer's messages in a task, reply with:
|
|
67498
67770
|
- title: at most 50 characters, sentence case, no trailing period, in the language of the message
|
|
67499
67771
|
- branch: 2 to 5 lowercase English words joined by hyphens, with no prefix`;
|
|
67500
67772
|
const PROMPT_LIMIT = 4e3;
|
|
67773
|
+
const ELISION = "\n\n[…]\n\n";
|
|
67774
|
+
const HALF_LIMIT = Math.floor((PROMPT_LIMIT - ELISION.length) / 2);
|
|
67775
|
+
const firstAndLatest = (text2) => text2.length <= PROMPT_LIMIT ? text2 : `${text2.slice(0, HALF_LIMIT)}${ELISION}${text2.slice(-HALF_LIMIT)}`;
|
|
67501
67776
|
class ThreadNaming extends Service$1()("hinacode/ThreadNaming") {
|
|
67502
67777
|
}
|
|
67503
67778
|
const suggest$1 = (model, prompt) => gen(function* () {
|
|
@@ -67508,7 +67783,7 @@ const suggest$1 = (model, prompt) => gen(function* () {
|
|
|
67508
67783
|
signal2.addEventListener("abort", () => abortController.abort());
|
|
67509
67784
|
const { query } = await import("./chunks/sdk-BjcPK2t_.js");
|
|
67510
67785
|
const stream2 = query({
|
|
67511
|
-
prompt: prompt
|
|
67786
|
+
prompt: firstAndLatest(prompt),
|
|
67512
67787
|
options: {
|
|
67513
67788
|
env: { ...process.env },
|
|
67514
67789
|
pathToClaudeCodeExecutable,
|
|
@@ -67535,12 +67810,18 @@ const suggest$1 = (model, prompt) => gen(function* () {
|
|
|
67535
67810
|
})
|
|
67536
67811
|
}).pipe(timeout(seconds(60)));
|
|
67537
67812
|
return yield* decodeUnknownEffect(Suggestion)(output);
|
|
67538
|
-
})
|
|
67813
|
+
}).pipe(
|
|
67814
|
+
mapError(
|
|
67815
|
+
(cause) => cause instanceof AgentError ? cause : new AgentError({ provider: "claude", message: `Failed to name thread: ${cause.message}` })
|
|
67816
|
+
)
|
|
67817
|
+
);
|
|
67818
|
+
const userText = (messages) => messages.filter((message2) => message2.role === "user").map((message2) => message2.parts.flatMap((part) => part.type === "text" ? [part.text] : []).join("\n")).filter((text2) => text2.trim() !== "").join("\n\n---\n\n");
|
|
67539
67819
|
const make$S = gen(function* () {
|
|
67540
67820
|
const threads = yield* Threads;
|
|
67541
67821
|
const worktrees = yield* Worktrees;
|
|
67542
67822
|
const settings = yield* Settings;
|
|
67543
67823
|
const events2 = yield* Events;
|
|
67824
|
+
const messages = yield* Messages;
|
|
67544
67825
|
const nameFromPrompt = (thread2, prompt, scope2) => gen(function* () {
|
|
67545
67826
|
const { textGenerationModel } = yield* settings.get;
|
|
67546
67827
|
const suggestion = yield* suggest$1(textGenerationModel, prompt);
|
|
@@ -67555,7 +67836,19 @@ const make$S = gen(function* () {
|
|
|
67555
67836
|
yield* worktrees.renameBranch(current.worktreeId, `kk/${branch}`);
|
|
67556
67837
|
}
|
|
67557
67838
|
}).pipe(catchCause((cause) => logWarning("thread naming failed", cause)));
|
|
67558
|
-
|
|
67839
|
+
const regenerateTitle = (threadId) => gen(function* () {
|
|
67840
|
+
const before = yield* threads.get(threadId);
|
|
67841
|
+
const prompt = userText(yield* messages.list(threadId));
|
|
67842
|
+
if (prompt === "") return before;
|
|
67843
|
+
const { textGenerationModel } = yield* settings.get;
|
|
67844
|
+
const title2 = (yield* suggest$1(textGenerationModel, prompt)).title.trim();
|
|
67845
|
+
const current = yield* threads.get(threadId);
|
|
67846
|
+
if (title2 === "" || title2 === current.title || current.title !== before.title) return current;
|
|
67847
|
+
const renamed = yield* threads.update({ id: threadId, title: title2 });
|
|
67848
|
+
yield* events2.publish({ type: "thread.updated", thread: renamed });
|
|
67849
|
+
return renamed;
|
|
67850
|
+
});
|
|
67851
|
+
return ThreadNaming.of({ nameFromPrompt, regenerateTitle });
|
|
67559
67852
|
});
|
|
67560
67853
|
const layer$y = effect(ThreadNaming, make$S);
|
|
67561
67854
|
const PERSIST_INTERVAL_MS = 500;
|
|
@@ -67621,7 +67914,7 @@ const savedImage = (threadId, attachments, record2) => {
|
|
|
67621
67914
|
const mimeType = source["mimeType"] ?? source["media_type"];
|
|
67622
67915
|
const data = source["data"];
|
|
67623
67916
|
if (typeof mimeType !== "string" || typeof data !== "string") return succeed$1({ type: "image", mimeType });
|
|
67624
|
-
const name = `image
|
|
67917
|
+
const name = `image${extensionOf$1(mimeType)}`;
|
|
67625
67918
|
return attachments.stage(threadId, { dataUrl: `data:${mimeType};base64,${data}`, name }).pipe(
|
|
67626
67919
|
map$2((attachment2) => ({ type: "image", mimeType, attachment: attachment2 })),
|
|
67627
67920
|
orElseSucceed(() => ({ type: "image", mimeType }))
|
|
@@ -67708,6 +68001,7 @@ const make$R = gen(function* () {
|
|
|
67708
68001
|
const waitsOnUser = (threadId) => [...approvals2.values(), ...questions.values(), ...[...secretRequests.values()].map(({ request: request2 }) => request2)].some(
|
|
67709
68002
|
(request2) => request2.threadId === threadId
|
|
67710
68003
|
);
|
|
68004
|
+
const isBusy = (threadId) => busyThreads.has(threadId) || activeTurns.has(threadId) || pendingSends.has(threadId);
|
|
67711
68005
|
const exclusive = (threadId) => (effect2) => {
|
|
67712
68006
|
let lock = threadLocks.get(threadId);
|
|
67713
68007
|
if (lock === void 0) threadLocks.set(threadId, lock = makeUnsafe$8(1));
|
|
@@ -67816,7 +68110,6 @@ const make$R = gen(function* () {
|
|
|
67816
68110
|
effort: thread2.effort,
|
|
67817
68111
|
fastMode: thread2.fastMode,
|
|
67818
68112
|
autoCompactTokens: autoCompactTokens[provider.id],
|
|
67819
|
-
userSkills: thread2.userSkills,
|
|
67820
68113
|
accessMode: thread2.accessMode,
|
|
67821
68114
|
resumeSessionId: thread2.providerSessionId ?? thread2.forkedFrom?.sessionId ?? null,
|
|
67822
68115
|
forkAt: thread2.providerSessionId === null ? thread2.forkedFrom?.checkpoint ?? null : null,
|
|
@@ -67986,7 +68279,11 @@ const make$R = gen(function* () {
|
|
|
67986
68279
|
const follow = (events2) => runForEach(events2, handle).pipe(
|
|
67987
68280
|
catchTag(
|
|
67988
68281
|
"AgentError",
|
|
67989
|
-
({ message: message2, loginCommand
|
|
68282
|
+
({ message: message2, loginCommand }) => handle({
|
|
68283
|
+
type: "turn_failed",
|
|
68284
|
+
message: message2,
|
|
68285
|
+
...loginCommand !== void 0 && { signedOut: true, loginCommand }
|
|
68286
|
+
})
|
|
67990
68287
|
),
|
|
67991
68288
|
catch_((error2) => logError("turn bookkeeping failed", error2)),
|
|
67992
68289
|
ensuring(finish)
|
|
@@ -68133,7 +68430,6 @@ const make$R = gen(function* () {
|
|
|
68133
68430
|
effort: request2.effort ?? null,
|
|
68134
68431
|
fastMode: false,
|
|
68135
68432
|
autoCompactTokens: autoCompactTokens[provider.id],
|
|
68136
|
-
userSkills: thread2.userSkills,
|
|
68137
68433
|
accessMode: thread2.accessMode,
|
|
68138
68434
|
resumeSessionId: null,
|
|
68139
68435
|
forkAt: null,
|
|
@@ -68685,19 +68981,32 @@ const make$R = gen(function* () {
|
|
|
68685
68981
|
yield* closeProviderSession(yield* threads.get(threadId));
|
|
68686
68982
|
}).pipe(exclusive(threadId));
|
|
68687
68983
|
}).pipe(catch_((error2) => logError("failed to retire the wakeup of a stopped thread", error2)));
|
|
68688
|
-
const
|
|
68984
|
+
const stopSubagentsAndTasks = (threadId, stops) => gen(function* () {
|
|
68689
68985
|
const running2 = listSubagents(threadId).filter((subagent2) => subagent2.status === "running");
|
|
68690
68986
|
yield* forEach(running2, (subagent2) => stopSubagent(threadId, subagent2.id).pipe(ignore$1), {
|
|
68691
68987
|
discard: true
|
|
68692
68988
|
});
|
|
68693
|
-
const tasks = (backgroundTasks.get(threadId) ?? []).filter(
|
|
68694
|
-
(task) => task.kind !== "wakeup" && task.kind !== "shell"
|
|
68695
|
-
);
|
|
68989
|
+
const tasks = (backgroundTasks.get(threadId) ?? []).filter((task) => task.kind !== "wakeup" && stops(task));
|
|
68696
68990
|
yield* forEach(tasks, (task) => stopBackgroundTask(threadId, task.id).pipe(ignore$1), {
|
|
68697
68991
|
discard: true
|
|
68698
68992
|
});
|
|
68993
|
+
});
|
|
68994
|
+
const stopBackgroundWork = (threadId) => gen(function* () {
|
|
68995
|
+
yield* stopSubagentsAndTasks(threadId, (task) => task.kind !== "shell");
|
|
68699
68996
|
if (hasPendingWakeup(threadId)) yield* forkIn(closeSessionAfterTurn(threadId), scope2);
|
|
68700
68997
|
});
|
|
68998
|
+
const release2 = (threadId, whileIdle) => gen(function* () {
|
|
68999
|
+
if (isBusy(threadId)) return none();
|
|
69000
|
+
yield* stopSubagentsAndTasks(threadId, () => true);
|
|
69001
|
+
return yield* gen(function* () {
|
|
69002
|
+
if (isBusy(threadId)) return none();
|
|
69003
|
+
yield* threads.get(threadId).pipe(
|
|
69004
|
+
flatMap(closeProviderSession),
|
|
69005
|
+
catch_((error2) => logWarning("failed to close the session of a settled thread", error2))
|
|
69006
|
+
);
|
|
69007
|
+
return some(yield* whileIdle);
|
|
69008
|
+
}).pipe(exclusive(threadId));
|
|
69009
|
+
});
|
|
68701
69010
|
const requestSecret = (threadId, name, description2) => gen(function* () {
|
|
68702
69011
|
const turn = activeTurns.get(threadId);
|
|
68703
69012
|
if (turn === void 0) {
|
|
@@ -68725,7 +69034,7 @@ const make$R = gen(function* () {
|
|
|
68725
69034
|
yield* succeed$3(pending.answer, path2);
|
|
68726
69035
|
});
|
|
68727
69036
|
const warm = (threadId) => gen(function* () {
|
|
68728
|
-
if (
|
|
69037
|
+
if (isBusy(threadId)) return;
|
|
68729
69038
|
const thread2 = yield* threads.get(threadId);
|
|
68730
69039
|
if (thread2.status === "archived") return;
|
|
68731
69040
|
if (thread2.sideOf !== null && !(yield* threads.started(threadId))) return;
|
|
@@ -68760,6 +69069,7 @@ const make$R = gen(function* () {
|
|
|
68760
69069
|
})
|
|
68761
69070
|
)
|
|
68762
69071
|
),
|
|
69072
|
+
release: release2,
|
|
68763
69073
|
warm,
|
|
68764
69074
|
setAccessMode: (threadId, accessMode) => gen(function* () {
|
|
68765
69075
|
const turn = activeTurns.get(threadId);
|
|
@@ -68862,6 +69172,10 @@ The screenshot shows the top of the page as the developer first sees it.`;
|
|
|
68862
69172
|
};
|
|
68863
69173
|
const MANIFEST = "artifact.json";
|
|
68864
69174
|
const ANNOUNCE_DEBOUNCE_MS = 50;
|
|
69175
|
+
class DocumentImageError extends TaggedError$1()("DocumentImageError", {
|
|
69176
|
+
message: String$1
|
|
69177
|
+
}) {
|
|
69178
|
+
}
|
|
68865
69179
|
class Artifacts extends Service$1()("hinacode/Artifacts") {
|
|
68866
69180
|
}
|
|
68867
69181
|
const manifestOwner = (name) => {
|
|
@@ -68960,6 +69274,23 @@ const make$Q = (root2) => gen(function* () {
|
|
|
68960
69274
|
() => promise$1(() => announce2(id2))
|
|
68961
69275
|
)
|
|
68962
69276
|
);
|
|
69277
|
+
const addDocumentImage = ({ id: id2, dataUrl: dataUrl2 }) => gen(function* () {
|
|
69278
|
+
const decoded = decodeDataUrl(dataUrl2);
|
|
69279
|
+
if (decoded === void 0) {
|
|
69280
|
+
return yield* new DocumentImageError({ message: "The pasted image is not a base64 data URL." });
|
|
69281
|
+
}
|
|
69282
|
+
const current = yield* promise$1(() => store2.get(id2));
|
|
69283
|
+
if (current === null) return yield* new NotFoundError({ entity: "document", id: id2 });
|
|
69284
|
+
const path2 = yield* tryPromise({
|
|
69285
|
+
try: () => store2.addDocumentImage(id2, { bytes: decoded.data, type: decoded.mime }),
|
|
69286
|
+
catch: (cause) => cause
|
|
69287
|
+
}).pipe(
|
|
69288
|
+
catch_(
|
|
69289
|
+
(cause) => cause instanceof ArtifactError ? fail$2(new DocumentImageError({ message: cause.message })) : die(cause)
|
|
69290
|
+
)
|
|
69291
|
+
);
|
|
69292
|
+
return { path: path2 };
|
|
69293
|
+
});
|
|
68963
69294
|
return Artifacts.of({
|
|
68964
69295
|
store: store2,
|
|
68965
69296
|
list: promise$1(() => store2.list()),
|
|
@@ -68969,7 +69300,8 @@ const make$Q = (root2) => gen(function* () {
|
|
|
68969
69300
|
readDocument,
|
|
68970
69301
|
saveDocument,
|
|
68971
69302
|
createDocument,
|
|
68972
|
-
rename: rename2
|
|
69303
|
+
rename: rename2,
|
|
69304
|
+
addDocumentImage
|
|
68973
69305
|
});
|
|
68974
69306
|
});
|
|
68975
69307
|
const layer$w = (root2) => effect(Artifacts, make$Q(root2));
|
|
@@ -70369,6 +70701,7 @@ const learnFromAnswer = (owners, environmentId, method2, payload, result2) => {
|
|
|
70369
70701
|
case "threads.unarchive":
|
|
70370
70702
|
case "threads.settle":
|
|
70371
70703
|
case "threads.unsettle":
|
|
70704
|
+
case "threads.regenerateTitle":
|
|
70372
70705
|
case "threads.sidechat":
|
|
70373
70706
|
return each(result2, learnId(teach, "thread"));
|
|
70374
70707
|
case "worktrees.list":
|
|
@@ -88401,7 +88734,7 @@ const renderPart = (part) => {
|
|
|
88401
88734
|
case "agent_switch":
|
|
88402
88735
|
return `[agent switched: ${part.from} → ${part.to}]`;
|
|
88403
88736
|
case "signed_out":
|
|
88404
|
-
return `**Error:** ${part.message}. Sign in with \`${part.loginCommand}\``;
|
|
88737
|
+
return part.loginCommand === void 0 ? `**Error:** ${part.message}. Sign in as the model provider's documentation describes.` : `**Error:** ${part.message}. Sign in with \`${part.loginCommand}\``;
|
|
88405
88738
|
case "session_import":
|
|
88406
88739
|
return part.history === "replayed" ? `[imported ${part.provider} session]` : `[imported ${part.provider} session, earlier history not shown]`;
|
|
88407
88740
|
}
|
|
@@ -89132,7 +89465,9 @@ const installCloudflared = (dir, asset, fetch2) => tryPromise({
|
|
|
89132
89465
|
},
|
|
89133
89466
|
catch: (error2) => new CloudflaredInstallError({ message: error2 instanceof Error ? error2.message : String(error2) })
|
|
89134
89467
|
});
|
|
89135
|
-
const EXPIRED = "The sign-in link expired.
|
|
89468
|
+
const EXPIRED = "The sign-in link expired. Link this machine again.";
|
|
89469
|
+
const SIGN_IN_USED = "The sign-in expired or was already used. Sign in again.";
|
|
89470
|
+
const DENIED = "The link was denied in the browser.";
|
|
89136
89471
|
const CALL_TIMEOUT = seconds(30);
|
|
89137
89472
|
class RelayError extends TaggedError$1()("RelayError", { message: String$1 }) {
|
|
89138
89473
|
}
|
|
@@ -89144,10 +89479,14 @@ const Link = Struct({
|
|
|
89144
89479
|
expiresAt: Number$2
|
|
89145
89480
|
});
|
|
89146
89481
|
const Claimed = Struct({ credential: String$1 });
|
|
89147
|
-
const Profile = Struct({
|
|
89482
|
+
const Profile = Struct({
|
|
89483
|
+
name: NullOr(String$1),
|
|
89484
|
+
email: NullOr(String$1),
|
|
89485
|
+
imageUrl: optionalKey(NullOr(String$1))
|
|
89486
|
+
});
|
|
89148
89487
|
const Tunnel = Struct({ hostname: String$1, connectorToken: String$1 });
|
|
89149
89488
|
const ServiceFailure = Struct({ error: String$1 });
|
|
89150
|
-
const forgotten = () => new RelayError({ message: "The relay service no longer knows this machine.
|
|
89489
|
+
const forgotten = () => new RelayError({ message: "The relay service no longer knows this machine. Link it again." });
|
|
89151
89490
|
const refusedDevice = () => new RelayError({
|
|
89152
89491
|
message: "The relay no longer accepts this device. Log out and sign in again."
|
|
89153
89492
|
});
|
|
@@ -89199,11 +89538,15 @@ const relayService = (fetch2, serviceUrl) => {
|
|
|
89199
89538
|
createLink: (environmentId, name) => call2("start linking", "POST", "/v1/links", { body: { environmentId, name } }).pipe(
|
|
89200
89539
|
flatMap((answer) => decode$1("start linking", Link, answer))
|
|
89201
89540
|
),
|
|
89202
|
-
|
|
89203
|
-
flatMap(
|
|
89541
|
+
exchangeSignInCode: (code2, codeVerifier) => call2("finish signing in", "POST", "/v1/sign-in-codes/exchange", { body: { code: code2, codeVerifier } }).pipe(
|
|
89542
|
+
flatMap(
|
|
89543
|
+
(answer) => answer.status === 410 ? fail$2(new RelayError({ message: SIGN_IN_USED })) : decode$1("finish signing in", Claimed, answer)
|
|
89544
|
+
),
|
|
89545
|
+
map$2(({ credential }) => credential)
|
|
89204
89546
|
),
|
|
89205
89547
|
profile: (credential) => asAccount("read your account", "GET", "/v1/account", credential).pipe(
|
|
89206
|
-
flatMap((answer) => decode$1("read your account", Profile, answer))
|
|
89548
|
+
flatMap((answer) => decode$1("read your account", Profile, answer)),
|
|
89549
|
+
map$2((profile) => ({ ...profile, imageUrl: profile.imageUrl ?? null }))
|
|
89207
89550
|
),
|
|
89208
89551
|
signOutDevice: (credential) => call2("sign out this device", "DELETE", "/v1/device", { credential }).pipe(
|
|
89209
89552
|
flatMap((answer) => answer.status === 401 ? void_ : succeeded("sign out this device")(answer))
|
|
@@ -89212,6 +89555,7 @@ const relayService = (fetch2, serviceUrl) => {
|
|
|
89212
89555
|
flatMap((answer) => {
|
|
89213
89556
|
if (answer.status === 202) return succeedNone;
|
|
89214
89557
|
if (answer.status === 410) return fail$2(new RelayError({ message: EXPIRED }));
|
|
89558
|
+
if (answer.status === 403) return fail$2(new RelayError({ message: DENIED }));
|
|
89215
89559
|
return map$2(decode$1("finish linking", Claimed, answer), ({ credential }) => some(credential));
|
|
89216
89560
|
})
|
|
89217
89561
|
),
|
|
@@ -89334,7 +89678,7 @@ const make$a = ({
|
|
|
89334
89678
|
yield* putTunnel(
|
|
89335
89679
|
yield* requireSecret(
|
|
89336
89680
|
CREDENTIAL_SECRET,
|
|
89337
|
-
"This machine's relay sign-in is gone, so the tunnel cannot follow the listener.
|
|
89681
|
+
"This machine's relay sign-in is gone, so the tunnel cannot follow the listener. Link this machine again."
|
|
89338
89682
|
)
|
|
89339
89683
|
);
|
|
89340
89684
|
});
|
|
@@ -89346,7 +89690,7 @@ const make$a = ({
|
|
|
89346
89690
|
if (published === tunnel.published) return;
|
|
89347
89691
|
const credential = yield* requireSecret(
|
|
89348
89692
|
CREDENTIAL_SECRET,
|
|
89349
|
-
"This machine's relay sign-in is gone, so its pairing cannot be published.
|
|
89693
|
+
"This machine's relay sign-in is gone, so its pairing cannot be published. Link this machine again."
|
|
89350
89694
|
);
|
|
89351
89695
|
yield* service2.publishPairing(credential, pairing);
|
|
89352
89696
|
yield* save({ ...tunnel, published });
|
|
@@ -89397,7 +89741,7 @@ const make$a = ({
|
|
|
89397
89741
|
yield* routed(tunnel ?? stored);
|
|
89398
89742
|
const token = yield* requireSecret(
|
|
89399
89743
|
CONNECTOR_TOKEN_SECRET,
|
|
89400
|
-
"The tunnel's connector token is gone.
|
|
89744
|
+
"The tunnel's connector token is gone. Link this machine again."
|
|
89401
89745
|
);
|
|
89402
89746
|
const first = yield* runOnce(binary, hostname2, token);
|
|
89403
89747
|
if (first.type !== "missing" || binary !== cloudflared || cloudflaredDir === void 0) return first;
|
|
@@ -92553,8 +92897,57 @@ const idleLayer = succeed$5(
|
|
|
92553
92897
|
const DEVICE_CREDENTIAL_SECRET = "relay.deviceCredential";
|
|
92554
92898
|
const SYNC_INTERVAL = "5 minutes";
|
|
92555
92899
|
const SIGN_IN_EXPIRED = "The sign-in expired. Try again.";
|
|
92900
|
+
const SIGN_IN_TIMEOUT = minutes(10);
|
|
92556
92901
|
class RelayAccount extends Service$1()("hinacode/RelayAccount") {
|
|
92557
92902
|
}
|
|
92903
|
+
const listenForSignInCode = (signedInPage) => gen(function* () {
|
|
92904
|
+
const received = Promise.withResolvers();
|
|
92905
|
+
let answered = false;
|
|
92906
|
+
const listening2 = yield* acquireRelease(
|
|
92907
|
+
callback((resume) => {
|
|
92908
|
+
const server2 = createServer((request2, response2) => {
|
|
92909
|
+
const url2 = URL.parse(request2.url ?? "/", "http://127.0.0.1");
|
|
92910
|
+
if (url2 === null) return void response2.writeHead(400).end();
|
|
92911
|
+
const code2 = url2.searchParams.get("code");
|
|
92912
|
+
if (answered || url2.pathname !== "/callback" || !code2) return void response2.writeHead(404).end();
|
|
92913
|
+
answered = true;
|
|
92914
|
+
response2.writeHead(302, { Location: signedInPage.href }).end(() => received.resolve(code2));
|
|
92915
|
+
});
|
|
92916
|
+
server2.once(
|
|
92917
|
+
"error",
|
|
92918
|
+
(cause) => resume(fail$2(new RelayError({ message: `Cannot wait for the sign-in: ${cause.message}` })))
|
|
92919
|
+
);
|
|
92920
|
+
server2.listen(0, "127.0.0.1", () => resume(succeed$1(server2)));
|
|
92921
|
+
}),
|
|
92922
|
+
(stopping) => callback((resume) => {
|
|
92923
|
+
stopping.close(() => resume(void_));
|
|
92924
|
+
stopping.closeAllConnections();
|
|
92925
|
+
})
|
|
92926
|
+
);
|
|
92927
|
+
return {
|
|
92928
|
+
redirectUri: `http://127.0.0.1:${listening2.address().port}/callback`,
|
|
92929
|
+
code: promise$1(() => received.promise)
|
|
92930
|
+
};
|
|
92931
|
+
});
|
|
92932
|
+
const AVATAR_MAX_BYTES = 256 * 1024;
|
|
92933
|
+
const downloadAvatar = (fetch2, imageUrl) => gen(function* () {
|
|
92934
|
+
const url2 = URL.parse(imageUrl);
|
|
92935
|
+
if (url2?.protocol !== "https:") return yield* new RelayError({ message: "The avatar is not an https URL." });
|
|
92936
|
+
const response2 = yield* tryPromise({
|
|
92937
|
+
try: (signal2) => fetch2(url2, { signal: signal2 }),
|
|
92938
|
+
catch: () => new RelayError({ message: "Cannot download the avatar." })
|
|
92939
|
+
});
|
|
92940
|
+
const type2 = response2.headers.get("Content-Type") ?? "";
|
|
92941
|
+
if (!response2.ok || !type2.startsWith("image/")) {
|
|
92942
|
+
return yield* new RelayError({ message: `The avatar answered HTTP ${response2.status} with ${type2}.` });
|
|
92943
|
+
}
|
|
92944
|
+
const bytes = yield* tryPromise({
|
|
92945
|
+
try: () => response2.arrayBuffer(),
|
|
92946
|
+
catch: () => new RelayError({ message: "Cannot download the avatar." })
|
|
92947
|
+
});
|
|
92948
|
+
if (bytes.byteLength > AVATAR_MAX_BYTES) return yield* new RelayError({ message: "The avatar is too large." });
|
|
92949
|
+
return `data:${type2};base64,${Buffer.from(bytes).toString("base64")}`;
|
|
92950
|
+
}).pipe(timeout(seconds(30)));
|
|
92558
92951
|
const make$8 = ({ serviceUrl, fetch: fetch2 = globalThis.fetch }) => gen(function* () {
|
|
92559
92952
|
const service2 = relayService(fetch2, serviceUrl);
|
|
92560
92953
|
const secrets = yield* Secrets;
|
|
@@ -92565,11 +92958,13 @@ const make$8 = ({ serviceUrl, fetch: fetch2 = globalThis.fetch }) => gen(functio
|
|
|
92565
92958
|
const nobody = {
|
|
92566
92959
|
name: null,
|
|
92567
92960
|
email: null,
|
|
92961
|
+
avatar: null,
|
|
92568
92962
|
machines: 0,
|
|
92569
92963
|
syncedAt: null,
|
|
92570
92964
|
error: null
|
|
92571
92965
|
};
|
|
92572
92966
|
let last = nobody;
|
|
92967
|
+
let avatarUrl = null;
|
|
92573
92968
|
const signedIn = () => ({ state: "signedIn", serviceUrl, environmentId: self2.id, ...last });
|
|
92574
92969
|
const signedOut2 = { state: "signedOut" };
|
|
92575
92970
|
const status = map$2(secrets.has(DEVICE_CREDENTIAL_SECRET), (has2) => has2 ? signedIn() : signedOut2);
|
|
@@ -92578,35 +92973,45 @@ const make$8 = ({ serviceUrl, fetch: fetch2 = globalThis.fetch }) => gen(functio
|
|
|
92578
92973
|
last = { ...last, machines: kept, syncedAt: yield* nowIso, error: null };
|
|
92579
92974
|
return signedIn();
|
|
92580
92975
|
});
|
|
92976
|
+
const refreshAvatar = (imageUrl) => imageUrl === avatarUrl ? void_ : gen(function* () {
|
|
92977
|
+
const avatar = imageUrl === null ? null : yield* downloadAvatar(fetch2, imageUrl);
|
|
92978
|
+
last = { ...last, avatar };
|
|
92979
|
+
avatarUrl = imageUrl;
|
|
92980
|
+
});
|
|
92581
92981
|
const refreshProfile = (credential) => service2.profile(credential).pipe(
|
|
92582
92982
|
tap$1(
|
|
92583
92983
|
({ name, email: email2 }) => sync(() => {
|
|
92584
92984
|
last = { ...last, name, email: email2 };
|
|
92585
92985
|
})
|
|
92586
92986
|
),
|
|
92987
|
+
flatMap(({ imageUrl }) => refreshAvatar(imageUrl)),
|
|
92587
92988
|
catch_((error2) => logWarning("could not read the relay account", error2))
|
|
92588
92989
|
);
|
|
92589
|
-
const
|
|
92590
|
-
|
|
92591
|
-
|
|
92592
|
-
|
|
92593
|
-
|
|
92594
|
-
|
|
92595
|
-
|
|
92596
|
-
|
|
92597
|
-
|
|
92598
|
-
|
|
92599
|
-
|
|
92600
|
-
|
|
92601
|
-
|
|
92602
|
-
|
|
92603
|
-
|
|
92604
|
-
|
|
92605
|
-
|
|
92606
|
-
|
|
92607
|
-
|
|
92608
|
-
|
|
92609
|
-
);
|
|
92990
|
+
const receiveSignInCode = (openUrl, codeChallenge) => gen(function* () {
|
|
92991
|
+
const listener = yield* listenForSignInCode(new URL("/signed-in", serviceUrl));
|
|
92992
|
+
const page2 = new URL("/sign-in", serviceUrl);
|
|
92993
|
+
page2.searchParams.set("redirect_uri", listener.redirectUri);
|
|
92994
|
+
page2.searchParams.set("code_challenge", codeChallenge);
|
|
92995
|
+
page2.searchParams.set("name", self2.name);
|
|
92996
|
+
yield* openUrl(page2.href);
|
|
92997
|
+
return yield* listener.code;
|
|
92998
|
+
}).pipe(
|
|
92999
|
+
timeoutOrElse({
|
|
93000
|
+
duration: SIGN_IN_TIMEOUT,
|
|
93001
|
+
orElse: () => fail$2(new RelayError({ message: SIGN_IN_EXPIRED }))
|
|
93002
|
+
}),
|
|
93003
|
+
scoped
|
|
93004
|
+
);
|
|
93005
|
+
const signInThroughBrowser = (openUrl) => gen(function* () {
|
|
93006
|
+
const codeVerifier = randomBytes(32).toString("base64url");
|
|
93007
|
+
const codeChallenge = createHash("sha256").update(codeVerifier).digest("base64url");
|
|
93008
|
+
const code2 = yield* receiveSignInCode(openUrl, codeChallenge);
|
|
93009
|
+
const credential = yield* service2.exchangeSignInCode(code2, codeVerifier);
|
|
93010
|
+
yield* secrets.set(DEVICE_CREDENTIAL_SECRET, credential).pipe(lock.withPermit, uninterruptible);
|
|
93011
|
+
return yield* sync$12;
|
|
93012
|
+
});
|
|
93013
|
+
const signIn = ({ openUrl }) => gen(function* () {
|
|
93014
|
+
const attempt = yield* run$5(signingIn, signInThroughBrowser(openUrl));
|
|
92610
93015
|
const exit2 = yield* await_(attempt);
|
|
92611
93016
|
return hasInterrupts(exit2) ? yield* status : yield* exit2;
|
|
92612
93017
|
});
|
|
@@ -92622,6 +93027,7 @@ const make$8 = ({ serviceUrl, fetch: fetch2 = globalThis.fetch }) => gen(functio
|
|
|
92622
93027
|
andThen(
|
|
92623
93028
|
sync(() => {
|
|
92624
93029
|
last = nobody;
|
|
93030
|
+
avatarUrl = null;
|
|
92625
93031
|
return signedOut2;
|
|
92626
93032
|
})
|
|
92627
93033
|
),
|
|
@@ -92666,7 +93072,7 @@ const make$8 = ({ serviceUrl, fetch: fetch2 = globalThis.fetch }) => gen(functio
|
|
|
92666
93072
|
const hosts = yield* service2.hosts(token);
|
|
92667
93073
|
if (hosts.some((host) => host.id === id2 && host.environmentId === self2.id)) {
|
|
92668
93074
|
return yield* new RelayError({
|
|
92669
|
-
message: "To unlink this machine,
|
|
93075
|
+
message: "To unlink this machine, sign out."
|
|
92670
93076
|
});
|
|
92671
93077
|
}
|
|
92672
93078
|
yield* service2.removeHost(token, id2);
|
|
@@ -92696,6 +93102,131 @@ const make$8 = ({ serviceUrl, fetch: fetch2 = globalThis.fetch }) => gen(functio
|
|
|
92696
93102
|
});
|
|
92697
93103
|
});
|
|
92698
93104
|
const layer$9 = (options) => effect(RelayAccount, make$8(options));
|
|
93105
|
+
const SWEEP_INTERVAL$1 = "3 minutes";
|
|
93106
|
+
const DAY_MS = 24 * 60 * 60 * 1e3;
|
|
93107
|
+
class Settle extends Service$1()("hinacode/Settle") {
|
|
93108
|
+
}
|
|
93109
|
+
const isFinished = (pullRequest) => pullRequest.status === "merged" || pullRequest.status === "closed";
|
|
93110
|
+
const mergedSince = (pullRequest, workStartedAt) => pullRequest.status === "merged" && (workStartedAt === null || pullRequest.mergedAt === void 0 || pullRequest.mergedAt === null || Date.parse(pullRequest.mergedAt) > Date.parse(workStartedAt));
|
|
93111
|
+
const canAutoSettle = (thread2) => thread2.status !== "archived" && !isThreadBusy(thread2.status) && thread2.settledAt === null && thread2.pinnedAt === null;
|
|
93112
|
+
const lastActivity = (thread2) => thread2.snoozedUntil !== null && thread2.snoozedUntil > thread2.updatedAt ? thread2.snoozedUntil : thread2.updatedAt;
|
|
93113
|
+
const olderThan = (timestamp2, days, now2) => now2 - Date.parse(timestamp2) >= days * DAY_MS;
|
|
93114
|
+
const isIdleFor = (thread2, days, now2) => canAutoSettle(thread2) && thread2.status === "idle" && olderThan(lastActivity(thread2), days, now2);
|
|
93115
|
+
const isSettledFor = (thread2, days, now2) => thread2.status === "idle" && thread2.pinnedAt === null && thread2.settledAt !== null && olderThan(thread2.settledAt, days, now2);
|
|
93116
|
+
const isOpen$1 = (pullRequest) => pullRequest.status === "open" || pullRequest.status === "draft";
|
|
93117
|
+
const make$7 = gen(function* () {
|
|
93118
|
+
const settings = yield* Settings;
|
|
93119
|
+
const threads = yield* Threads;
|
|
93120
|
+
const pullRequests = yield* PullRequests;
|
|
93121
|
+
const github = yield* GitHub;
|
|
93122
|
+
const events2 = yield* Events;
|
|
93123
|
+
const worktrees = yield* Worktrees;
|
|
93124
|
+
const runner = yield* AgentRunner;
|
|
93125
|
+
const terminals = yield* Terminals;
|
|
93126
|
+
const ports = yield* Ports;
|
|
93127
|
+
const stopProcesses = (threadId) => terminals.closeThread(threadId).pipe(andThen(ports.closeThread(threadId)));
|
|
93128
|
+
const hasAgentWork = (threadId) => gen(function* () {
|
|
93129
|
+
const tasks = yield* runner.backgroundTasks(threadId);
|
|
93130
|
+
const subagents = yield* runner.subagents(threadId);
|
|
93131
|
+
return tasks.length > 0 || subagents.some((subagent2) => subagent2.status === "running");
|
|
93132
|
+
});
|
|
93133
|
+
const hasListeningPort = (threadId) => ports.listForThread(threadId).pipe(
|
|
93134
|
+
map$2((open2) => open2.length > 0),
|
|
93135
|
+
catchTag("FolderMissingError", () => succeed$1(false))
|
|
93136
|
+
);
|
|
93137
|
+
const settle2 = (threadId) => gen(function* () {
|
|
93138
|
+
if (isThreadBusy((yield* threads.get(threadId)).status)) return yield* new ThreadBusyError({ id: threadId });
|
|
93139
|
+
const settled = yield* runner.release(
|
|
93140
|
+
threadId,
|
|
93141
|
+
stopProcesses(threadId).pipe(andThen(threads.settle(threadId)))
|
|
93142
|
+
);
|
|
93143
|
+
if (isNone(settled)) return yield* new ThreadBusyError({ id: threadId });
|
|
93144
|
+
return settled.value;
|
|
93145
|
+
});
|
|
93146
|
+
const ownBranch = (worktreeId) => gen(function* () {
|
|
93147
|
+
if (worktreeId === null) return null;
|
|
93148
|
+
const worktree = yield* worktrees.get(worktreeId);
|
|
93149
|
+
return worktree.status === "removed" ? null : worktree.branch;
|
|
93150
|
+
});
|
|
93151
|
+
const settleIfDone = (threadId, links) => gen(function* () {
|
|
93152
|
+
const thread2 = yield* threads.get(threadId);
|
|
93153
|
+
if (!canAutoSettle(thread2) || (yield* hasAgentWork(threadId))) return;
|
|
93154
|
+
const branch = yield* ownBranch(thread2.worktreeId);
|
|
93155
|
+
const found2 = yield* forEach(links, (link) => github.pullRequest(link.url), { concurrency: 4 });
|
|
93156
|
+
const isOwn = (pullRequest) => branch === null || branch === pullRequest.headRefName || branch === forkPullRequestBranch(pullRequest.number);
|
|
93157
|
+
const allFinished = found2.every(
|
|
93158
|
+
(pullRequest, index) => isFinished(pullRequest) || !isOwn(pullRequest) && links[index].watch === null
|
|
93159
|
+
);
|
|
93160
|
+
if (!allFinished || (yield* hasListeningPort(threadId))) return;
|
|
93161
|
+
const ownMergedSince = (workStartedAt) => found2.some((pullRequest) => isOwn(pullRequest) && mergedSince(pullRequest, workStartedAt));
|
|
93162
|
+
const settled = yield* threads.settleMerged(
|
|
93163
|
+
threadId,
|
|
93164
|
+
(latest, workStartedAt) => canAutoSettle(latest) && ownMergedSince(workStartedAt)
|
|
93165
|
+
);
|
|
93166
|
+
if (isNone(settled)) return;
|
|
93167
|
+
yield* events2.publish({ type: "thread.updated", thread: settled.value });
|
|
93168
|
+
yield* runner.release(threadId, terminals.closeThread(threadId));
|
|
93169
|
+
}).pipe(catchCause((cause) => logWarning("auto settle skipped a thread", threadId, cause)));
|
|
93170
|
+
const settleIfIdle = (thread2, links, days, now2) => gen(function* () {
|
|
93171
|
+
if (!isIdleFor(thread2, days, now2) || (yield* hasAgentWork(thread2.id))) return;
|
|
93172
|
+
const found2 = yield* forEach(links, (link) => github.pullRequest(link.url), { concurrency: 4 });
|
|
93173
|
+
if (found2.some(isOpen$1) || (yield* hasListeningPort(thread2.id))) return;
|
|
93174
|
+
const latest = yield* threads.get(thread2.id);
|
|
93175
|
+
if (latest.updatedAt !== thread2.updatedAt || !isIdleFor(latest, days, now2)) return;
|
|
93176
|
+
const settled = yield* runner.release(
|
|
93177
|
+
thread2.id,
|
|
93178
|
+
stopProcesses(thread2.id).pipe(andThen(threads.settle(thread2.id)))
|
|
93179
|
+
);
|
|
93180
|
+
if (isSome(settled)) yield* events2.publish({ type: "thread.updated", thread: settled.value });
|
|
93181
|
+
}).pipe(catchCause((cause) => logWarning("idle settle skipped a thread", thread2.id, cause)));
|
|
93182
|
+
const losesUncommittedWork = (thread2) => gen(function* () {
|
|
93183
|
+
if (!(yield* settings.get).archive.removeWorktree || thread2.worktreeId === null) return false;
|
|
93184
|
+
const worktree = yield* worktrees.get(thread2.worktreeId);
|
|
93185
|
+
if (worktree.status === "removed") return false;
|
|
93186
|
+
return (yield* worktrees.checkoutState(worktree.id)) === "dirty";
|
|
93187
|
+
});
|
|
93188
|
+
const isArchiveDue = (thread2, now2) => map$2(
|
|
93189
|
+
settings.get,
|
|
93190
|
+
({ archive: { archiveAfterSettledDays: days } }) => days === null ? false : isSettledFor(thread2, days, now2)
|
|
93191
|
+
);
|
|
93192
|
+
const archiveIfSettledLong = (thread2, now2) => gen(function* () {
|
|
93193
|
+
if (!(yield* isArchiveDue(thread2, now2))) return;
|
|
93194
|
+
const archiveIfStillDue = threads.archiveIf(
|
|
93195
|
+
thread2.id,
|
|
93196
|
+
(latest) => gen(function* () {
|
|
93197
|
+
if (yield* losesUncommittedWork(latest)) return false;
|
|
93198
|
+
return yield* isArchiveDue(latest, now2);
|
|
93199
|
+
})
|
|
93200
|
+
);
|
|
93201
|
+
const archived = flatten$1(
|
|
93202
|
+
yield* runner.release(thread2.id, stopProcesses(thread2.id).pipe(andThen(archiveIfStillDue)))
|
|
93203
|
+
);
|
|
93204
|
+
if (isSome(archived)) yield* events2.publish({ type: "thread.updated", thread: archived.value });
|
|
93205
|
+
}).pipe(catchCause((cause) => logWarning("auto archive skipped a thread", thread2.id, cause)));
|
|
93206
|
+
const sweep = gen(function* () {
|
|
93207
|
+
const { archive: archive2 } = yield* settings.get;
|
|
93208
|
+
const now2 = yield* currentTimeMillis;
|
|
93209
|
+
const byThread = Map.groupBy(yield* pullRequests.listAll, (link) => link.threadId);
|
|
93210
|
+
if (archive2.whenMerged) {
|
|
93211
|
+
yield* forEach(byThread, ([threadId, links]) => settleIfDone(threadId, links), { discard: true });
|
|
93212
|
+
}
|
|
93213
|
+
const all2 = yield* threads.list;
|
|
93214
|
+
const { settleAfterIdleDays } = archive2;
|
|
93215
|
+
if (settleAfterIdleDays !== null) {
|
|
93216
|
+
yield* forEach(
|
|
93217
|
+
all2,
|
|
93218
|
+
(thread2) => settleIfIdle(thread2, byThread.get(thread2.id) ?? [], settleAfterIdleDays, now2),
|
|
93219
|
+
{ discard: true }
|
|
93220
|
+
);
|
|
93221
|
+
}
|
|
93222
|
+
if (archive2.archiveAfterSettledDays !== null) {
|
|
93223
|
+
yield* forEach(all2, (thread2) => archiveIfSettledLong(thread2, now2), { discard: true });
|
|
93224
|
+
}
|
|
93225
|
+
}).pipe(catchCause((cause) => logWarning("auto settle sweep failed", cause)));
|
|
93226
|
+
yield* schedule(sweep, spaced(SWEEP_INTERVAL$1)).pipe(forkScoped);
|
|
93227
|
+
return Settle.of({ settle: settle2, sweep });
|
|
93228
|
+
});
|
|
93229
|
+
const layer$8 = effect(Settle, make$7);
|
|
92699
93230
|
const INTERVAL = "5 seconds";
|
|
92700
93231
|
const KEPT_SAMPLES = 120;
|
|
92701
93232
|
class SystemResources extends Service$1()("hinacode/SystemResources") {
|
|
@@ -92731,7 +93262,7 @@ const disksUnder = (paths) => forEach(
|
|
|
92731
93262
|
return [...byDevice.values()].toSorted((a, b) => diskFullness(b) - diskFullness(a));
|
|
92732
93263
|
})
|
|
92733
93264
|
);
|
|
92734
|
-
const make$
|
|
93265
|
+
const make$6 = gen(function* () {
|
|
92735
93266
|
let samples = [];
|
|
92736
93267
|
let last = cpuTimes();
|
|
92737
93268
|
const sample = gen(function* () {
|
|
@@ -92753,7 +93284,7 @@ const make$7 = gen(function* () {
|
|
|
92753
93284
|
}));
|
|
92754
93285
|
return SystemResources.of({ read: read2 });
|
|
92755
93286
|
});
|
|
92756
|
-
const layer$
|
|
93287
|
+
const layer$7 = effect(SystemResources, make$6);
|
|
92757
93288
|
class Updates extends Service$1()("hinacode/Updates") {
|
|
92758
93289
|
}
|
|
92759
93290
|
const unsupported = (current) => Updates.of({
|
|
@@ -92764,7 +93295,7 @@ const unsupported = (current) => Updates.of({
|
|
|
92764
93295
|
const providerNames = { claude: "Claude Code", codex: "Codex" };
|
|
92765
93296
|
class SessionImports extends Service$1()("hinacode/SessionImports") {
|
|
92766
93297
|
}
|
|
92767
|
-
const make$
|
|
93298
|
+
const make$5 = gen(function* () {
|
|
92768
93299
|
const sql = yield* SqlClient;
|
|
92769
93300
|
const projects = yield* Projects;
|
|
92770
93301
|
const threads = yield* Threads;
|
|
@@ -92903,7 +93434,7 @@ const make$6 = gen(function* () {
|
|
|
92903
93434
|
});
|
|
92904
93435
|
return SessionImports.of({ list, import: importSession });
|
|
92905
93436
|
});
|
|
92906
|
-
const layer$
|
|
93437
|
+
const layer$6 = effect(SessionImports, make$5);
|
|
92907
93438
|
const newThreadOptions = (provider) => gen(function* () {
|
|
92908
93439
|
const settings = yield* Settings.use((service2) => service2.get);
|
|
92909
93440
|
const model = settings.defaultModel[provider] ?? (yield* AgentRunner.use((runner) => runner.listModels(provider)))[0]?.id ?? "";
|
|
@@ -92953,6 +93484,7 @@ const handlers = {
|
|
|
92953
93484
|
"projects.list": () => Projects.use((projects) => projects.listWithRepositories),
|
|
92954
93485
|
"projects.create": (input) => Projects.use((projects) => projects.create(input)),
|
|
92955
93486
|
"projects.clone": (input) => Projects.use((projects) => projects.clone(input)),
|
|
93487
|
+
"projects.cancelClone": ({ cloneId }) => Projects.use((projects) => projects.cancelClone(cloneId)),
|
|
92956
93488
|
"projects.update": (input) => Projects.use((projects) => projects.update(input)),
|
|
92957
93489
|
"projects.delete": ({ id: id2 }) => gen(function* () {
|
|
92958
93490
|
const threads = (yield* Threads.use((service2) => service2.list)).filter((thread2) => thread2.projectId === id2);
|
|
@@ -93035,8 +93567,9 @@ const handlers = {
|
|
|
93035
93567
|
"threads.undoTurn": ({ threadId }) => Threads.use((threads) => threads.undoTurn(threadId)),
|
|
93036
93568
|
"threads.archive": ({ threadId }) => Threads.use((threads) => threads.archive(threadId)),
|
|
93037
93569
|
"threads.unarchive": ({ threadId }) => Threads.use((threads) => threads.unarchive(threadId)),
|
|
93038
|
-
"threads.settle": ({ threadId }) =>
|
|
93570
|
+
"threads.settle": ({ threadId }) => Settle.use((settle2) => settle2.settle(threadId)),
|
|
93039
93571
|
"threads.unsettle": ({ threadId }) => Threads.use((threads) => threads.unsettle(threadId)),
|
|
93572
|
+
"threads.regenerateTitle": ({ threadId }) => ThreadNaming.use((naming) => naming.regenerateTitle(threadId)),
|
|
93040
93573
|
"threads.fork": ({ threadId, messageId }) => Threads.use((threads) => threads.fork(threadId, messageId)).pipe(
|
|
93041
93574
|
tap$1((thread2) => Events.use((events2) => events2.publish({ type: "thread.updated", thread: thread2 })))
|
|
93042
93575
|
),
|
|
@@ -93084,8 +93617,19 @@ const handlers = {
|
|
|
93084
93617
|
"environments.remove": ({ id: id2 }) => Environments.use((environments2) => environments2.remove(id2)),
|
|
93085
93618
|
"environments.reconnect": ({ id: id2 }) => Environments.use((environments2) => environments2.reconnect(id2)),
|
|
93086
93619
|
"relayAccount.status": () => RelayAccount.use((account2) => account2.status),
|
|
93087
|
-
"relayAccount.signIn": (_, desktop) =>
|
|
93088
|
-
|
|
93620
|
+
"relayAccount.signIn": (_, desktop) => gen(function* () {
|
|
93621
|
+
const account2 = yield* RelayAccount;
|
|
93622
|
+
const relay2 = yield* Relay;
|
|
93623
|
+
const openInBrowser2 = (url2) => desktop?.openExternal(url2) ?? void_;
|
|
93624
|
+
const status = yield* account2.signIn({ openUrl: openInBrowser2 });
|
|
93625
|
+
if (status.state === "signedIn") yield* desktop?.focus ?? void_;
|
|
93626
|
+
if (status.state !== "signedIn" || (yield* relay2.status).state !== "off") return status;
|
|
93627
|
+
yield* relay2.setup({
|
|
93628
|
+
onLink: (link) => account2.approveOwnLink(link.userCode).pipe(flatMap((approved2) => approved2 ? void_ : openInBrowser2(link.url)))
|
|
93629
|
+
});
|
|
93630
|
+
return yield* account2.sync;
|
|
93631
|
+
}),
|
|
93632
|
+
"relayAccount.signOut": () => Relay.use((relay2) => relay2.remove).pipe(andThen(RelayAccount.use((account2) => account2.signOut))),
|
|
93089
93633
|
"relayAccount.sync": () => RelayAccount.use((account2) => account2.sync),
|
|
93090
93634
|
"relayAccount.machines": () => RelayAccount.use((account2) => account2.machines),
|
|
93091
93635
|
"relayAccount.setShown": (input) => RelayAccount.use((account2) => account2.setShown(input)),
|
|
@@ -93178,6 +93722,8 @@ const handlers = {
|
|
|
93178
93722
|
"github.merge": ({ url: url2, method: method2 }) => GitHub.use((github) => github.merge(url2, method2)),
|
|
93179
93723
|
"github.close": ({ url: url2 }) => GitHub.use((github) => github.close(url2)),
|
|
93180
93724
|
"github.comment": ({ url: url2, body: body2 }) => GitHub.use((github) => github.comment(url2, body2)),
|
|
93725
|
+
"github.pullRequestCandidates": ({ url: url2 }) => GitHub.use((github) => github.pullRequestCandidates(url2)),
|
|
93726
|
+
"github.editPullRequest": ({ url: url2, edit }) => GitHub.use((github) => github.editPullRequest(url2, edit)),
|
|
93181
93727
|
"github.fileContent": ({ url: url2, ref: ref2, path: path2 }) => GitHub.use((github) => github.fileContent(url2, ref2, path2)),
|
|
93182
93728
|
"github.reviewComment": ({ url: url2, comment }) => GitHub.use((github) => github.reviewComment(url2, comment)),
|
|
93183
93729
|
"linear.issues": () => Linear.use((linear) => linear.assignedIssues),
|
|
@@ -93237,6 +93783,7 @@ const handlers = {
|
|
|
93237
93783
|
"artifacts.delete": ({ id: id2 }) => Artifacts.use((artifacts) => artifacts.remove(id2)),
|
|
93238
93784
|
"artifacts.readDocument": ({ id: id2 }) => Artifacts.use((artifacts) => artifacts.readDocument(id2)),
|
|
93239
93785
|
"artifacts.saveDocument": (input) => Artifacts.use((artifacts) => artifacts.saveDocument(input)),
|
|
93786
|
+
"artifacts.addDocumentImage": (input) => Artifacts.use((artifacts) => artifacts.addDocumentImage(input)),
|
|
93240
93787
|
"artifacts.createDocument": (input) => Artifacts.use((artifacts) => artifacts.createDocument(input)),
|
|
93241
93788
|
"artifacts.rename": ({ id: id2, title: title2 }) => Artifacts.use((artifacts) => artifacts.rename(id2, title2)),
|
|
93242
93789
|
"artifacts.setTheme": (theme) => ArtifactInspector.use((inspector) => inspector.setTheme(theme)),
|
|
@@ -93261,17 +93808,7 @@ const handlers = {
|
|
|
93261
93808
|
}),
|
|
93262
93809
|
"remote.status": () => RemoteAccess.use((remote) => remote.status),
|
|
93263
93810
|
"remote.pairing": () => RemoteAccess.use((remote) => remote.pairing),
|
|
93264
|
-
"remote.rotateToken": () => RemoteAccess.use((remote) => remote.rotateToken)
|
|
93265
|
-
"remote.setupRelay": (_, desktop) => gen(function* () {
|
|
93266
|
-
const account2 = yield* RelayAccount;
|
|
93267
|
-
const relay2 = yield* Relay;
|
|
93268
|
-
yield* relay2.setup({
|
|
93269
|
-
onLink: (link) => account2.approveOwnLink(link.userCode).pipe(
|
|
93270
|
-
flatMap((approved2) => approved2 ? void_ : desktop?.openExternal(link.url) ?? void_)
|
|
93271
|
-
)
|
|
93272
|
-
});
|
|
93273
|
-
}).pipe(andThen(RemoteAccess.use((remote) => remote.pairing))),
|
|
93274
|
-
"remote.removeRelay": () => Relay.use((relay2) => relay2.remove).pipe(andThen(RemoteAccess.use((remote) => remote.pairing)))
|
|
93811
|
+
"remote.rotateToken": () => RemoteAccess.use((remote) => remote.rotateToken)
|
|
93275
93812
|
};
|
|
93276
93813
|
const RpcCall = Struct({
|
|
93277
93814
|
method: Literals(Object.keys(RpcMethods)),
|
|
@@ -93508,7 +94045,7 @@ const makePrivate = (folder) => {
|
|
|
93508
94045
|
chmodSync(folder, 448);
|
|
93509
94046
|
return true;
|
|
93510
94047
|
};
|
|
93511
|
-
const make$
|
|
94048
|
+
const make$4 = (dataDir) => gen(function* () {
|
|
93512
94049
|
const socketPath = cliSocketPath(dataDir);
|
|
93513
94050
|
const access2 = yield* RemoteAccess;
|
|
93514
94051
|
const windows = yield* WindowBroadcast;
|
|
@@ -93545,11 +94082,11 @@ const make$5 = (dataDir) => gen(function* () {
|
|
|
93545
94082
|
yield* logInfo("cli socket listening", socketPath);
|
|
93546
94083
|
}).pipe(catchCause((cause) => logWarning("cli socket failed", pretty(cause))));
|
|
93547
94084
|
});
|
|
93548
|
-
const layer$
|
|
94085
|
+
const layer$5 = (dataDir) => process.platform === "win32" ? empty$9 : effectDiscard(make$4(dataDir));
|
|
93549
94086
|
const AUTH_TIMEOUT = seconds(5);
|
|
93550
94087
|
const describeCause = (cause) => describeError(squash(cause));
|
|
93551
94088
|
const staysOnPrivateNetworks = (socket) => [socket.localAddress, socket.remoteAddress].every((address) => address !== void 0 && isPrivateAddress(address));
|
|
93552
|
-
const make$
|
|
94089
|
+
const make$3 = gen(function* () {
|
|
93553
94090
|
const access2 = yield* RemoteAccess;
|
|
93554
94091
|
const broadcast = yield* PushBroadcast;
|
|
93555
94092
|
const settings = yield* Settings;
|
|
@@ -93658,7 +94195,7 @@ const make$4 = gen(function* () {
|
|
|
93658
94195
|
forkScoped
|
|
93659
94196
|
);
|
|
93660
94197
|
});
|
|
93661
|
-
const layer$
|
|
94198
|
+
const layer$4 = effectDiscard(make$3);
|
|
93662
94199
|
const envFlag = (env, name) => {
|
|
93663
94200
|
const value2 = env[name];
|
|
93664
94201
|
if (value2 === void 0 || value2 === "0" || value2 === "false") return false;
|
|
@@ -93738,50 +94275,6 @@ const linkInstructions = (url2) => [
|
|
|
93738
94275
|
"Waiting for you to approve it…",
|
|
93739
94276
|
""
|
|
93740
94277
|
].join("\n");
|
|
93741
|
-
const SWEEP_INTERVAL$1 = "3 minutes";
|
|
93742
|
-
class AutoSettle extends Service$1()(
|
|
93743
|
-
"hinacode/AutoSettle"
|
|
93744
|
-
) {
|
|
93745
|
-
}
|
|
93746
|
-
const isFinished = (pullRequest) => pullRequest.status === "merged" || pullRequest.status === "closed";
|
|
93747
|
-
const mergedSince = (pullRequest, workStartedAt) => pullRequest.status === "merged" && (workStartedAt === null || pullRequest.mergedAt === void 0 || pullRequest.mergedAt === null || Date.parse(pullRequest.mergedAt) > Date.parse(workStartedAt));
|
|
93748
|
-
const canAutoSettle = (thread2) => thread2.status !== "archived" && !isThreadBusy(thread2.status) && thread2.settledAt === null && thread2.pinnedAt === null;
|
|
93749
|
-
const make$3 = gen(function* () {
|
|
93750
|
-
const settings = yield* Settings;
|
|
93751
|
-
const threads = yield* Threads;
|
|
93752
|
-
const pullRequests = yield* PullRequests;
|
|
93753
|
-
const github = yield* GitHub;
|
|
93754
|
-
const events2 = yield* Events;
|
|
93755
|
-
const worktrees = yield* Worktrees;
|
|
93756
|
-
const ownBranch = (worktreeId) => gen(function* () {
|
|
93757
|
-
if (worktreeId === null) return null;
|
|
93758
|
-
const worktree = yield* worktrees.get(worktreeId);
|
|
93759
|
-
return worktree.status === "removed" ? null : worktree.branch;
|
|
93760
|
-
});
|
|
93761
|
-
const settleIfDone = (threadId, links) => gen(function* () {
|
|
93762
|
-
const thread2 = yield* threads.get(threadId);
|
|
93763
|
-
if (!canAutoSettle(thread2)) return;
|
|
93764
|
-
const branch = yield* ownBranch(thread2.worktreeId);
|
|
93765
|
-
const found2 = yield* forEach(links, (link) => github.pullRequest(link.url), { concurrency: 4 });
|
|
93766
|
-
const isOwn = (pullRequest) => branch === null || branch === pullRequest.headRefName || branch === forkPullRequestBranch(pullRequest.number);
|
|
93767
|
-
const isDone2 = (workStartedAt) => found2.some((pullRequest) => isOwn(pullRequest) && mergedSince(pullRequest, workStartedAt)) && found2.every(
|
|
93768
|
-
(pullRequest, index) => isFinished(pullRequest) || !isOwn(pullRequest) && links[index].watch === null
|
|
93769
|
-
);
|
|
93770
|
-
const settled = yield* threads.settleMerged(
|
|
93771
|
-
threadId,
|
|
93772
|
-
(latest, workStartedAt) => canAutoSettle(latest) && isDone2(workStartedAt)
|
|
93773
|
-
);
|
|
93774
|
-
if (isSome(settled)) yield* events2.publish({ type: "thread.updated", thread: settled.value });
|
|
93775
|
-
}).pipe(catchCause((cause) => logWarning("auto settle skipped a thread", threadId, cause)));
|
|
93776
|
-
const sweep = gen(function* () {
|
|
93777
|
-
if (!(yield* settings.get).archive.whenMerged) return;
|
|
93778
|
-
const byThread = Map.groupBy(yield* pullRequests.listAll, (link) => link.threadId);
|
|
93779
|
-
yield* forEach(byThread, ([threadId, links]) => settleIfDone(threadId, links), { discard: true });
|
|
93780
|
-
}).pipe(catchCause((cause) => logWarning("auto settle sweep failed", cause)));
|
|
93781
|
-
yield* schedule(sweep, spaced(SWEEP_INTERVAL$1)).pipe(forkScoped);
|
|
93782
|
-
return AutoSettle.of({ sweep });
|
|
93783
|
-
});
|
|
93784
|
-
const layer$4 = effect(AutoSettle, make$3);
|
|
93785
94278
|
const SWEEP_CONCURRENCY = 4;
|
|
93786
94279
|
class PullRequestLifecycle extends Service$1()("hinacode/PullRequestLifecycle") {
|
|
93787
94280
|
}
|
|
@@ -118219,7 +118712,13 @@ const makeAppLayer = ({
|
|
|
118219
118712
|
layer$e,
|
|
118220
118713
|
layer$q
|
|
118221
118714
|
);
|
|
118222
|
-
const naming = providers.simulated ?
|
|
118715
|
+
const naming = providers.simulated ? effect(
|
|
118716
|
+
ThreadNaming,
|
|
118717
|
+
map$2(Threads, (threads) => ({
|
|
118718
|
+
nameFromPrompt: () => void_,
|
|
118719
|
+
regenerateTitle: (threadId) => threads.get(threadId)
|
|
118720
|
+
}))
|
|
118721
|
+
) : layer$y;
|
|
118223
118722
|
const remoteAccess = layer$s.pipe(provide$2(layer$t));
|
|
118224
118723
|
const relayServiceUrl = process.env["HINACODE_RELAY_URL"] ?? DEFAULT_RELAY_SERVICE_URL;
|
|
118225
118724
|
const relay2 = layer$b({ serviceUrl: relayServiceUrl, cloudflaredDir: join$1(userData, "cloudflared") }).pipe(
|
|
@@ -118244,7 +118743,7 @@ const makeAppLayer = ({
|
|
|
118244
118743
|
credentialsLayer,
|
|
118245
118744
|
layer$R,
|
|
118246
118745
|
layer$v,
|
|
118247
|
-
layer$
|
|
118746
|
+
layer$7,
|
|
118248
118747
|
naming,
|
|
118249
118748
|
remoteAccess,
|
|
118250
118749
|
relay2,
|
|
@@ -118256,17 +118755,17 @@ const makeAppLayer = ({
|
|
|
118256
118755
|
const agents = layer$x.pipe(provideMerge(mergeAll(domain, features)));
|
|
118257
118756
|
const services = mergeAll(
|
|
118258
118757
|
layer$j,
|
|
118259
|
-
layer$
|
|
118758
|
+
layer$8,
|
|
118260
118759
|
layer$1,
|
|
118261
118760
|
layer$3,
|
|
118262
118761
|
providers.simulated ? idleLayer : layer$a,
|
|
118263
118762
|
updates,
|
|
118264
118763
|
serverLayer,
|
|
118265
118764
|
layer$L(join$1(userData, "cache")),
|
|
118266
|
-
layer$
|
|
118765
|
+
layer$6,
|
|
118267
118766
|
layer$9({ serviceUrl: relayServiceUrl }).pipe(provide$2(layer$t))
|
|
118268
118767
|
).pipe(provideMerge(agents));
|
|
118269
|
-
return mergeAll(layer$
|
|
118768
|
+
return mergeAll(layer$4, layer$5(userData), answerAsksLayer, layer$2).pipe(
|
|
118270
118769
|
provideMerge(effectDiscard(serve2 ? applyServeConfig(serve2) : void_)),
|
|
118271
118770
|
provideMerge(services),
|
|
118272
118771
|
provide$2(providers.layer),
|