hinacode 0.1.0-alpha.11 → 0.1.0-alpha.13
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.
|
@@ -2495,7 +2495,7 @@ const CurrentLogLevel$1 = /* @__PURE__ */ Reference("effect/References/CurrentLo
|
|
|
2495
2495
|
fiberCached: true,
|
|
2496
2496
|
defaultValue: () => "Info"
|
|
2497
2497
|
});
|
|
2498
|
-
const MinimumLogLevel = /* @__PURE__ */ Reference("effect/References/MinimumLogLevel", {
|
|
2498
|
+
const MinimumLogLevel$1 = /* @__PURE__ */ Reference("effect/References/MinimumLogLevel", {
|
|
2499
2499
|
fiberCached: true,
|
|
2500
2500
|
defaultValue: () => "Info"
|
|
2501
2501
|
});
|
|
@@ -3001,7 +3001,7 @@ const makeFiberContextCache = (context2) => {
|
|
|
3001
3001
|
tracerEnabled: get$6(context2, TracerEnabled),
|
|
3002
3002
|
span: getOrUndefinedUnsafe(context2, ParentSpanKey),
|
|
3003
3003
|
logLevel: get$6(context2, CurrentLogLevel$1),
|
|
3004
|
-
minimumLogLevel: get$6(context2, MinimumLogLevel),
|
|
3004
|
+
minimumLogLevel: get$6(context2, MinimumLogLevel$1),
|
|
3005
3005
|
stackFrame: get$6(context2, CurrentStackFrame),
|
|
3006
3006
|
runtimeMetrics: getOrUndefinedUnsafe(context2, FiberRuntimeMetricsKey),
|
|
3007
3007
|
maxOpsBeforeYield: get$6(context2, MaxOpsBeforeYield),
|
|
@@ -3418,8 +3418,48 @@ const tapEffectCont = function(value2) {
|
|
|
3418
3418
|
};
|
|
3419
3419
|
const asSome$1 = (self) => map$5(self, some);
|
|
3420
3420
|
const andThen$1 = /* @__PURE__ */ dual(2, (self, f) => new ContImpl(self, isEffect$1(f) ? returnPayload : andThenCont, f));
|
|
3421
|
-
const tap$
|
|
3421
|
+
const tap$3 = /* @__PURE__ */ dual(2, (self, f) => new ContImpl(self, isEffect$1(f) ? tapEffectCont : tapCont, f));
|
|
3422
3422
|
const asVoid$1 = (self) => new ContImpl(self, returnPayload, exitVoid);
|
|
3423
|
+
const raceAll = (all2, options) => withFiber$1((parent) => {
|
|
3424
|
+
const fibers = /* @__PURE__ */ new Set();
|
|
3425
|
+
onExitUnsafe(parent, () => fibers.size === 0 ? void 0 : fiberInterruptAll(fibers));
|
|
3426
|
+
return callback$2((resume) => {
|
|
3427
|
+
const effects = fromIterable$3(all2);
|
|
3428
|
+
const len = effects.length;
|
|
3429
|
+
let doneCount = 0;
|
|
3430
|
+
let done2 = false;
|
|
3431
|
+
const failures = [];
|
|
3432
|
+
const onExit2 = (exit2, fiber, i) => {
|
|
3433
|
+
doneCount++;
|
|
3434
|
+
if (exit2._tag === "Failure") {
|
|
3435
|
+
failures.push(...exit2.cause.reasons);
|
|
3436
|
+
if (doneCount >= len) {
|
|
3437
|
+
resume(failCause$6(causeFromReasons(failures)));
|
|
3438
|
+
}
|
|
3439
|
+
return;
|
|
3440
|
+
}
|
|
3441
|
+
const isWinner = !done2;
|
|
3442
|
+
done2 = true;
|
|
3443
|
+
resume(exit2);
|
|
3444
|
+
if (isWinner && options?.onWinner) {
|
|
3445
|
+
options.onWinner({
|
|
3446
|
+
fiber,
|
|
3447
|
+
index: i,
|
|
3448
|
+
parentFiber: parent
|
|
3449
|
+
});
|
|
3450
|
+
}
|
|
3451
|
+
};
|
|
3452
|
+
for (let i = 0; i < len; i++) {
|
|
3453
|
+
const fiber = forkUnsafe$1(parent, effects[i], true, true, false);
|
|
3454
|
+
fibers.add(fiber);
|
|
3455
|
+
fiber.addObserver((exit2) => {
|
|
3456
|
+
fibers.delete(fiber);
|
|
3457
|
+
onExit2(exit2, fiber, i);
|
|
3458
|
+
});
|
|
3459
|
+
if (done2) break;
|
|
3460
|
+
}
|
|
3461
|
+
});
|
|
3462
|
+
});
|
|
3423
3463
|
const raceAllFirst = (all2, options) => withFiber$1((parent) => {
|
|
3424
3464
|
const fibers = /* @__PURE__ */ new Set();
|
|
3425
3465
|
onExitUnsafe(parent, () => fibers.size === 0 ? void 0 : fiberInterruptAll(fibers));
|
|
@@ -3447,6 +3487,7 @@ const raceAllFirst = (all2, options) => withFiber$1((parent) => {
|
|
|
3447
3487
|
}
|
|
3448
3488
|
});
|
|
3449
3489
|
});
|
|
3490
|
+
const race$1 = /* @__PURE__ */ dual((args2) => isEffect$1(args2[1]), (self, that, options) => raceAll([self, that], options));
|
|
3450
3491
|
const raceFirst$1 = /* @__PURE__ */ dual((args2) => isEffect$1(args2[1]), (self, that, options) => raceAllFirst([self, that], options));
|
|
3451
3492
|
const flatMap$3 = /* @__PURE__ */ dual(2, (self, f) => new ContImpl(self, andThenCont, f));
|
|
3452
3493
|
const matchCauseEffectEager$1 = /* @__PURE__ */ dual(2, (self, options) => {
|
|
@@ -3847,7 +3888,7 @@ const scopedWith$1 = (f) => suspend$3(() => {
|
|
|
3847
3888
|
const scope2 = scopeMakeUnsafe();
|
|
3848
3889
|
return onExit$2(f(scope2), (exit2) => suspend$3(() => scopeCloseUnsafe(scope2, exit2) ?? void_$3));
|
|
3849
3890
|
});
|
|
3850
|
-
const acquireRelease$1 = (acquire, release2, options) => contextWith$1((context2) => uninterruptibleMask$1((restore) => flatMap$3(scope$1, (scope2) => tap$
|
|
3891
|
+
const acquireRelease$1 = (acquire, release2, options) => contextWith$1((context2) => uninterruptibleMask$1((restore) => flatMap$3(scope$1, (scope2) => tap$3(options?.interruptible ? restore(acquire) : acquire, (a) => scopeAddFinalizerExit(scope2, (exit2) => provideContext$3(release2(a, exit2), context2))))));
|
|
3851
3892
|
const addFinalizer$2 = (finalizer) => flatMap$3(scope$1, (scope2) => contextWith$1((context2) => scopeAddFinalizerExit(scope2, (exit2) => provideContext$3(finalizer(exit2), context2))));
|
|
3852
3893
|
const OnExitImpl = /* @__PURE__ */ (function() {
|
|
3853
3894
|
const Proto3 = /* @__PURE__ */ makePrimitiveProto({
|
|
@@ -4914,6 +4955,7 @@ const into = /* @__PURE__ */ dual(2, (self, deferred) => uninterruptibleMask$1((
|
|
|
4914
4955
|
const CurrentLogAnnotations = CurrentLogAnnotations$1;
|
|
4915
4956
|
const CurrentLogLevel = CurrentLogLevel$1;
|
|
4916
4957
|
const CurrentLogSpans = CurrentLogSpans$1;
|
|
4958
|
+
const MinimumLogLevel = MinimumLogLevel$1;
|
|
4917
4959
|
const TracerTimingEnabled = TracerTimingEnabled$1;
|
|
4918
4960
|
const Scope = scopeTag;
|
|
4919
4961
|
const make$1t = scopeMake;
|
|
@@ -5299,7 +5341,7 @@ const provide$2 = /* @__PURE__ */ dual((args2) => isEffect$1(args2[0]), (self, s
|
|
|
5299
5341
|
const findErrorOnly = (cause) => cause.reasons.every(isFailReason$1) ? findError$1(cause) : fail$7(cause);
|
|
5300
5342
|
const repeatOrElse = /* @__PURE__ */ dual(3, (self, schedule2, orElse) => flatMap$3(toStepWithMetadata(schedule2), (step) => {
|
|
5301
5343
|
let meta = CurrentMetadata.defaultValue();
|
|
5302
|
-
return catchCauseFilter$1(catchDone(forever$2(tap$
|
|
5344
|
+
return catchCauseFilter$1(catchDone(forever$2(tap$3(flatMap$3(suspend$3(() => provideService$3(self, CurrentMetadata, meta)), step), (meta_) => sync$1(() => {
|
|
5303
5345
|
meta = meta_;
|
|
5304
5346
|
})), {
|
|
5305
5347
|
disableYield: true
|
|
@@ -5394,7 +5436,7 @@ const fromOption = fromOption$1;
|
|
|
5394
5436
|
const flatMap$1 = flatMap$3;
|
|
5395
5437
|
const flatten$1 = flatten$2;
|
|
5396
5438
|
const andThen = andThen$1;
|
|
5397
|
-
const tap$
|
|
5439
|
+
const tap$2 = tap$3;
|
|
5398
5440
|
const result$1 = result$2;
|
|
5399
5441
|
const option = option$1;
|
|
5400
5442
|
const exit = exit$1;
|
|
@@ -5422,6 +5464,7 @@ const timeoutOption = timeoutOption$1;
|
|
|
5422
5464
|
const timeoutOrElse = timeoutOrElse$1;
|
|
5423
5465
|
const delay = delay$1;
|
|
5424
5466
|
const sleep = sleep$1;
|
|
5467
|
+
const race = race$1;
|
|
5425
5468
|
const raceFirst = raceFirst$1;
|
|
5426
5469
|
const filterOrFail = filterOrFail$1;
|
|
5427
5470
|
const when$2 = when$3;
|
|
@@ -11947,7 +11990,7 @@ const unsubscribe = (self) => uninterruptible(withFiber((state) => {
|
|
|
11947
11990
|
return forEach$1(takeAll$2(self.pollers), (d) => interruptWith(d, state.id), {
|
|
11948
11991
|
discard: true,
|
|
11949
11992
|
concurrency: "unbounded"
|
|
11950
|
-
}).pipe(tap$
|
|
11993
|
+
}).pipe(tap$2(() => sync(() => {
|
|
11951
11994
|
self.subscribers.delete(self.subscription);
|
|
11952
11995
|
self.subscription.unsubscribe();
|
|
11953
11996
|
self.replayWindow.close();
|
|
@@ -12805,7 +12848,7 @@ const DefaultChunkSize = 4096;
|
|
|
12805
12848
|
const asyncQueue = (scope2, f, options) => make$1d({
|
|
12806
12849
|
capacity: options?.bufferSize,
|
|
12807
12850
|
strategy: options?.strategy
|
|
12808
|
-
}).pipe(tap$
|
|
12851
|
+
}).pipe(tap$2((queue) => addFinalizer$1(scope2, shutdown(queue))), tap$2((queue) => provide$4(f(queue), scope2).pipe(catchCause$1((cause) => failCause$2(queue, cause)), forkIn(scope2))));
|
|
12809
12852
|
const callbackArray = (f, options) => fromTransform$1((_, scope2) => map$3(asyncQueue(scope2, f, options), takeAll));
|
|
12810
12853
|
const suspend$1 = (evaluate2) => fromTransform$1((upstream, scope2) => suspend$2(() => toTransform(evaluate2())(upstream, scope2)));
|
|
12811
12854
|
const fromIterator = (iterator) => fromPull$1(sync(() => {
|
|
@@ -13030,7 +13073,7 @@ const mergeAll = /* @__PURE__ */ dual(2, (channels, {
|
|
|
13030
13073
|
if (fibers.size === 0) yield* doneLatch.open;
|
|
13031
13074
|
yield* interrupt(fiber2);
|
|
13032
13075
|
}
|
|
13033
|
-
const fiber = yield* childPull.pipe(tap$
|
|
13076
|
+
const fiber = yield* childPull.pipe(tap$2(() => yieldNow), flatMap$1((value2) => offer(queue, value2)), forever({
|
|
13034
13077
|
disableYield: true
|
|
13035
13078
|
}), onError(fnUntraced(function* (cause) {
|
|
13036
13079
|
const exit$12 = doneExitFromCause(cause);
|
|
@@ -13349,7 +13392,7 @@ const make$1b = (options) => withFiber((fiber) => {
|
|
|
13349
13392
|
self.state = {
|
|
13350
13393
|
_tag: "Closed"
|
|
13351
13394
|
};
|
|
13352
|
-
return forEach$1(map2, ([, entry]) => exit(closeEntry(entry))).pipe(tap$
|
|
13395
|
+
return forEach$1(map2, ([, entry]) => exit(closeEntry(entry))).pipe(tap$2(() => sync(() => {
|
|
13353
13396
|
clear$3(map2);
|
|
13354
13397
|
})));
|
|
13355
13398
|
}), self);
|
|
@@ -13604,6 +13647,7 @@ const map = /* @__PURE__ */ dual(2, (self, f) => suspend(() => {
|
|
|
13604
13647
|
return fromChannel(map$1(self.channel, map$6((o) => f(o, i++))));
|
|
13605
13648
|
}));
|
|
13606
13649
|
const mapEffect = /* @__PURE__ */ dual((args2) => isStream(args2[0]), (self, f, options) => self.channel.pipe(flattenArray, mapEffect$1(f, options), map$1(of), fromChannel));
|
|
13650
|
+
const tap$1 = /* @__PURE__ */ dual((args2) => isStream(args2[0]), (self, f, options) => mapEffect(self, (a) => as(f(a), a), options));
|
|
13607
13651
|
const concat = /* @__PURE__ */ dual(2, (self, that) => {
|
|
13608
13652
|
const stream2 = fromChannel(flatten(fromIterator(() => concatChannels(self, that))));
|
|
13609
13653
|
concatParts.set(stream2, [self, that]);
|
|
@@ -14151,7 +14195,7 @@ const make$14 = (layer2, options) => {
|
|
|
14151
14195
|
let buildFiber;
|
|
14152
14196
|
const contextEffect = withFiber((fiber) => {
|
|
14153
14197
|
if (!buildFiber) {
|
|
14154
|
-
buildFiber = runFork(tap$
|
|
14198
|
+
buildFiber = runFork(tap$2(buildWithMemoMap(layer2, memoMap, layerScope), (context2) => sync(() => {
|
|
14155
14199
|
self.cachedContext = context2;
|
|
14156
14200
|
})), {
|
|
14157
14201
|
...defaultRunOptions,
|
|
@@ -14378,7 +14422,7 @@ const make$13 = /* @__PURE__ */ sync(() => {
|
|
|
14378
14422
|
}
|
|
14379
14423
|
return void_$1;
|
|
14380
14424
|
});
|
|
14381
|
-
const mutation = (keys2, effect2) => tap$
|
|
14425
|
+
const mutation = (keys2, effect2) => tap$2(effect2, invalidate(keys2));
|
|
14382
14426
|
const registerUnsafe = (keys2, handler) => {
|
|
14383
14427
|
const resolvedKeys = [];
|
|
14384
14428
|
keysToHashes(keys2, (hash2) => {
|
|
@@ -15800,7 +15844,8 @@ const Compaction = Union2([
|
|
|
15800
15844
|
Struct({
|
|
15801
15845
|
status: Literal2("done"),
|
|
15802
15846
|
trigger: Literals(["manual", "auto"]),
|
|
15803
|
-
|
|
15847
|
+
/** Null when the agent does not report the sizes, as Codex does not. */
|
|
15848
|
+
preTokens: NullOr(Number$1),
|
|
15804
15849
|
postTokens: NullOr(Number$1)
|
|
15805
15850
|
}),
|
|
15806
15851
|
/** `message` is null when the turn ended before the compaction reported back. */
|
|
@@ -15901,7 +15946,9 @@ const Project = Struct({
|
|
|
15901
15946
|
* The GitHub repository the root checks out, as lower-case `owner/name`, then the root's folder inside the repository
|
|
15902
15947
|
* when it is not the top level. Only `projects.list` sets it. Absent without a GitHub `origin`.
|
|
15903
15948
|
*/
|
|
15904
|
-
repository: optionalKey(String$1)
|
|
15949
|
+
repository: optionalKey(String$1),
|
|
15950
|
+
/** Experimental. Opens the project's GitHub pull request links on linear.review instead. */
|
|
15951
|
+
linearReview: Boolean$1.pipe(withDecodingDefaultKey(succeed$3(false)))
|
|
15905
15952
|
});
|
|
15906
15953
|
const WorktreeStatus = Literals(["preparing", "ready", "failed", "removed"]);
|
|
15907
15954
|
const Worktree = Struct({
|
|
@@ -15914,6 +15961,8 @@ const Worktree = Struct({
|
|
|
15914
15961
|
setupLog: String$1,
|
|
15915
15962
|
createdAt: Timestamp
|
|
15916
15963
|
});
|
|
15964
|
+
const CheckoutState = Literals(["clean", "dirty", "missing"]);
|
|
15965
|
+
const WorktreeCheckout = Struct({ id: String$1, state: CheckoutState });
|
|
15917
15966
|
const ChangedFileStatus = Literals(["added", "modified", "deleted", "untracked", "conflict"]);
|
|
15918
15967
|
const Changes = Struct({
|
|
15919
15968
|
files: ArraySchema(Struct({ path: String$1, status: ChangedFileStatus })),
|
|
@@ -16020,6 +16069,12 @@ const OpenPullRequest = Struct({
|
|
|
16020
16069
|
author: String$1,
|
|
16021
16070
|
isDraft: Boolean$1
|
|
16022
16071
|
});
|
|
16072
|
+
const PullRequestMatch = Struct({
|
|
16073
|
+
number: Int,
|
|
16074
|
+
title: String$1,
|
|
16075
|
+
status: PullRequestStatus,
|
|
16076
|
+
author: String$1
|
|
16077
|
+
});
|
|
16023
16078
|
const ThreadStatus = Literals(["idle", "running", "awaiting_approval", "limited", "archived"]);
|
|
16024
16079
|
const isThreadBusy = (status) => status === "running" || status === "awaiting_approval";
|
|
16025
16080
|
const AccessMode = Literals(["supervised", "auto", "full"]);
|
|
@@ -16209,6 +16264,8 @@ const defaultClientSettings = {
|
|
|
16209
16264
|
appearance: { theme: "system", fontSize: 16, uiFont: null, monoFont: null, contrast: 0 },
|
|
16210
16265
|
notifications: { completed: true, needsInput: true, failed: true, sound: true }
|
|
16211
16266
|
};
|
|
16267
|
+
const AUTO_COMPACT_RANGE = { minimum: 1e5, maximum: 1e6 };
|
|
16268
|
+
const AutoCompactTokens = Int.check(isBetween(AUTO_COMPACT_RANGE));
|
|
16212
16269
|
const Settings$1 = Struct({
|
|
16213
16270
|
defaultModel: Struct({
|
|
16214
16271
|
claude: NullOr(String$1),
|
|
@@ -16233,6 +16290,15 @@ const Settings$1 = Struct({
|
|
|
16233
16290
|
codex: NullOr(AgentProfileName),
|
|
16234
16291
|
muse: NullOr(AgentProfileName)
|
|
16235
16292
|
}).pipe(withDecodingDefaultKey(succeed$3({ claude: null, codex: null, muse: null }))),
|
|
16293
|
+
/**
|
|
16294
|
+
* How full each agent's context window gets, in tokens, before it compacts the conversation. Null keeps the
|
|
16295
|
+
* agent's own threshold. The range is Claude Code's, which ignores anything outside it.
|
|
16296
|
+
*/
|
|
16297
|
+
autoCompactTokens: Struct({
|
|
16298
|
+
claude: NullOr(AutoCompactTokens),
|
|
16299
|
+
codex: NullOr(AutoCompactTokens),
|
|
16300
|
+
muse: NullOr(AutoCompactTokens)
|
|
16301
|
+
}).pipe(withDecodingDefaultKey(succeed$3({ claude: null, codex: null, muse: null }))),
|
|
16236
16302
|
/** Where the automation webhook listener binds. 0.0.0.0 exposes it on the LAN and Tailscale. */
|
|
16237
16303
|
automations: Struct({
|
|
16238
16304
|
bindHost: String$1,
|
|
@@ -16258,6 +16324,7 @@ const defaultSettings = {
|
|
|
16258
16324
|
modelPresets: { claude: [], codex: [], muse: [] },
|
|
16259
16325
|
defaultAccount: { claude: null, codex: null, muse: null },
|
|
16260
16326
|
defaultAccountName: { claude: null, codex: null, muse: null },
|
|
16327
|
+
autoCompactTokens: { claude: null, codex: null, muse: null },
|
|
16261
16328
|
automations: { bindHost: "127.0.0.1", port: 48080 },
|
|
16262
16329
|
remote: { enabled: false, bindHost: "0.0.0.0", port: 48081 },
|
|
16263
16330
|
textGenerationModel: "claude-sonnet-5-5",
|
|
@@ -16276,7 +16343,12 @@ const Environment = Struct({
|
|
|
16276
16343
|
const EnvironmentStatus = Literals(["connecting", "connected", "offline", "unauthorized", "incompatible"]);
|
|
16277
16344
|
const Environments$1 = Struct({
|
|
16278
16345
|
clouds: ArraySchema(
|
|
16279
|
-
Struct({
|
|
16346
|
+
Struct({
|
|
16347
|
+
...Environment.fields,
|
|
16348
|
+
status: EnvironmentStatus,
|
|
16349
|
+
lastSeenAt: NullOr(Timestamp),
|
|
16350
|
+
protocol: optional$6(Int)
|
|
16351
|
+
})
|
|
16280
16352
|
)
|
|
16281
16353
|
});
|
|
16282
16354
|
const VmControl = Literals(["agent", "user"]);
|
|
@@ -16517,7 +16589,8 @@ const RpcMethods = {
|
|
|
16517
16589
|
id: String$1,
|
|
16518
16590
|
name: optional$6(String$1),
|
|
16519
16591
|
rootPath: optional$6(String$1),
|
|
16520
|
-
setupScript: optional$6(NullOr(String$1))
|
|
16592
|
+
setupScript: optional$6(NullOr(String$1)),
|
|
16593
|
+
linearReview: optional$6(Boolean$1)
|
|
16521
16594
|
}),
|
|
16522
16595
|
Project
|
|
16523
16596
|
),
|
|
@@ -16570,7 +16643,11 @@ const RpcMethods = {
|
|
|
16570
16643
|
Struct({ id: String$1, deleteBranch: Literals(["keep", "ifMerged", "force"]) }),
|
|
16571
16644
|
Worktree
|
|
16572
16645
|
),
|
|
16646
|
+
/** The checkout state of every live worktree. A checkout git cannot read is left out. */
|
|
16647
|
+
"worktrees.checkouts": rpc(Void2, ArraySchema(WorktreeCheckout)),
|
|
16573
16648
|
"worktrees.setupLog": rpc(Struct({ id: String$1 }), String$1),
|
|
16649
|
+
/** Kills a setup script still running; the worktree ends `failed`. */
|
|
16650
|
+
"worktrees.stopSetup": rpc(Struct({ id: String$1 }), Void2),
|
|
16574
16651
|
/** The branch's GitHub pull request via `gh`, or null when there is none. */
|
|
16575
16652
|
"worktrees.pullRequest": rpc(Struct({ id: String$1 }), NullOr(PullRequest)),
|
|
16576
16653
|
/** Null when the scope has no base: the thread has no live worktree, or no turn started in a git checkout. */
|
|
@@ -16586,6 +16663,14 @@ const RpcMethods = {
|
|
|
16586
16663
|
"projects.branches": rpc(Struct({ id: String$1 }), ArraySchema(String$1)),
|
|
16587
16664
|
/** Open pull requests of the project's repository, newest first. Empty when `gh` is missing or signed out. */
|
|
16588
16665
|
"projects.pullRequests": rpc(Struct({ id: String$1 }), ArraySchema(OpenPullRequest)),
|
|
16666
|
+
/**
|
|
16667
|
+
* Pull requests of the project's GitHub repository in any state, best match first, or the newest for an empty query.
|
|
16668
|
+
* Empty when the project is not on GitHub or `gh` is missing or signed out.
|
|
16669
|
+
*/
|
|
16670
|
+
"projects.searchPullRequests": rpc(
|
|
16671
|
+
Struct({ id: String$1, query: String$1 }),
|
|
16672
|
+
ArraySchema(PullRequestMatch)
|
|
16673
|
+
),
|
|
16589
16674
|
/** Fetches `origin`, so the branch picker and a new worktree's default base are current. */
|
|
16590
16675
|
"projects.fetch": rpc(Struct({ id: String$1 }), Void2),
|
|
16591
16676
|
/** The project's own favicon as a data URL, or null when it has none. */
|
|
@@ -16629,6 +16714,8 @@ const RpcMethods = {
|
|
|
16629
16714
|
"environments.add": rpc(Struct({ name: String$1, pairingUrl: String$1 }), Environment),
|
|
16630
16715
|
/** Forgets the cloud and its token. Its projects and threads stay on the cloud. */
|
|
16631
16716
|
"environments.remove": rpc(Struct({ id: String$1 }), Void2),
|
|
16717
|
+
/** Dials an offline or incompatible cloud now instead of after its backoff. Calls waiting for it keep waiting. */
|
|
16718
|
+
"environments.reconnect": rpc(Struct({ id: String$1 }), Void2),
|
|
16632
16719
|
"models.list": rpc(Struct({ provider: ProviderId }), ArraySchema(ModelInfo)),
|
|
16633
16720
|
/** Who the account is signed in as. `accountId` null is the CLI's own login. */
|
|
16634
16721
|
"agents.account": rpc(Struct({ provider: ProviderId, accountId: NullOr(String$1) }), AgentAccount),
|
|
@@ -16925,7 +17012,9 @@ const methodKind = {
|
|
|
16925
17012
|
"worktrees.list": "read",
|
|
16926
17013
|
"worktrees.create": "mutation",
|
|
16927
17014
|
"worktrees.remove": "mutation",
|
|
17015
|
+
"worktrees.checkouts": "read",
|
|
16928
17016
|
"worktrees.setupLog": "read",
|
|
17017
|
+
"worktrees.stopSetup": "mutation",
|
|
16929
17018
|
"worktrees.pullRequest": "read",
|
|
16930
17019
|
"threads.changes": "read",
|
|
16931
17020
|
"threads.archive": "mutation",
|
|
@@ -16934,6 +17023,7 @@ const methodKind = {
|
|
|
16934
17023
|
"projects.defaultBranch": "read",
|
|
16935
17024
|
"projects.branches": "read",
|
|
16936
17025
|
"projects.pullRequests": "read",
|
|
17026
|
+
"projects.searchPullRequests": "read",
|
|
16937
17027
|
"projects.fetch": "mutation",
|
|
16938
17028
|
"projects.icon": "read",
|
|
16939
17029
|
"git.log": "read",
|
|
@@ -16950,6 +17040,7 @@ const methodKind = {
|
|
|
16950
17040
|
"environments.list": "read",
|
|
16951
17041
|
"environments.add": "mutation",
|
|
16952
17042
|
"environments.remove": "mutation",
|
|
17043
|
+
"environments.reconnect": "mutation",
|
|
16953
17044
|
"models.list": "read",
|
|
16954
17045
|
"agents.account": "read",
|
|
16955
17046
|
"agents.updates": "read",
|
|
@@ -17061,6 +17152,7 @@ const desktopOnlyMethods = /* @__PURE__ */ new Set([
|
|
|
17061
17152
|
"environments.list",
|
|
17062
17153
|
"environments.add",
|
|
17063
17154
|
"environments.remove",
|
|
17155
|
+
"environments.reconnect",
|
|
17064
17156
|
"agents.update"
|
|
17065
17157
|
]);
|
|
17066
17158
|
const desktopOnlyPushes = /* @__PURE__ */ new Set([
|
|
@@ -17169,7 +17261,8 @@ const pairingUrl = ({ hosts, port, token }) => {
|
|
|
17169
17261
|
const remoteWebSocketUrl = ({ host, port }) => `ws://${host.includes(":") ? `[${host}]` : host}:${port}${REMOTE_PATH}`;
|
|
17170
17262
|
const isAuthorityOnlyHost = (host) => host !== "" && !/[\s/?#@[\]\\]/.test(host) && URL.parse(remoteWebSocketUrl({ host, port: 1 })) !== null;
|
|
17171
17263
|
const parsePairingUrl = (text2) => {
|
|
17172
|
-
const
|
|
17264
|
+
const word = text2.split(/\s+/).find((part) => /^hinacode:\/\/connect\?/i.test(part));
|
|
17265
|
+
const url = word === void 0 ? null : URL.parse(word);
|
|
17173
17266
|
if (!url || url.protocol !== "hinacode:" || url.host !== "connect") return null;
|
|
17174
17267
|
const hosts = url.searchParams.getAll("host");
|
|
17175
17268
|
const port = Number(url.searchParams.get("port"));
|
|
@@ -17178,6 +17271,7 @@ const parsePairingUrl = (text2) => {
|
|
|
17178
17271
|
if (!token || !Number.isInteger(port) || port < 1 || port > 65535) return null;
|
|
17179
17272
|
return { hosts, port, token };
|
|
17180
17273
|
};
|
|
17274
|
+
const isPortInUse = (listenError) => listenError.includes("EADDRINUSE");
|
|
17181
17275
|
const ExitCode = /* @__PURE__ */ nominal();
|
|
17182
17276
|
const ProcessId = /* @__PURE__ */ nominal();
|
|
17183
17277
|
const HandleTypeId = "~effect/process/ChildProcessSpawner/ChildProcessHandle";
|
|
@@ -19003,13 +19097,12 @@ class ThreadBusyError extends TaggedError()("ThreadBusyError", {
|
|
|
19003
19097
|
}
|
|
19004
19098
|
}
|
|
19005
19099
|
const busyReasons = {
|
|
19006
|
-
setup: "its setup script is still running",
|
|
19007
19100
|
turn: "a thread is still running in it",
|
|
19008
19101
|
shared: "another thread still uses it"
|
|
19009
19102
|
};
|
|
19010
19103
|
class WorktreeBusyError extends TaggedError()("WorktreeBusyError", {
|
|
19011
19104
|
path: String$1,
|
|
19012
|
-
reason: Literals(["
|
|
19105
|
+
reason: Literals(["turn", "shared"])
|
|
19013
19106
|
}) {
|
|
19014
19107
|
get message() {
|
|
19015
19108
|
return `Cannot remove ${this.path}: ${busyReasons[this.reason]}`;
|
|
@@ -20165,6 +20258,7 @@ const layer$B = effect(
|
|
|
20165
20258
|
...effort === null ? {} : { effort },
|
|
20166
20259
|
settings: {
|
|
20167
20260
|
fastMode: input.fastMode,
|
|
20261
|
+
...input.autoCompactTokens !== null && { autoCompactWindow: input.autoCompactTokens },
|
|
20168
20262
|
...input.effort === ULTRACODE && { ultracode: true },
|
|
20169
20263
|
...hidden !== null && { skillOverrides: hidden }
|
|
20170
20264
|
},
|
|
@@ -20203,6 +20297,7 @@ const layer$B = effect(
|
|
|
20203
20297
|
effort: input.effort,
|
|
20204
20298
|
fastMode: input.fastMode,
|
|
20205
20299
|
userSkills: input.userSkills,
|
|
20300
|
+
autoCompactTokens: input.autoCompactTokens,
|
|
20206
20301
|
permissionMode: mode,
|
|
20207
20302
|
prompts,
|
|
20208
20303
|
abort,
|
|
@@ -20235,7 +20330,8 @@ const layer$B = effect(
|
|
|
20235
20330
|
const acquireSession = (input, mode) => gen(function* () {
|
|
20236
20331
|
const existing = sessions.get(input.threadId);
|
|
20237
20332
|
if (existing !== void 0) {
|
|
20238
|
-
if (sameContext(existing, input) && existing.userSkills === input.userSkills
|
|
20333
|
+
if (sameContext(existing, input) && existing.userSkills === input.userSkills && existing.autoCompactTokens === input.autoCompactTokens)
|
|
20334
|
+
return claim(existing);
|
|
20239
20335
|
yield* closeSession(existing);
|
|
20240
20336
|
}
|
|
20241
20337
|
return yield* startSession(input, mode);
|
|
@@ -20480,6 +20576,7 @@ const usageLimitAssistant = {
|
|
|
20480
20576
|
}
|
|
20481
20577
|
};
|
|
20482
20578
|
const markdownFixture = '# Heading 1 with `code`\n\nA paragraph right under a heading. It runs long enough to wrap, so the line height and the measure of the transcript column are visible. **Bold**, _italic_, **_bold italic_**, ~~strikethrough~~, `inline code`, and a [link to the docs](https://github.com/hinadev-ai/hinacode). A bare URL autolinks: https://github.com/hinadev-ai/hinacode. A pull request reference: #1.\n\nA second paragraph, to show the gap between paragraphs.\nThis line follows a soft break, so it joins the paragraph above.\\\nThis line follows a hard break, so it starts on its own line.\n\n## Heading 2\n\n### Heading 3\n\n#### Heading 4\n\n##### Heading 5\n\n###### Heading 6\n\n---\n\n## Links\n\nEach web link should start with an icon. Pull requests get the GitHub mark and a hover card, other sites their favicon, and a site without one the globe.\n\n- A bare pull request URL, shortened to `owner/repo#n`: https://github.com/react/react/pull/31139\n- A pull request with its own text: [the React Compiler ref fix](https://github.com/react/react/pull/34000)\n- A pull request in another repository: https://github.com/vercel/next.js/pull/71000\n- A GitHub issue, which is not a pull request: https://github.com/react/react/issues/11347\n- A repository: https://github.com/react/react\n- Documentation sites: [React docs](https://react.dev/reference/react/useMemo), [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-wrap) and https://tailwindcss.com/docs/overflow-wrap\n- A site with no favicon: https://example.com\n- A link inside **bold text: [react.dev](https://react.dev)** and one inside a sentence that wraps across lines so the icon stays with its text: [the Effect documentation on services and layers](https://effect.website/docs/requirements-management/services/)\n- Not web links, so no icon: [an email](mailto:dev@example.com) and [a relative path](./README.md)\n\n## Lists\n\n- An unordered item\n- An item with **bold** and `code`\n - A nested item\n - A third level\n- An item long enough to wrap onto a second line, to check that the wrapped line lines up with the text and not with the bullet.\n\n1. First\n2. Second\n 1. Nested ordered\n 2. Another\n3. Third\n\nAn ordered list that starts at five:\n\n5. Five\n6. Six\n\nA task list:\n\n- [x] A finished task\n- [ ] An open task\n - [ ] A nested task\n\nA loose list:\n\n- A loose list item, with a blank line after it.\n\n- The next loose item, with a paragraph inside.\n\n A second paragraph in the same item.\n\n## Quotes\n\n> A quote with a single paragraph, long enough to wrap, so the bar runs the height of both lines and stays inside the quote.\n\n> A quote with a list:\n>\n> - one\n> - two\n>\n> > A nested quote.\n\n## Code\n\nInline `const answer = 42` sits on the baseline of the text around it.\n\n```ts\nimport { Effect } from "effect"\n\n/** A long line to check horizontal scrolling inside the block, instead of the whole transcript widening past the column. */\nexport const greet = (name: string) => Effect.succeed(`Hello, ${name}`)\n```\n\n```\nA fence without a language.\n```\n\n```sh\npnpm typecheck && pnpm lint && pnpm test\n```\n\n## Table\n\n| Left | Center | Right | Notes |\n| :----------------------------------- | :----: | -----: | ------------------------------------------------------------------------- |\n| `fonts/otf/` | 8 | 1.2 MB | Static weights from Thin to ExtraBold |\n| `fonts/ttf/` | 8 | 1.4 MB | The same weights as TTF |\n| `fonts/variable/PaperMono[wght].ttf` | 1 | 310 KB | One file covering the whole weight range, long enough to wrap in its cell |\n| `fonts/webfonts/` | 9 | 640 KB | WOFF2 versions of all of the above |\n\n## Diagram\n\n```mermaid\nflowchart LR\n Prompt --> Agent --> Worktree --> PR\n```\n\n## Text in other scripts\n\n這是一段繁體中文,用來檢查中英混排時的行高與字距,例如 `pnpm dev` 與 HinaCode 之間的間隔。\n\nこれは日本語の段落です。行の高さと、英数字の HinaCode や `git fetch` との混在を確認します。\n\n## Edge cases\n\nA footnote reference[^1] and an escaped \\*asterisk\\*. Keys render as keys: press <kbd>Cmd</kbd> + <kbd>Shift</kbd> + <kbd>P</kbd>. Other raw HTML stays text: <div>, and a tag written in prose like <Suspense> stays visible.\n\nA very long unbroken token: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n\n[^1]: The footnote text.\n';
|
|
20579
|
+
const mockScenarios = ["usage-limit", "org-spend-limit", "todos", "markdown", "stream"];
|
|
20483
20580
|
const commands = [
|
|
20484
20581
|
{
|
|
20485
20582
|
trigger: "/",
|
|
@@ -20500,8 +20597,18 @@ const toolCall = (callId, name, input, output) => [
|
|
|
20500
20597
|
{ type: "tool_call_started", callId, name, input },
|
|
20501
20598
|
{ type: "tool_call_finished", callId, output, isError: false }
|
|
20502
20599
|
];
|
|
20600
|
+
const chunks = (text2, size2) => text2.match(new RegExp(`[\\s\\S]{1,${size2}}`, "g")) ?? [];
|
|
20503
20601
|
const markdownTurn = () => [
|
|
20504
|
-
...(markdownFixture
|
|
20602
|
+
...chunks(markdownFixture, 400).map((text2) => ({ type: "text_delta", text: text2 })),
|
|
20603
|
+
{ type: "turn_completed" }
|
|
20604
|
+
];
|
|
20605
|
+
const streamTurn = () => [
|
|
20606
|
+
...chunks(markdownFixture.slice(0, 900), 30).map((text2) => ({ type: "reasoning_delta", text: text2 })),
|
|
20607
|
+
...Array.from(
|
|
20608
|
+
{ length: 6 },
|
|
20609
|
+
(_, index) => toolCall(`stream-read-${index}`, "Read", { file_path: `src/file-${index}.ts` }, markdownFixture)
|
|
20610
|
+
).flat(),
|
|
20611
|
+
...chunks(markdownFixture, 30).map((text2) => ({ type: "text_delta", text: text2 })),
|
|
20505
20612
|
{ type: "turn_completed" }
|
|
20506
20613
|
];
|
|
20507
20614
|
const todoTurn = (first) => first ? [
|
|
@@ -20573,6 +20680,8 @@ const usageLimitLayer = (scenario = "usage-limit", resetAfterMs = 6e4) => effect
|
|
|
20573
20680
|
listCommands: () => succeed$3(commands),
|
|
20574
20681
|
runTurn: (input) => suspend(() => {
|
|
20575
20682
|
if (scenario === "markdown") return fromIterable(markdownTurn());
|
|
20683
|
+
if (scenario === "stream")
|
|
20684
|
+
return fromIterable(streamTurn()).pipe(tap$1(() => sleep("20 millis")));
|
|
20576
20685
|
if (scenario === "todos") {
|
|
20577
20686
|
const first = !attempted.has(input.threadId);
|
|
20578
20687
|
attempted.add(input.threadId);
|
|
@@ -21121,6 +21230,7 @@ const make$T = gen(function* () {
|
|
|
21121
21230
|
const runs = /* @__PURE__ */ new Map();
|
|
21122
21231
|
const subagentsByThread = /* @__PURE__ */ new Map();
|
|
21123
21232
|
const subagentTurns = /* @__PURE__ */ new Map();
|
|
21233
|
+
const loadedCompactLimits = /* @__PURE__ */ new Map();
|
|
21124
21234
|
const listModels = gen(function* () {
|
|
21125
21235
|
const client = yield* getClient(null);
|
|
21126
21236
|
const models = [];
|
|
@@ -21211,6 +21321,7 @@ const make$T = gen(function* () {
|
|
|
21211
21321
|
config: {
|
|
21212
21322
|
// Off by default in current Codex; the composer's task list is built from its plan.
|
|
21213
21323
|
tools: { update_plan: { enabled: true } },
|
|
21324
|
+
...input.autoCompactTokens !== null && { model_auto_compact_token_limit: input.autoCompactTokens },
|
|
21214
21325
|
...hiddenSkills !== null && {
|
|
21215
21326
|
skills: { config: hiddenSkills.map((skill) => ({ path: skill.path, enabled: false })) }
|
|
21216
21327
|
},
|
|
@@ -21221,11 +21332,17 @@ const make$T = gen(function* () {
|
|
|
21221
21332
|
},
|
|
21222
21333
|
developerInstructions: input.instructions
|
|
21223
21334
|
};
|
|
21335
|
+
const resumed = input.resumeSessionId;
|
|
21336
|
+
const loadedLimit = resumed === null ? void 0 : loadedCompactLimits.get(resumed);
|
|
21337
|
+
if (resumed !== null && loadedLimit !== void 0 && loadedLimit !== input.autoCompactTokens) {
|
|
21338
|
+
yield* client.request("thread/unsubscribe", { threadId: resumed });
|
|
21339
|
+
}
|
|
21224
21340
|
const { thread, sandbox } = input.resumeSessionId ? yield* client.request("thread/resume", {
|
|
21225
21341
|
...overrides,
|
|
21226
21342
|
threadId: input.resumeSessionId,
|
|
21227
21343
|
excludeTurns: true
|
|
21228
21344
|
}) : yield* client.request("thread/start", overrides);
|
|
21345
|
+
loadedCompactLimits.set(thread.id, input.autoCompactTokens);
|
|
21229
21346
|
yield* emit({ type: "session_bound", providerSessionId: thread.id });
|
|
21230
21347
|
const skills = input.prompt.includes("$") ? (yield* listSkills2(input.cwd, input.home)).filter((skill) => input.userSkills || skill.scope !== "user") : [];
|
|
21231
21348
|
const turnStart = {
|
|
@@ -21445,12 +21562,22 @@ const make$T = gen(function* () {
|
|
|
21445
21562
|
}
|
|
21446
21563
|
case "item/started": {
|
|
21447
21564
|
const params2 = message.params;
|
|
21565
|
+
if (params2.item.type === "contextCompaction") {
|
|
21566
|
+
yield* emit({ type: "compaction_updated", compaction: { status: "running" } });
|
|
21567
|
+
}
|
|
21448
21568
|
yield* startTool(params2.item);
|
|
21449
21569
|
yield* emitSubagents(applyParentItem(subagents, params2.item, yield* nowIso));
|
|
21450
21570
|
return false;
|
|
21451
21571
|
}
|
|
21452
21572
|
case "item/completed": {
|
|
21453
21573
|
const params2 = message.params;
|
|
21574
|
+
if (params2.item.type === "contextCompaction") {
|
|
21575
|
+
yield* emit({
|
|
21576
|
+
type: "compaction_updated",
|
|
21577
|
+
// Codex starts compaction only by itself, and its item carries no token counts.
|
|
21578
|
+
compaction: { status: "done", trigger: "auto", preTokens: null, postTokens: null }
|
|
21579
|
+
});
|
|
21580
|
+
}
|
|
21454
21581
|
yield* finishTool(params2.item);
|
|
21455
21582
|
if (params2.item.type === "agentMessage" && params2.item.questions) {
|
|
21456
21583
|
yield* emit({
|
|
@@ -22061,6 +22188,31 @@ const promptParts = (host, sessionId, text2, attachments, instructions) => gen(f
|
|
|
22061
22188
|
};
|
|
22062
22189
|
return [skill, ...images];
|
|
22063
22190
|
});
|
|
22191
|
+
const trackContext = (sessions, method, params2) => {
|
|
22192
|
+
const session = sessions.get(params2?.sessionId ?? "");
|
|
22193
|
+
if (session === void 0) return;
|
|
22194
|
+
if (method === "session/contextUsage") session.usedTokens = params2.usedTokens;
|
|
22195
|
+
if (params2.item?.kind !== "compaction") return;
|
|
22196
|
+
if (method === "item/started") session.compacting = true;
|
|
22197
|
+
if (method === "item/completed") session.compacting = false;
|
|
22198
|
+
};
|
|
22199
|
+
const decodeContextUsage = decodeUnknownOption(Struct({ usedTokens: Number$1 }));
|
|
22200
|
+
const latestUsedTokens = (host, sessionId) => gen(function* () {
|
|
22201
|
+
let cursor = null;
|
|
22202
|
+
do {
|
|
22203
|
+
const raw2 = yield* host.request("view/page", {
|
|
22204
|
+
sessionId,
|
|
22205
|
+
direction: "backward",
|
|
22206
|
+
limit: 100,
|
|
22207
|
+
...cursor === null ? {} : { cursor }
|
|
22208
|
+
});
|
|
22209
|
+
const page = yield* decodeUnknownEffect(ViewPage)(raw2);
|
|
22210
|
+
const usage = page.events.findLast((event) => event.method === "session/contextUsage");
|
|
22211
|
+
if (usage !== void 0) return getOrNull(decodeContextUsage(usage.params))?.usedTokens ?? null;
|
|
22212
|
+
cursor = page.nextCursor;
|
|
22213
|
+
} while (cursor !== null);
|
|
22214
|
+
return null;
|
|
22215
|
+
}).pipe(catch_$2(() => succeed$3(null)));
|
|
22064
22216
|
const interruptTurn = (host, sessionId, turnId) => suspend$2(
|
|
22065
22217
|
() => host.isAlive() ? host.command("turn/interrupt", { sessionId, turnId }).pipe(mapError(toAgentError)) : void_$1
|
|
22066
22218
|
);
|
|
@@ -22087,11 +22239,16 @@ const make$S = gen(function* () {
|
|
|
22087
22239
|
provide$4(scope2),
|
|
22088
22240
|
onError(() => close(scope2, void_$2))
|
|
22089
22241
|
);
|
|
22242
|
+
const sessions = /* @__PURE__ */ new Map();
|
|
22090
22243
|
yield* host.subscribe((message) => {
|
|
22091
|
-
if (message.kind !== "notification"
|
|
22092
|
-
|
|
22244
|
+
if (message.kind !== "notification") return;
|
|
22245
|
+
if (message.method === "usage/changed") {
|
|
22246
|
+
planUsage = getOrElse(decodePlanUsage(message.params), () => planUsage);
|
|
22247
|
+
} else {
|
|
22248
|
+
trackContext(sessions, message.method, message.params);
|
|
22249
|
+
}
|
|
22093
22250
|
}).pipe(provide$4(scope2));
|
|
22094
|
-
current = { host, scope: scope2, sessions
|
|
22251
|
+
current = { host, scope: scope2, sessions };
|
|
22095
22252
|
return current;
|
|
22096
22253
|
})
|
|
22097
22254
|
);
|
|
@@ -22145,12 +22302,24 @@ const make$S = gen(function* () {
|
|
|
22145
22302
|
catch_$2(() => succeed$3(void 0))
|
|
22146
22303
|
);
|
|
22147
22304
|
if (resumed !== void 0) {
|
|
22148
|
-
sessions.set(known, {
|
|
22305
|
+
sessions.set(known, {
|
|
22306
|
+
model: resumed.modelId,
|
|
22307
|
+
approvalMode: resumed.approvalMode?.mode ?? null,
|
|
22308
|
+
cwd,
|
|
22309
|
+
usedTokens: null,
|
|
22310
|
+
compacting: false
|
|
22311
|
+
});
|
|
22149
22312
|
return known;
|
|
22150
22313
|
}
|
|
22151
22314
|
}
|
|
22152
22315
|
const { session } = yield* host.command("session/start", { workspaceRoot: cwd }).pipe(mapError(toAgentError));
|
|
22153
|
-
sessions.set(session.sessionId, {
|
|
22316
|
+
sessions.set(session.sessionId, {
|
|
22317
|
+
model: session.modelId ?? null,
|
|
22318
|
+
approvalMode: null,
|
|
22319
|
+
cwd,
|
|
22320
|
+
usedTokens: null,
|
|
22321
|
+
compacting: false
|
|
22322
|
+
});
|
|
22154
22323
|
probeSessions.set(cwd, session.sessionId);
|
|
22155
22324
|
return session.sessionId;
|
|
22156
22325
|
})
|
|
@@ -22182,7 +22351,13 @@ const make$S = gen(function* () {
|
|
|
22182
22351
|
approvalMode,
|
|
22183
22352
|
config
|
|
22184
22353
|
});
|
|
22185
|
-
sessions.set(session.sessionId, {
|
|
22354
|
+
sessions.set(session.sessionId, {
|
|
22355
|
+
model: input.model,
|
|
22356
|
+
approvalMode,
|
|
22357
|
+
cwd: input.cwd,
|
|
22358
|
+
usedTokens: null,
|
|
22359
|
+
compacting: false
|
|
22360
|
+
});
|
|
22186
22361
|
threadSessions.set(input.threadId, session.sessionId);
|
|
22187
22362
|
return session.sessionId;
|
|
22188
22363
|
}
|
|
@@ -22194,7 +22369,14 @@ const make$S = gen(function* () {
|
|
|
22194
22369
|
excludeItems: true,
|
|
22195
22370
|
config
|
|
22196
22371
|
});
|
|
22197
|
-
loaded = {
|
|
22372
|
+
loaded = {
|
|
22373
|
+
model: session.modelId,
|
|
22374
|
+
approvalMode: session.approvalMode?.mode ?? null,
|
|
22375
|
+
cwd: input.cwd,
|
|
22376
|
+
// An `excludeItems` resume carries no context usage.
|
|
22377
|
+
usedTokens: input.autoCompactTokens === null ? null : yield* latestUsedTokens(host, sessionId),
|
|
22378
|
+
compacting: false
|
|
22379
|
+
};
|
|
22198
22380
|
sessions.set(sessionId, loaded);
|
|
22199
22381
|
}
|
|
22200
22382
|
threadSessions.set(input.threadId, sessionId);
|
|
@@ -22225,20 +22407,6 @@ const make$S = gen(function* () {
|
|
|
22225
22407
|
const sessionId = yield* openSession(entry, input);
|
|
22226
22408
|
run2.sessionId = sessionId;
|
|
22227
22409
|
yield* emit({ type: "session_bound", providerSessionId: sessionId });
|
|
22228
|
-
const prompt = yield* promptParts(host, sessionId, input.prompt, input.attachments, input.instructions);
|
|
22229
|
-
run2.turnStart = yield* host.command("turn/start", {
|
|
22230
|
-
sessionId,
|
|
22231
|
-
// Muse shows `displayText`, never the instructions in front of the prompt.
|
|
22232
|
-
input: prompt,
|
|
22233
|
-
displayText: input.prompt,
|
|
22234
|
-
...input.effort === null ? {} : { reasoningEffort: input.effort }
|
|
22235
|
-
}).pipe(
|
|
22236
|
-
map$3((ack) => ack.turnId),
|
|
22237
|
-
mapError(toAgentError),
|
|
22238
|
-
forkIn(providerScope)
|
|
22239
|
-
);
|
|
22240
|
-
const turnId = yield* join$1(run2.turnStart);
|
|
22241
|
-
run2.turnId = turnId;
|
|
22242
22410
|
const threadGrants = grants.get(input.threadId) ?? /* @__PURE__ */ new Set();
|
|
22243
22411
|
grants.set(input.threadId, threadGrants);
|
|
22244
22412
|
const pendingApprovals = /* @__PURE__ */ new Map();
|
|
@@ -22248,6 +22416,7 @@ const make$S = gen(function* () {
|
|
|
22248
22416
|
const toolOutput = /* @__PURE__ */ new Map();
|
|
22249
22417
|
const openTools = /* @__PURE__ */ new Set();
|
|
22250
22418
|
let context2;
|
|
22419
|
+
let compacting = false;
|
|
22251
22420
|
const decide = (approval, decision) => gen(function* () {
|
|
22252
22421
|
const stage2 = approval.params.currentRequirementId.sourceIndex;
|
|
22253
22422
|
if (approval.answered === stage2) return;
|
|
@@ -22412,10 +22581,23 @@ const make$S = gen(function* () {
|
|
|
22412
22581
|
return finishText(item, "reasoning_delta", (item.summary ?? []).join(SUMMARY_BREAK));
|
|
22413
22582
|
case "toolCall":
|
|
22414
22583
|
return finishTool(item);
|
|
22584
|
+
case "compaction":
|
|
22585
|
+
return finishCompaction(item);
|
|
22415
22586
|
default:
|
|
22416
22587
|
return void_$1;
|
|
22417
22588
|
}
|
|
22418
22589
|
};
|
|
22590
|
+
const finishCompaction = (item) => {
|
|
22591
|
+
const trigger = compacting || item.trigger !== "manual" ? "auto" : "manual";
|
|
22592
|
+
compacting = false;
|
|
22593
|
+
const compaction = item.outcome === "compacted" || item.outcome === "noop" ? {
|
|
22594
|
+
status: "done",
|
|
22595
|
+
trigger,
|
|
22596
|
+
preTokens: item.tokensBefore ?? null,
|
|
22597
|
+
postTokens: item.tokensAfter ?? null
|
|
22598
|
+
} : { status: "failed", message: item.reason ?? null };
|
|
22599
|
+
return emit({ type: "compaction_updated", compaction });
|
|
22600
|
+
};
|
|
22419
22601
|
const finishTurn = (params2) => gen(function* () {
|
|
22420
22602
|
for (const callId of openTools) {
|
|
22421
22603
|
const output = toolOutput.get(callId) ?? `Turn ${params2.terminal}`;
|
|
@@ -22464,6 +22646,9 @@ const make$S = gen(function* () {
|
|
|
22464
22646
|
case "item/started": {
|
|
22465
22647
|
const { item } = message.params;
|
|
22466
22648
|
if (item.kind === "toolCall") yield* startTool(item);
|
|
22649
|
+
if (item.kind === "compaction") {
|
|
22650
|
+
yield* emit({ type: "compaction_updated", compaction: { status: "running" } });
|
|
22651
|
+
}
|
|
22467
22652
|
return false;
|
|
22468
22653
|
}
|
|
22469
22654
|
case "item/delta":
|
|
@@ -22482,13 +22667,13 @@ const make$S = gen(function* () {
|
|
|
22482
22667
|
yield* resolveQuestion(message.params);
|
|
22483
22668
|
return false;
|
|
22484
22669
|
case "session/contextUsage": {
|
|
22485
|
-
const { usedTokens, windowTokens } = message.params;
|
|
22486
|
-
if (windowTokens !== void 0) context2 = { usedTokens, maxTokens: windowTokens };
|
|
22670
|
+
const { usedTokens: usedTokens2, windowTokens } = message.params;
|
|
22671
|
+
if (windowTokens !== void 0) context2 = { usedTokens: usedTokens2, maxTokens: windowTokens };
|
|
22487
22672
|
return false;
|
|
22488
22673
|
}
|
|
22489
22674
|
case "turn/completed": {
|
|
22490
22675
|
const params2 = message.params;
|
|
22491
|
-
if (params2.turnId !== turnId) return false;
|
|
22676
|
+
if (params2.turnId !== run2.turnId) return false;
|
|
22492
22677
|
yield* finishTurn(params2);
|
|
22493
22678
|
return true;
|
|
22494
22679
|
}
|
|
@@ -22496,6 +22681,34 @@ const make$S = gen(function* () {
|
|
|
22496
22681
|
return false;
|
|
22497
22682
|
}
|
|
22498
22683
|
});
|
|
22684
|
+
const loaded = entry.sessions.get(sessionId);
|
|
22685
|
+
const usedTokens = loaded?.usedTokens ?? null;
|
|
22686
|
+
if (loaded?.compacting) {
|
|
22687
|
+
compacting = true;
|
|
22688
|
+
yield* emit({ type: "compaction_updated", compaction: { status: "running" } });
|
|
22689
|
+
} else if (input.autoCompactTokens !== null && usedTokens !== null && usedTokens >= input.autoCompactTokens) {
|
|
22690
|
+
const ack = yield* host.command("session/compact", { sessionId }).pipe(
|
|
22691
|
+
map$3((result2) => result2.status),
|
|
22692
|
+
catch_$2((error) => logWarning("session/compact failed", error.message).pipe(as(null)))
|
|
22693
|
+
);
|
|
22694
|
+
compacting = ack === "accepted";
|
|
22695
|
+
}
|
|
22696
|
+
if (compacting) {
|
|
22697
|
+
yield* take(inbox).pipe(flatMap$1(handle), repeat({ while: () => compacting }));
|
|
22698
|
+
}
|
|
22699
|
+
const prompt = yield* promptParts(host, sessionId, input.prompt, input.attachments, input.instructions);
|
|
22700
|
+
run2.turnStart = yield* host.command("turn/start", {
|
|
22701
|
+
sessionId,
|
|
22702
|
+
// Muse shows `displayText`, never the instructions in front of the prompt.
|
|
22703
|
+
input: prompt,
|
|
22704
|
+
displayText: input.prompt,
|
|
22705
|
+
...input.effort === null ? {} : { reasoningEffort: input.effort }
|
|
22706
|
+
}).pipe(
|
|
22707
|
+
map$3((ack) => ack.turnId),
|
|
22708
|
+
mapError(toAgentError),
|
|
22709
|
+
forkIn(providerScope)
|
|
22710
|
+
);
|
|
22711
|
+
run2.turnId = yield* join$1(run2.turnStart);
|
|
22499
22712
|
while (!(yield* take(inbox).pipe(flatMap$1(handle)))) {
|
|
22500
22713
|
}
|
|
22501
22714
|
});
|
|
@@ -23017,6 +23230,10 @@ const threadUserSkills = gen(function* () {
|
|
|
23017
23230
|
const sql = yield* SqlClient;
|
|
23018
23231
|
yield* sql`ALTER TABLE thread ADD COLUMN user_skills INTEGER NOT NULL DEFAULT 1 CHECK (user_skills IN (0, 1))`;
|
|
23019
23232
|
});
|
|
23233
|
+
const projectLinearReview = gen(function* () {
|
|
23234
|
+
const sql = yield* SqlClient;
|
|
23235
|
+
yield* sql`ALTER TABLE project ADD COLUMN linear_review INTEGER NOT NULL DEFAULT 0 CHECK (linear_review IN (0, 1))`;
|
|
23236
|
+
});
|
|
23020
23237
|
const run = make$V({});
|
|
23021
23238
|
const runMigrations = run({
|
|
23022
23239
|
loader: fromRecord({
|
|
@@ -23036,9 +23253,14 @@ const runMigrations = run({
|
|
|
23036
23253
|
"15_environments": environments,
|
|
23037
23254
|
"16_thread_queue": threadQueue,
|
|
23038
23255
|
"17_fts_on_completion": ftsOnCompletion,
|
|
23039
|
-
"18_thread_user_skills": threadUserSkills
|
|
23256
|
+
"18_thread_user_skills": threadUserSkills,
|
|
23257
|
+
"19_project_linear_review": projectLinearReview
|
|
23040
23258
|
})
|
|
23041
|
-
}).pipe(
|
|
23259
|
+
}).pipe(
|
|
23260
|
+
tap$2(
|
|
23261
|
+
(ran) => ran.length === 0 ? void_$1 : logInfo(`migrations ran up to ${ran.at(-1)?.join("_")}`)
|
|
23262
|
+
)
|
|
23263
|
+
);
|
|
23042
23264
|
const setup = effectDiscard(
|
|
23043
23265
|
gen(function* () {
|
|
23044
23266
|
const sql = yield* SqlClient;
|
|
@@ -23306,8 +23528,9 @@ const reviewStatus = {
|
|
|
23306
23528
|
CHANGES_REQUESTED: "changesRequested",
|
|
23307
23529
|
REVIEW_REQUIRED: "reviewRequired"
|
|
23308
23530
|
};
|
|
23531
|
+
const pullRequestStatus = (state, isDraft) => state === "OPEN" ? isDraft ? "draft" : "open" : state === "MERGED" ? "merged" : "closed";
|
|
23309
23532
|
const toPullRequest = (json2) => {
|
|
23310
|
-
const status = json2.state
|
|
23533
|
+
const status = pullRequestStatus(json2.state, json2.isDraft);
|
|
23311
23534
|
return {
|
|
23312
23535
|
url: json2.url,
|
|
23313
23536
|
number: json2.number,
|
|
@@ -23365,6 +23588,19 @@ const decodeOpenPullRequests = decodeUnknownEffect(
|
|
|
23365
23588
|
)
|
|
23366
23589
|
)
|
|
23367
23590
|
);
|
|
23591
|
+
const decodePullRequestMatches = decodeUnknownEffect(
|
|
23592
|
+
fromJsonString(
|
|
23593
|
+
ArraySchema(
|
|
23594
|
+
Struct({
|
|
23595
|
+
number: Int,
|
|
23596
|
+
title: String$1,
|
|
23597
|
+
state: PullRequestFields.fields.state,
|
|
23598
|
+
isDraft: Boolean$1,
|
|
23599
|
+
author: Struct({ login: String$1 })
|
|
23600
|
+
})
|
|
23601
|
+
)
|
|
23602
|
+
)
|
|
23603
|
+
);
|
|
23368
23604
|
class GitHub extends Service$1()("hinacode/GitHub") {
|
|
23369
23605
|
}
|
|
23370
23606
|
const SIGNED_OUT_EXIT_CODE = 4;
|
|
@@ -23439,6 +23675,29 @@ const make$P = gen(function* () {
|
|
|
23439
23675
|
flatMap$1(decodeOpenPullRequests),
|
|
23440
23676
|
map$3((list) => list.map(({ author, ...pullRequest }) => ({ ...pullRequest, author: author.login })))
|
|
23441
23677
|
),
|
|
23678
|
+
searchPullRequests: ({ owner, name }, query2) => gh(homedir(), [
|
|
23679
|
+
"pr",
|
|
23680
|
+
"list",
|
|
23681
|
+
"--repo",
|
|
23682
|
+
`${owner}/${name}`,
|
|
23683
|
+
"--state",
|
|
23684
|
+
"all",
|
|
23685
|
+
"--limit",
|
|
23686
|
+
"20",
|
|
23687
|
+
...query2 === "" ? [] : [`--search=${query2}`],
|
|
23688
|
+
"--json",
|
|
23689
|
+
"number,title,state,isDraft,author"
|
|
23690
|
+
]).pipe(
|
|
23691
|
+
flatMap$1(decodePullRequestMatches),
|
|
23692
|
+
map$3(
|
|
23693
|
+
(list) => list.map(({ number: number2, title, state, isDraft, author }) => ({
|
|
23694
|
+
number: number2,
|
|
23695
|
+
title,
|
|
23696
|
+
status: pullRequestStatus(state, isDraft),
|
|
23697
|
+
author: author.login
|
|
23698
|
+
}))
|
|
23699
|
+
)
|
|
23700
|
+
),
|
|
23442
23701
|
createPullRequest,
|
|
23443
23702
|
clone: clone2,
|
|
23444
23703
|
repository
|
|
@@ -23601,6 +23860,7 @@ const ICON_NAMES = ["favicon.svg", "favicon.png", "favicon.ico", "icon.svg", "ic
|
|
|
23601
23860
|
const ICON_DIRS = ["", "public", "static", "app", "src/app", "assets", "apps/web/public", "apps/web/app"];
|
|
23602
23861
|
const ICON_PATHS = ICON_DIRS.flatMap((dir) => ICON_NAMES.map((name) => join$2(dir, name)));
|
|
23603
23862
|
const ICON_LIMIT_BYTES$1 = 100 * 1024;
|
|
23863
|
+
const ProjectRow = Struct({ ...Project.fields, linearReview: BooleanFromBit });
|
|
23604
23864
|
const make$N = gen(function* () {
|
|
23605
23865
|
const sql = yield* SqlClient;
|
|
23606
23866
|
const fs = yield* FileSystem;
|
|
@@ -23608,12 +23868,12 @@ const make$N = gen(function* () {
|
|
|
23608
23868
|
const github = yield* GitHub;
|
|
23609
23869
|
const findAll$1 = findAll({
|
|
23610
23870
|
Request: Void2,
|
|
23611
|
-
Result:
|
|
23871
|
+
Result: ProjectRow,
|
|
23612
23872
|
execute: () => sql`SELECT * FROM project ORDER BY created_at`
|
|
23613
23873
|
});
|
|
23614
23874
|
const findById = findOneOption({
|
|
23615
23875
|
Request: String$1,
|
|
23616
|
-
Result:
|
|
23876
|
+
Result: ProjectRow,
|
|
23617
23877
|
execute: (id) => sql`SELECT * FROM project WHERE id = ${id}`
|
|
23618
23878
|
});
|
|
23619
23879
|
const get2 = (id) => findById(id).pipe(
|
|
@@ -23638,11 +23898,17 @@ const make$N = gen(function* () {
|
|
|
23638
23898
|
}).pipe(catchTag("PlatformError", () => fail$2(new ProjectRootInvalidError({ rootPath }))));
|
|
23639
23899
|
const insert = (input) => gen(function* () {
|
|
23640
23900
|
const now2 = yield* nowIso;
|
|
23641
|
-
const
|
|
23642
|
-
|
|
23901
|
+
const { linearReview, ...row } = {
|
|
23902
|
+
id: randomUUID(),
|
|
23903
|
+
...input,
|
|
23904
|
+
linearReview: false,
|
|
23905
|
+
createdAt: now2,
|
|
23906
|
+
updatedAt: now2
|
|
23907
|
+
};
|
|
23908
|
+
yield* sql`INSERT INTO project ${sql.insert(row)}`.pipe(
|
|
23643
23909
|
mapError(mapWriteError("projects.create", input.rootPath))
|
|
23644
23910
|
);
|
|
23645
|
-
return
|
|
23911
|
+
return { ...row, linearReview };
|
|
23646
23912
|
});
|
|
23647
23913
|
const create = (input) => gen(function* () {
|
|
23648
23914
|
const rootPath = yield* resolveRoot(input.rootPath);
|
|
@@ -23700,12 +23966,13 @@ const make$N = gen(function* () {
|
|
|
23700
23966
|
name: input.name ?? current.name,
|
|
23701
23967
|
rootPath: input.rootPath ?? current.rootPath,
|
|
23702
23968
|
setupScript: input.setupScript === void 0 ? current.setupScript : input.setupScript,
|
|
23969
|
+
linearReview: input.linearReview ?? current.linearReview,
|
|
23703
23970
|
updatedAt: yield* nowIso
|
|
23704
23971
|
};
|
|
23705
23972
|
yield* sql`
|
|
23706
23973
|
UPDATE project
|
|
23707
23974
|
SET name = ${next.name}, root_path = ${next.rootPath}, setup_script = ${next.setupScript},
|
|
23708
|
-
updated_at = ${next.updatedAt}
|
|
23975
|
+
linear_review = ${next.linearReview ? 1 : 0}, updated_at = ${next.updatedAt}
|
|
23709
23976
|
WHERE id = ${next.id}
|
|
23710
23977
|
`.pipe(mapError(mapWriteError("projects.update", next.rootPath)));
|
|
23711
23978
|
return next;
|
|
@@ -23974,7 +24241,7 @@ const make$L = gen(function* () {
|
|
|
23974
24241
|
})
|
|
23975
24242
|
)
|
|
23976
24243
|
);
|
|
23977
|
-
const publishCurrent = (id) => get2(id).pipe(tap$
|
|
24244
|
+
const publishCurrent = (id) => get2(id).pipe(tap$2((worktree) => events.publish({ type: "worktree.updated", worktree })));
|
|
23978
24245
|
const setStatus = (id, status) => sql`UPDATE worktree SET status = ${status} WHERE id = ${id}`.pipe(
|
|
23979
24246
|
mapError(persistence("worktrees.setStatus")),
|
|
23980
24247
|
andThen(publishCurrent(id))
|
|
@@ -24000,7 +24267,9 @@ const make$L = gen(function* () {
|
|
|
24000
24267
|
HINACODE_BRANCH: worktree.branch
|
|
24001
24268
|
},
|
|
24002
24269
|
extendEnv: true,
|
|
24003
|
-
stdin: "ignore"
|
|
24270
|
+
stdin: "ignore",
|
|
24271
|
+
// Without it, a script that ignores SIGTERM would keep stopSetup waiting forever.
|
|
24272
|
+
forceKillAfter: "3 seconds"
|
|
24004
24273
|
})
|
|
24005
24274
|
);
|
|
24006
24275
|
yield* handle.all.pipe(
|
|
@@ -24028,6 +24297,12 @@ Setup script exited with code ${exitCode}
|
|
|
24028
24297
|
andThen(setStatus(worktree.id, "failed")),
|
|
24029
24298
|
ignore$1
|
|
24030
24299
|
)
|
|
24300
|
+
),
|
|
24301
|
+
onInterrupt(
|
|
24302
|
+
() => appendLog(worktree.id, "\nSetup script was stopped.\n").pipe(
|
|
24303
|
+
andThen(setStatus(worktree.id, "failed")),
|
|
24304
|
+
ignore$1
|
|
24305
|
+
)
|
|
24031
24306
|
)
|
|
24032
24307
|
);
|
|
24033
24308
|
const setups = /* @__PURE__ */ new Map();
|
|
@@ -24039,10 +24314,14 @@ Setup script exited with code ${exitCode}
|
|
|
24039
24314
|
}
|
|
24040
24315
|
return yield* get2(id);
|
|
24041
24316
|
});
|
|
24317
|
+
const stopSetup = (id) => {
|
|
24318
|
+
const running = setups.get(id);
|
|
24319
|
+
return running === void 0 ? void_$1 : interrupt(running);
|
|
24320
|
+
};
|
|
24042
24321
|
const removals = /* @__PURE__ */ new Map();
|
|
24043
|
-
const findOrphan = (rootPath,
|
|
24322
|
+
const findOrphan = (rootPath, checkouts2, branch) => gen(function* () {
|
|
24044
24323
|
const checkout2 = (yield* registeredCheckouts(rootPath)).find(
|
|
24045
|
-
({ path, ref }) => ref === `refs/heads/${branch}` && dirname(path) ===
|
|
24324
|
+
({ path, ref }) => ref === `refs/heads/${branch}` && dirname(path) === checkouts2
|
|
24046
24325
|
);
|
|
24047
24326
|
if (!checkout2) return none();
|
|
24048
24327
|
const recorded = yield* findByPath(checkout2.path).pipe(mapError(persistence("worktrees.create")));
|
|
@@ -24060,10 +24339,10 @@ Setup script exited with code ${exitCode}
|
|
|
24060
24339
|
}
|
|
24061
24340
|
const rootPath = yield* resolve2(project.rootPath);
|
|
24062
24341
|
const { worktreeRoot } = yield* settings.get;
|
|
24063
|
-
const
|
|
24342
|
+
const checkouts2 = checkoutsDir(rootPath, worktreeRoot === null ? null : yield* resolve2(worktreeRoot));
|
|
24064
24343
|
const id = randomUUID();
|
|
24065
|
-
const orphan = yield* findOrphan(rootPath,
|
|
24066
|
-
const path = getOrElse(orphan, () => checkoutPath(
|
|
24344
|
+
const orphan = yield* findOrphan(rootPath, checkouts2, input.branch);
|
|
24345
|
+
const path = getOrElse(orphan, () => checkoutPath(checkouts2, input.branch, id));
|
|
24067
24346
|
if (isNone(orphan)) {
|
|
24068
24347
|
const args2 = (yield* branchExists(rootPath, input.branch)) ? ["worktree", "add", path, input.branch] : input.startPoint === void 0 ? (
|
|
24069
24348
|
// Forking from `origin/main` would otherwise make it the upstream, and a plain `git push` would fail.
|
|
@@ -24124,9 +24403,6 @@ Setup script exited with code ${exitCode}
|
|
|
24124
24403
|
return yield* publishCurrent(id);
|
|
24125
24404
|
}).pipe(exclusive);
|
|
24126
24405
|
const ensureRemovable = (worktree, owner) => gen(function* () {
|
|
24127
|
-
if (worktree.status === "preparing") {
|
|
24128
|
-
return yield* new WorktreeBusyError({ path: worktree.path, reason: "setup" });
|
|
24129
|
-
}
|
|
24130
24406
|
const users = yield* findUsers(worktree.id).pipe(mapError(persistence("worktrees.remove")));
|
|
24131
24407
|
if (users.some((thread) => isThreadBusy(thread.status))) {
|
|
24132
24408
|
return yield* new WorktreeBusyError({ path: worktree.path, reason: "turn" });
|
|
@@ -24138,7 +24414,7 @@ Setup script exited with code ${exitCode}
|
|
|
24138
24414
|
});
|
|
24139
24415
|
const deleteFiles = (rootPath, worktree, deleteBranch) => gen(function* () {
|
|
24140
24416
|
if ((yield* registeredCheckouts(rootPath)).some((registered) => registered.path === worktree.path)) {
|
|
24141
|
-
yield* git2.run(rootPath, ["worktree", "remove", "--force", worktree.path]);
|
|
24417
|
+
yield* git2.run(rootPath, ["worktree", "remove", "--force", "--force", worktree.path]);
|
|
24142
24418
|
}
|
|
24143
24419
|
yield* git2.run(rootPath, ["worktree", "prune"]);
|
|
24144
24420
|
if (deleteBranch !== "keep" && (yield* branchExists(rootPath, worktree.branch))) {
|
|
@@ -24161,13 +24437,32 @@ Setup script exited with code ${exitCode}
|
|
|
24161
24437
|
const worktree = yield* get2(id);
|
|
24162
24438
|
if (worktree.status === "removed") return worktree;
|
|
24163
24439
|
yield* ensureRemovable(worktree, owner);
|
|
24440
|
+
yield* stopSetup(id);
|
|
24441
|
+
const stopped = yield* get2(id);
|
|
24164
24442
|
const { rootPath } = yield* projects.get(worktree.projectId);
|
|
24165
24443
|
const removed = yield* setStatus(id, "removed");
|
|
24166
|
-
const deletion = yield* forkDetach(deleteFiles(rootPath,
|
|
24444
|
+
const deletion = yield* forkDetach(deleteFiles(rootPath, stopped, deleteBranch));
|
|
24167
24445
|
removals.set(removalKey(worktree.projectId, worktree.branch), deletion);
|
|
24168
24446
|
return removed;
|
|
24169
24447
|
});
|
|
24170
24448
|
const remove2 = (id, deleteBranch, owner) => exclusive(removeWhileExclusive(id, deleteBranch, owner));
|
|
24449
|
+
const checkoutOf = (worktree) => gen(function* () {
|
|
24450
|
+
if (!(yield* fs.exists(worktree.path)))
|
|
24451
|
+
return some({ id: worktree.id, state: "missing" });
|
|
24452
|
+
const status = yield* git2.run(worktree.path, ["status", "--porcelain"]);
|
|
24453
|
+
return some({ id: worktree.id, state: status.trim() === "" ? "clean" : "dirty" });
|
|
24454
|
+
}).pipe(orElseSucceed(none));
|
|
24455
|
+
const checkouts = findAll$1(void 0).pipe(
|
|
24456
|
+
mapError(persistence("worktrees.checkouts")),
|
|
24457
|
+
flatMap$1(
|
|
24458
|
+
(all2) => forEach$1(
|
|
24459
|
+
all2.filter((worktree) => worktree.status !== "removed"),
|
|
24460
|
+
checkoutOf,
|
|
24461
|
+
{ concurrency: 8 }
|
|
24462
|
+
)
|
|
24463
|
+
),
|
|
24464
|
+
map$3((states) => states.flatMap(toArray))
|
|
24465
|
+
);
|
|
24171
24466
|
const changes = (id) => gen(function* () {
|
|
24172
24467
|
const worktree = yield* get2(id);
|
|
24173
24468
|
if (worktree.status === "removed") return null;
|
|
@@ -24217,6 +24512,7 @@ Setup script exited with code ${exitCode}
|
|
|
24217
24512
|
);
|
|
24218
24513
|
return Worktrees.of({
|
|
24219
24514
|
list: findAll$1(void 0).pipe(mapError(persistence("worktrees.list"))),
|
|
24515
|
+
checkouts,
|
|
24220
24516
|
get: get2,
|
|
24221
24517
|
create,
|
|
24222
24518
|
createFromPullRequest,
|
|
@@ -24232,7 +24528,8 @@ Setup script exited with code ${exitCode}
|
|
|
24232
24528
|
defaultBranch,
|
|
24233
24529
|
fetch: fetch2,
|
|
24234
24530
|
renameBranch,
|
|
24235
|
-
whenPrepared
|
|
24531
|
+
whenPrepared,
|
|
24532
|
+
stopSetup
|
|
24236
24533
|
});
|
|
24237
24534
|
});
|
|
24238
24535
|
const layer$s = effect(Worktrees, make$L);
|
|
@@ -26078,12 +26375,12 @@ const fromWebSocket = (acquire, options) => withFiber((fiber) => {
|
|
|
26078
26375
|
}));
|
|
26079
26376
|
}
|
|
26080
26377
|
});
|
|
26081
|
-
const writeAll = (
|
|
26378
|
+
const writeAll = (chunks2) => suspend$2(() => {
|
|
26082
26379
|
const ws = currentWS;
|
|
26083
|
-
if (ws === void 0) return latch.whenOpen(writeAll(
|
|
26380
|
+
if (ws === void 0) return latch.whenOpen(writeAll(chunks2));
|
|
26084
26381
|
try {
|
|
26085
|
-
for (let i = 0; i <
|
|
26086
|
-
ws.send(
|
|
26382
|
+
for (let i = 0; i < chunks2.length; i++) {
|
|
26383
|
+
ws.send(chunks2[i]);
|
|
26087
26384
|
}
|
|
26088
26385
|
return void_$1;
|
|
26089
26386
|
} catch (cause) {
|
|
@@ -38759,7 +39056,7 @@ const make$b = gen(function* () {
|
|
|
38759
39056
|
if (request2 === void 0) return void_$1;
|
|
38760
39057
|
return providers[request2.provider]?.respondApproval(requestId, decision) ?? void_$1;
|
|
38761
39058
|
});
|
|
38762
|
-
const updateThread = (input) => threads.update(input).pipe(tap$
|
|
39059
|
+
const updateThread = (input) => threads.update(input).pipe(tap$2((thread) => push.publish({ type: "thread.updated", thread })));
|
|
38763
39060
|
const exclusive = (threadId) => (effect2) => {
|
|
38764
39061
|
let lock = threadLocks.get(threadId);
|
|
38765
39062
|
if (lock === void 0) threadLocks.set(threadId, lock = makeUnsafe$4(1));
|
|
@@ -38884,7 +39181,10 @@ const make$b = gen(function* () {
|
|
|
38884
39181
|
const run2 = (prompt, attachments) => follow(
|
|
38885
39182
|
unwrap(
|
|
38886
39183
|
gen(function* () {
|
|
38887
|
-
const [mcpServer, { experimental }] = yield* all([
|
|
39184
|
+
const [mcpServer, { experimental, autoCompactTokens }] = yield* all([
|
|
39185
|
+
mcp.connectionFor(thread.id),
|
|
39186
|
+
settings.get
|
|
39187
|
+
]);
|
|
38888
39188
|
if (yield* isDone(stop)) {
|
|
38889
39189
|
return succeed({ type: "turn_failed", message: "Turn interrupted" });
|
|
38890
39190
|
}
|
|
@@ -38896,6 +39196,7 @@ const make$b = gen(function* () {
|
|
|
38896
39196
|
model: thread.model,
|
|
38897
39197
|
effort: thread.effort,
|
|
38898
39198
|
fastMode: thread.fastMode,
|
|
39199
|
+
autoCompactTokens: autoCompactTokens[provider.id],
|
|
38899
39200
|
userSkills: thread.userSkills,
|
|
38900
39201
|
accessMode: thread.accessMode,
|
|
38901
39202
|
resumeSessionId: thread.providerSessionId,
|
|
@@ -39846,10 +40147,11 @@ const CLOSE_AUTH_TIMEOUT = 4004;
|
|
|
39846
40147
|
const CLOSE_MALFORMED_FRAME = 4005;
|
|
39847
40148
|
const CLOSE_SLOW_CONSUMER = 4006;
|
|
39848
40149
|
const isTailscale = (address) => address.startsWith("100.");
|
|
39849
|
-
const
|
|
40150
|
+
const isVirtualBridge = (name) => /^(docker|br-|veth|virbr|cni|flannel|podman|vboxnet|vmnet)/.test(name);
|
|
40151
|
+
const reachableHosts = (bindHost, interfaces = networkInterfaces(), host = hostname()) => {
|
|
39850
40152
|
if (bindHost !== "0.0.0.0" && bindHost !== "::") return [bindHost];
|
|
39851
|
-
const addresses = Object.
|
|
39852
|
-
return append$1([...addresses.filter(isTailscale), ...addresses.filter((a) => !isTailscale(a))],
|
|
40153
|
+
const addresses = Object.entries(interfaces).filter(([name]) => !isVirtualBridge(name)).flatMap(([, nets]) => nets ?? []).filter((net) => net.family === "IPv4" && !net.internal).map((net) => net.address);
|
|
40154
|
+
return append$1([...addresses.filter(isTailscale), ...addresses.filter((a) => !isTailscale(a))], host);
|
|
39853
40155
|
};
|
|
39854
40156
|
class RemoteAccess extends Service$1()("hinacode/RemoteAccess") {
|
|
39855
40157
|
}
|
|
@@ -40083,6 +40385,21 @@ const learnFromPush = (owners, environmentId, event) => {
|
|
|
40083
40385
|
}
|
|
40084
40386
|
}
|
|
40085
40387
|
};
|
|
40388
|
+
const unreachableMessage = ({ host, port }, code, reason) => {
|
|
40389
|
+
switch (code) {
|
|
40390
|
+
case "ECONNREFUSED":
|
|
40391
|
+
return `Nothing is listening on ${host}:${port}. Check that hinacode serve is running there and uses port ${port}.`;
|
|
40392
|
+
case "ETIMEDOUT":
|
|
40393
|
+
case "EHOSTUNREACH":
|
|
40394
|
+
case "ENETUNREACH":
|
|
40395
|
+
return `${host} did not answer. Check that this computer is on the same network or tailnet as it.`;
|
|
40396
|
+
case "ENOTFOUND":
|
|
40397
|
+
case "EAI_AGAIN":
|
|
40398
|
+
return `Could not find ${host}. Use its Tailscale or LAN address instead.`;
|
|
40399
|
+
default:
|
|
40400
|
+
return `Could not reach ${host}:${port}: ${reason}`;
|
|
40401
|
+
}
|
|
40402
|
+
};
|
|
40086
40403
|
class InvalidPairingUrl extends TaggedError()("InvalidPairingUrl", {
|
|
40087
40404
|
message: String$1
|
|
40088
40405
|
}) {
|
|
@@ -40104,6 +40421,7 @@ const PING_INTERVAL = "10 seconds";
|
|
|
40104
40421
|
const SILENCE_LIMIT_MS = 25e3;
|
|
40105
40422
|
const OFFLINE_LIMIT_MS = 6e4;
|
|
40106
40423
|
const STABLE_MS = 6e4;
|
|
40424
|
+
const PREFER_EARLIER_HOST_MS = 1e3;
|
|
40107
40425
|
const reconnectDelay = (attempt) => Math.min(500 * 2 ** attempt, 6e4) * (0.7 + Math.random() * 0.6);
|
|
40108
40426
|
const offline = (name) => ({
|
|
40109
40427
|
error: { tag: "EnvironmentOffline", message: `${name} is offline` }
|
|
@@ -40150,6 +40468,7 @@ const probe = (target) => {
|
|
|
40150
40468
|
const where = `${target.host}:${target.port}`;
|
|
40151
40469
|
return callback$1((resume) => {
|
|
40152
40470
|
let reason = "the connection closed";
|
|
40471
|
+
let errorCode;
|
|
40153
40472
|
const socket = dial(target, target.token, {
|
|
40154
40473
|
onFrame: (frame) => {
|
|
40155
40474
|
if (frame.type !== "ready") return;
|
|
@@ -40157,7 +40476,8 @@ const probe = (target) => {
|
|
|
40157
40476
|
socket.close();
|
|
40158
40477
|
},
|
|
40159
40478
|
onError: (error) => {
|
|
40160
|
-
reason = error.message;
|
|
40479
|
+
reason = error.message || reason;
|
|
40480
|
+
errorCode = "code" in error && typeof error.code === "string" ? error.code : void 0;
|
|
40161
40481
|
},
|
|
40162
40482
|
onClose: (code) => {
|
|
40163
40483
|
if (code === CLOSE_UNAUTHORIZED || code === CLOSE_TOKEN_ROTATED) {
|
|
@@ -40169,7 +40489,7 @@ const probe = (target) => {
|
|
|
40169
40489
|
)
|
|
40170
40490
|
);
|
|
40171
40491
|
}
|
|
40172
|
-
resume(fail$2(new EnvironmentUnreachable({ message:
|
|
40492
|
+
resume(fail$2(new EnvironmentUnreachable({ message: unreachableMessage(target, errorCode, reason) })));
|
|
40173
40493
|
}
|
|
40174
40494
|
});
|
|
40175
40495
|
return sync(() => socket.terminate());
|
|
@@ -40178,12 +40498,45 @@ const probe = (target) => {
|
|
|
40178
40498
|
duration: READY_TIMEOUT_MS,
|
|
40179
40499
|
orElse: () => fail$2(
|
|
40180
40500
|
new EnvironmentUnreachable({
|
|
40181
|
-
message:
|
|
40501
|
+
message: unreachableMessage(target, "ETIMEDOUT", `no answer within ${READY_TIMEOUT_MS / 1e3} seconds`)
|
|
40182
40502
|
})
|
|
40183
40503
|
)
|
|
40184
40504
|
})
|
|
40185
40505
|
);
|
|
40186
40506
|
};
|
|
40507
|
+
const probeHosts = (pairing) => gen(function* () {
|
|
40508
|
+
const answers = [];
|
|
40509
|
+
const graceOver = yield* make$1u();
|
|
40510
|
+
let graceStarted = false;
|
|
40511
|
+
const startGrace = suspend$2(() => {
|
|
40512
|
+
if (graceStarted) return void_$1;
|
|
40513
|
+
graceStarted = true;
|
|
40514
|
+
return forkScoped(
|
|
40515
|
+
sleep(PREFER_EARLIER_HOST_MS).pipe(andThen(succeed$5(graceOver, void 0)))
|
|
40516
|
+
);
|
|
40517
|
+
});
|
|
40518
|
+
const probes = yield* forEach$1(
|
|
40519
|
+
pairing.hosts,
|
|
40520
|
+
(host, index) => forkScoped(
|
|
40521
|
+
probe({ host, port: pairing.port, token: pairing.token }).pipe(
|
|
40522
|
+
tap$2((ready) => {
|
|
40523
|
+
answers[index] = ready;
|
|
40524
|
+
return startGrace;
|
|
40525
|
+
}),
|
|
40526
|
+
result$1
|
|
40527
|
+
)
|
|
40528
|
+
)
|
|
40529
|
+
);
|
|
40530
|
+
const failures = [];
|
|
40531
|
+
for (const fiber of probes) {
|
|
40532
|
+
const outcome = yield* raceFirst(join$1(fiber), _await(graceOver).pipe(as(null)));
|
|
40533
|
+
if (outcome === null || outcome._tag === "Success") break;
|
|
40534
|
+
failures.push(outcome.failure);
|
|
40535
|
+
}
|
|
40536
|
+
const won = answers.findIndex((ready) => ready !== void 0);
|
|
40537
|
+
if (won !== -1) return { host: pairing.hosts[won], ready: answers[won] };
|
|
40538
|
+
return yield* fail$2(failures.find((error) => error._tag === "EnvironmentUnauthorized") ?? failures[0]);
|
|
40539
|
+
}).pipe(scoped);
|
|
40187
40540
|
const send$1 = (live, call2) => {
|
|
40188
40541
|
const key2 = live.dedupesCalls ? call2.key : void 0;
|
|
40189
40542
|
call2.sent = true;
|
|
@@ -40267,7 +40620,7 @@ const make$8 = gen(function* () {
|
|
|
40267
40620
|
const { id, name } = cloud.environment;
|
|
40268
40621
|
const closed = yield* make$1u();
|
|
40269
40622
|
let connectedAt = null;
|
|
40270
|
-
let
|
|
40623
|
+
let otherProtocol = null;
|
|
40271
40624
|
let heardAt = now2();
|
|
40272
40625
|
const heard = () => {
|
|
40273
40626
|
heardAt = now2();
|
|
@@ -40281,10 +40634,11 @@ const make$8 = gen(function* () {
|
|
|
40281
40634
|
switch (frame.type) {
|
|
40282
40635
|
case "ready": {
|
|
40283
40636
|
if (frame.version !== REMOTE_PROTOCOL_VERSION) {
|
|
40284
|
-
|
|
40637
|
+
otherProtocol = frame.version;
|
|
40285
40638
|
return socket.close();
|
|
40286
40639
|
}
|
|
40287
40640
|
connectedAt = now2();
|
|
40641
|
+
cloud.protocol = null;
|
|
40288
40642
|
const live = { socket, dedupesCalls: frame.features?.includes("call-keys") ?? false };
|
|
40289
40643
|
cloud.live = live;
|
|
40290
40644
|
for (const call2 of cloud.outbox.values()) {
|
|
@@ -40346,7 +40700,7 @@ const make$8 = gen(function* () {
|
|
|
40346
40700
|
const code = yield* _await(closed);
|
|
40347
40701
|
return {
|
|
40348
40702
|
code,
|
|
40349
|
-
|
|
40703
|
+
otherProtocol,
|
|
40350
40704
|
connectedMs: connectedAt === null ? 0 : now2() - connectedAt
|
|
40351
40705
|
};
|
|
40352
40706
|
}).pipe(scoped);
|
|
@@ -40361,18 +40715,26 @@ const make$8 = gen(function* () {
|
|
|
40361
40715
|
let attempt = 0;
|
|
40362
40716
|
for (; ; ) {
|
|
40363
40717
|
const end2 = yield* session(cloud, token);
|
|
40364
|
-
if (end2.incompatible) {
|
|
40365
|
-
failAll(cloud, incompatible(name));
|
|
40366
|
-
return yield* setStatus(cloud, "incompatible");
|
|
40367
|
-
}
|
|
40368
40718
|
if (end2.code === CLOSE_UNAUTHORIZED || end2.code === CLOSE_TOKEN_ROTATED) {
|
|
40369
40719
|
failAll(cloud, unauthorized(name));
|
|
40370
40720
|
return yield* setStatus(cloud, "unauthorized");
|
|
40371
40721
|
}
|
|
40372
|
-
|
|
40722
|
+
if (end2.otherProtocol === null) {
|
|
40723
|
+
yield* setStatus(cloud, "offline");
|
|
40724
|
+
} else {
|
|
40725
|
+
cloud.protocol = end2.otherProtocol;
|
|
40726
|
+
failAll(cloud, incompatible(name));
|
|
40727
|
+
yield* setStatus(cloud, "incompatible");
|
|
40728
|
+
}
|
|
40373
40729
|
if (end2.connectedMs >= STABLE_MS) attempt = 0;
|
|
40374
|
-
yield*
|
|
40375
|
-
|
|
40730
|
+
const wake = yield* make$1u();
|
|
40731
|
+
cloud.wake = wake;
|
|
40732
|
+
const woken = yield* race(
|
|
40733
|
+
sleep(reconnectDelay(attempt)).pipe(as(false)),
|
|
40734
|
+
_await(wake).pipe(as(true))
|
|
40735
|
+
);
|
|
40736
|
+
cloud.wake = null;
|
|
40737
|
+
attempt = woken ? 0 : attempt + 1;
|
|
40376
40738
|
}
|
|
40377
40739
|
}).pipe(catchCause$1((cause) => logWarning("environment connection stopped", cause)));
|
|
40378
40740
|
const connections = yield* make$15();
|
|
@@ -40391,7 +40753,9 @@ const make$8 = gen(function* () {
|
|
|
40391
40753
|
environment,
|
|
40392
40754
|
status: "connecting",
|
|
40393
40755
|
lastSeenAt: null,
|
|
40756
|
+
protocol: null,
|
|
40394
40757
|
live: null,
|
|
40758
|
+
wake: null,
|
|
40395
40759
|
outbox: /* @__PURE__ */ new Map(),
|
|
40396
40760
|
remembered: /* @__PURE__ */ new Map()
|
|
40397
40761
|
};
|
|
@@ -40404,7 +40768,8 @@ const make$8 = gen(function* () {
|
|
|
40404
40768
|
return {
|
|
40405
40769
|
clouds: rows.map((row) => {
|
|
40406
40770
|
const cloud = clouds.get(row.id);
|
|
40407
|
-
|
|
40771
|
+
const entry = { ...row, status: cloud?.status ?? "offline", lastSeenAt: cloud?.lastSeenAt ?? null };
|
|
40772
|
+
return cloud?.status === "incompatible" && cloud.protocol !== null ? { ...entry, protocol: cloud.protocol } : entry;
|
|
40408
40773
|
})
|
|
40409
40774
|
};
|
|
40410
40775
|
});
|
|
@@ -40415,8 +40780,8 @@ const make$8 = gen(function* () {
|
|
|
40415
40780
|
message: "Paste the hinacode://connect URL that hinacode serve printed."
|
|
40416
40781
|
});
|
|
40417
40782
|
}
|
|
40418
|
-
const
|
|
40419
|
-
const
|
|
40783
|
+
const { host, ready } = yield* probeHosts(pairing);
|
|
40784
|
+
const target = { host, port: pairing.port, token: pairing.token };
|
|
40420
40785
|
if (ready.environment?.id === self.id) {
|
|
40421
40786
|
return yield* new InvalidPairingUrl({ message: "That pairing URL is for this desktop." });
|
|
40422
40787
|
}
|
|
@@ -40448,6 +40813,14 @@ const make$8 = gen(function* () {
|
|
|
40448
40813
|
clouds.delete(id);
|
|
40449
40814
|
owners.forget(id);
|
|
40450
40815
|
});
|
|
40816
|
+
const reconnect = (id) => suspend$2(() => {
|
|
40817
|
+
const cloud = clouds.get(id);
|
|
40818
|
+
const wake = cloud?.wake;
|
|
40819
|
+
if (cloud === void 0 || wake == null) return void_$1;
|
|
40820
|
+
cloud.wake = null;
|
|
40821
|
+
return setStatus(cloud, "connecting").pipe(andThen(succeed$5(wake, void 0)));
|
|
40822
|
+
});
|
|
40823
|
+
const reconnectAll = suspend$2(() => forEach$1([...clouds.keys()], reconnect, { discard: true }));
|
|
40451
40824
|
const forward = (environmentId, { method, payload }) => suspend$2(() => {
|
|
40452
40825
|
const cloud = clouds.get(environmentId);
|
|
40453
40826
|
if (cloud === void 0) return succeed$3(unknownEnvironment(environmentId));
|
|
@@ -40498,7 +40871,7 @@ const make$8 = gen(function* () {
|
|
|
40498
40871
|
{ concurrency: "unbounded" }
|
|
40499
40872
|
).pipe(map$3((answers) => answers.flat()));
|
|
40500
40873
|
yield* forEach$1(yield* findAll$1(void 0).pipe(mapError(persistence("environments.load"))), start);
|
|
40501
|
-
return Environments.of({ list, add: add2, remove: remove2, forward, gather, owner: owners.owner });
|
|
40874
|
+
return Environments.of({ list, add: add2, remove: remove2, reconnect, reconnectAll, forward, gather, owner: owners.owner });
|
|
40502
40875
|
});
|
|
40503
40876
|
const layer$8 = effect(Environments, make$8);
|
|
40504
40877
|
const previewMimes = {
|
|
@@ -40826,18 +41199,18 @@ const get = async (url, deadline) => {
|
|
|
40826
41199
|
return null;
|
|
40827
41200
|
};
|
|
40828
41201
|
const readUpTo = async (response, limit) => {
|
|
40829
|
-
const
|
|
41202
|
+
const chunks2 = [];
|
|
40830
41203
|
let size2 = 0;
|
|
40831
41204
|
const reader = response.body?.getReader();
|
|
40832
41205
|
if (!reader) return { bytes: Buffer.alloc(0), truncated: false };
|
|
40833
41206
|
while (size2 <= limit) {
|
|
40834
41207
|
const { done: done2, value: value2 } = await reader.read();
|
|
40835
41208
|
if (done2) break;
|
|
40836
|
-
|
|
41209
|
+
chunks2.push(value2);
|
|
40837
41210
|
size2 += value2.byteLength;
|
|
40838
41211
|
}
|
|
40839
41212
|
await reader.cancel();
|
|
40840
|
-
return { bytes: Buffer.concat(
|
|
41213
|
+
return { bytes: Buffer.concat(chunks2).subarray(0, limit), truncated: size2 > limit };
|
|
40841
41214
|
};
|
|
40842
41215
|
const attribute = (tag2, name) => new RegExp(`\\s${name}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))`, "i").exec(tag2)?.slice(1).find((value2) => value2 !== void 0);
|
|
40843
41216
|
const ICON_RELS = /* @__PURE__ */ new Set(["icon", "apple-touch-icon"]);
|
|
@@ -41377,7 +41750,7 @@ const make$5 = gen(function* () {
|
|
|
41377
41750
|
launch(server).pipe(
|
|
41378
41751
|
catchCause$1((cause) => {
|
|
41379
41752
|
listenError = describeCause$1(cause);
|
|
41380
|
-
return logWarning("automation webhook listener failed",
|
|
41753
|
+
return logWarning("automation webhook listener failed", listenError);
|
|
41381
41754
|
})
|
|
41382
41755
|
)
|
|
41383
41756
|
);
|
|
@@ -42013,7 +42386,7 @@ const startForward = (openTunnel) => callback$1((resume) => {
|
|
|
42013
42386
|
track(local);
|
|
42014
42387
|
runFork(
|
|
42015
42388
|
openTunnel().pipe(
|
|
42016
|
-
tap$
|
|
42389
|
+
tap$2(
|
|
42017
42390
|
({ socket, head }) => sync(() => {
|
|
42018
42391
|
track(socket);
|
|
42019
42392
|
if (local.destroyed) {
|
|
@@ -42400,7 +42773,7 @@ const makeRelayCore = (deps) => gen(function* () {
|
|
|
42400
42773
|
duration: "180 seconds",
|
|
42401
42774
|
orElse: () => as(deps.cancelCeremony, notAllowed("No answer came from this Mac in time"))
|
|
42402
42775
|
}),
|
|
42403
|
-
tap$
|
|
42776
|
+
tap$2((outcome) => logInfo("tiny vm passkey: ceremony finished", validated.rpId, outcome.type)),
|
|
42404
42777
|
flatMap$1((outcome) => finishCeremony(session, request2, outcome))
|
|
42405
42778
|
);
|
|
42406
42779
|
pending.fiber = yield* forkIn(ceremony, scope$12);
|
|
@@ -42631,7 +43004,9 @@ const handlers = {
|
|
|
42631
43004
|
"worktrees.list": () => Worktrees.use((worktrees) => worktrees.list),
|
|
42632
43005
|
"worktrees.create": (input) => Worktrees.use((worktrees) => worktrees.create(input)),
|
|
42633
43006
|
"worktrees.remove": ({ id, deleteBranch }) => Worktrees.use((worktrees) => worktrees.remove(id, deleteBranch)),
|
|
43007
|
+
"worktrees.checkouts": () => Worktrees.use((worktrees) => worktrees.checkouts),
|
|
42634
43008
|
"worktrees.setupLog": ({ id }) => Worktrees.use((worktrees) => map$3(worktrees.get(id), (w) => w.setupLog)),
|
|
43009
|
+
"worktrees.stopSetup": ({ id }) => Worktrees.use((worktrees) => worktrees.stopSetup(id)),
|
|
42635
43010
|
"worktrees.pullRequest": ({ id }) => Worktrees.use((worktrees) => worktrees.pullRequest(id)),
|
|
42636
43011
|
"threads.changes": ({ threadId, scope: scope2 }) => Threads.use((threads) => threads.changes(threadId, scope2)),
|
|
42637
43012
|
"threads.archive": ({ threadId }) => Threads.use((threads) => threads.archive(threadId)),
|
|
@@ -42649,6 +43024,17 @@ const handlers = {
|
|
|
42649
43024
|
GitHubSignedOutError: () => succeed$3([])
|
|
42650
43025
|
})
|
|
42651
43026
|
),
|
|
43027
|
+
"projects.searchPullRequests": ({ id, query: query2 }) => gen(function* () {
|
|
43028
|
+
const { rootPath } = yield* Projects.use((projects) => projects.get(id));
|
|
43029
|
+
const repository = yield* GitHub.use((github) => github.repository(rootPath));
|
|
43030
|
+
if (repository === null) return [];
|
|
43031
|
+
return yield* GitHub.use((github) => github.searchPullRequests(repository, query2));
|
|
43032
|
+
}).pipe(
|
|
43033
|
+
catchTags({
|
|
43034
|
+
GitHubCliMissingError: () => succeed$3([]),
|
|
43035
|
+
GitHubSignedOutError: () => succeed$3([])
|
|
43036
|
+
})
|
|
43037
|
+
),
|
|
42652
43038
|
"projects.icon": ({ id }) => Projects.use((projects) => projects.icon(id)),
|
|
42653
43039
|
"git.log": ({ root, limit = 200 }) => knownRoot(root).pipe(andThen(Git.use((git2) => git2.log(root, limit)))),
|
|
42654
43040
|
"git.show": ({ root, hash: hash2 }) => knownRoot(root).pipe(andThen(Git.use((git2) => git2.show(root, hash2)))),
|
|
@@ -42662,6 +43048,7 @@ const handlers = {
|
|
|
42662
43048
|
"environments.list": () => Environments.use((environments2) => environments2.list),
|
|
42663
43049
|
"environments.add": (input) => Environments.use((environments2) => environments2.add(input)),
|
|
42664
43050
|
"environments.remove": ({ id }) => Environments.use((environments2) => environments2.remove(id)),
|
|
43051
|
+
"environments.reconnect": ({ id }) => Environments.use((environments2) => environments2.reconnect(id)),
|
|
42665
43052
|
"notifications.permission": (_, desktop) => desktop?.notificationPermission ?? succeed$3("unknown"),
|
|
42666
43053
|
"notifications.askPermission": ({ title, body: body2 }, desktop) => desktop?.askNotificationPermission(title, body2) ?? succeed$3("noAnswer"),
|
|
42667
43054
|
"models.list": ({ provider }) => AgentRunner.use((runner) => runner.listModels(provider)),
|
|
@@ -42958,9 +43345,10 @@ const make$2 = gen(function* () {
|
|
|
42958
43345
|
yield* run$2(
|
|
42959
43346
|
listener,
|
|
42960
43347
|
listen(remote).pipe(
|
|
42961
|
-
catchCause$1(
|
|
42962
|
-
|
|
42963
|
-
|
|
43348
|
+
catchCause$1((cause) => {
|
|
43349
|
+
const listenError = describeCause(cause);
|
|
43350
|
+
return access2.report({ listenError }).pipe(andThen(logWarning("remote listener failed", listenError)));
|
|
43351
|
+
})
|
|
42964
43352
|
)
|
|
42965
43353
|
);
|
|
42966
43354
|
});
|
|
@@ -42982,6 +43370,49 @@ const make$2 = gen(function* () {
|
|
|
42982
43370
|
);
|
|
42983
43371
|
});
|
|
42984
43372
|
const layer$2 = effectDiscard(make$2);
|
|
43373
|
+
const USAGE = `Usage: hinacode <command> [options]
|
|
43374
|
+
|
|
43375
|
+
Commands:
|
|
43376
|
+
serve Run a HinaCode cloud: agents, worktrees and threads on this machine, driven from the desktop or phone app.
|
|
43377
|
+
pair Print the pairing URLs and QR code of the cloud again, without restarting it.
|
|
43378
|
+
|
|
43379
|
+
serve options:
|
|
43380
|
+
--port <n> Port to listen on, or HINACODE_SERVE_PORT.
|
|
43381
|
+
--host <host> Address to bind, or HINACODE_SERVE_HOST. 0.0.0.0 for every interface.
|
|
43382
|
+
--rotate-token Replace the token, which unpairs every client, or HINACODE_SERVE_ROTATE_TOKEN=1.
|
|
43383
|
+
|
|
43384
|
+
-h, --help Print this help.
|
|
43385
|
+
--version Print the version.
|
|
43386
|
+
|
|
43387
|
+
A cloud installed with npm install -g installs new releases on its own once nothing is running.
|
|
43388
|
+
Set HINACODE_SERVE_AUTO_UPDATE=0 to update it by hand instead.
|
|
43389
|
+
|
|
43390
|
+
Data lives in HINACODE_USER_DATA, default ~/.hinacode-cloud.`;
|
|
43391
|
+
class UsageError extends Error {
|
|
43392
|
+
}
|
|
43393
|
+
const OPTIONS = {
|
|
43394
|
+
serve: { values: ["--port", "--host"], switches: ["--rotate-token"] },
|
|
43395
|
+
pair: { values: [], switches: [] }
|
|
43396
|
+
};
|
|
43397
|
+
const parseCommand = (argv) => {
|
|
43398
|
+
if (argv.includes("--help") || argv.includes("-h")) return "help";
|
|
43399
|
+
const [command, ...rest] = argv;
|
|
43400
|
+
if (command === "--version") return "version";
|
|
43401
|
+
if (command !== "serve" && command !== "pair") {
|
|
43402
|
+
throw new UsageError(command === void 0 ? "missing command" : `unknown command ${command}`);
|
|
43403
|
+
}
|
|
43404
|
+
const { values: values2, switches } = OPTIONS[command];
|
|
43405
|
+
for (let index = 0; index < rest.length; index++) {
|
|
43406
|
+
const arg = rest[index];
|
|
43407
|
+
const name = arg.split("=")[0];
|
|
43408
|
+
if (values2.includes(name)) {
|
|
43409
|
+
if (name === arg) index++;
|
|
43410
|
+
} else if (!switches.includes(arg)) {
|
|
43411
|
+
throw new UsageError(arg.startsWith("-") ? `unknown option ${name}` : `unexpected argument ${arg}`);
|
|
43412
|
+
}
|
|
43413
|
+
}
|
|
43414
|
+
return command;
|
|
43415
|
+
};
|
|
42985
43416
|
const envFlag = (env, name) => {
|
|
42986
43417
|
const value2 = env[name];
|
|
42987
43418
|
if (value2 === void 0 || value2 === "0" || value2 === "false") return false;
|
|
@@ -42995,6 +43426,15 @@ const portOf = (raw2, source) => {
|
|
|
42995
43426
|
}
|
|
42996
43427
|
return port;
|
|
42997
43428
|
};
|
|
43429
|
+
const restartCommand = (process2) => {
|
|
43430
|
+
const { HINACODE_SERVE_ROTATE_TOKEN: _rotated, ...env } = process2.env;
|
|
43431
|
+
return {
|
|
43432
|
+
file: process2.execPath,
|
|
43433
|
+
args: [process2.execPath, ...process2.execArgv, ...process2.argv.slice(1).filter((arg) => arg !== "--rotate-token")],
|
|
43434
|
+
env
|
|
43435
|
+
};
|
|
43436
|
+
};
|
|
43437
|
+
const autoUpdate = (env) => env["HINACODE_SERVE_AUTO_UPDATE"] === void 0 || envFlag(env, "HINACODE_SERVE_AUTO_UPDATE");
|
|
42998
43438
|
const flagValue = (argv, name) => {
|
|
42999
43439
|
const inline = argv.find((arg) => arg.startsWith(`--${name}=`));
|
|
43000
43440
|
if (inline !== void 0) return inline.slice(name.length + 3);
|
|
@@ -43245,13 +43685,13 @@ const layer = effect(PullRequestWatcher, make2);
|
|
|
43245
43685
|
const simulatedClaude = (env) => {
|
|
43246
43686
|
const mode = env["HINACODE_MOCK_CLAUDE"];
|
|
43247
43687
|
if (mode === void 0) return void 0;
|
|
43248
|
-
|
|
43249
|
-
|
|
43688
|
+
const scenario = mockScenarios.find((candidate) => candidate === mode);
|
|
43689
|
+
if (scenario === void 0) throw new Error(`HINACODE_MOCK_CLAUDE must be one of ${mockScenarios.join(", ")}`);
|
|
43250
43690
|
if (!env["HINACODE_USER_DATA"]) throw new Error("Claude simulation requires HINACODE_USER_DATA");
|
|
43251
43691
|
const resetMs = Number(env["HINACODE_MOCK_RESET_MS"] ?? 6e4);
|
|
43252
43692
|
if (!Number.isFinite(resetMs) || Math.abs(resetMs) > 36e5)
|
|
43253
43693
|
throw new Error("HINACODE_MOCK_RESET_MS must be between -3600000 and 3600000");
|
|
43254
|
-
return usageLimitLayer(
|
|
43694
|
+
return usageLimitLayer(scenario, resetMs);
|
|
43255
43695
|
};
|
|
43256
43696
|
const makeAppLayer = ({ userData, sbxConfigPath, keyring, updates, toWindows, serve: serve2 }) => {
|
|
43257
43697
|
const mockClaude = simulatedClaude(process.env);
|
|
@@ -43323,65 +43763,91 @@ const hydratePath = async (env) => {
|
|
|
43323
43763
|
env.PATH = [...new Set(entries)].join(":");
|
|
43324
43764
|
};
|
|
43325
43765
|
export {
|
|
43326
|
-
|
|
43327
|
-
|
|
43328
|
-
|
|
43329
|
-
|
|
43330
|
-
|
|
43331
|
-
|
|
43332
|
-
|
|
43333
|
-
|
|
43334
|
-
|
|
43335
|
-
|
|
43336
|
-
|
|
43337
|
-
|
|
43338
|
-
|
|
43339
|
-
|
|
43340
|
-
|
|
43341
|
-
|
|
43342
|
-
|
|
43343
|
-
|
|
43766
|
+
seconds as $,
|
|
43767
|
+
make$14 as A,
|
|
43768
|
+
makeAppLayer as B,
|
|
43769
|
+
autoUpdate as C,
|
|
43770
|
+
layer$b as D,
|
|
43771
|
+
Events as E,
|
|
43772
|
+
provideMerge as F,
|
|
43773
|
+
mergeAll$1 as G,
|
|
43774
|
+
layer$p as H,
|
|
43775
|
+
layer$w as I,
|
|
43776
|
+
provide$3 as J,
|
|
43777
|
+
noKeyring as K,
|
|
43778
|
+
layer$z as L,
|
|
43779
|
+
succeed$4 as M,
|
|
43780
|
+
MinimumLogLevel as N,
|
|
43781
|
+
Settings as O,
|
|
43782
|
+
pairingUrl as P,
|
|
43783
|
+
isPortInUse as Q,
|
|
43344
43784
|
RemoteAccess as R,
|
|
43345
|
-
|
|
43346
|
-
|
|
43785
|
+
Struct as S,
|
|
43786
|
+
Threads as T,
|
|
43347
43787
|
Updates as U,
|
|
43348
|
-
|
|
43349
|
-
|
|
43350
|
-
|
|
43351
|
-
|
|
43352
|
-
|
|
43353
|
-
|
|
43354
|
-
|
|
43355
|
-
|
|
43356
|
-
|
|
43357
|
-
|
|
43358
|
-
|
|
43359
|
-
|
|
43360
|
-
|
|
43361
|
-
|
|
43362
|
-
|
|
43363
|
-
|
|
43364
|
-
|
|
43365
|
-
|
|
43366
|
-
|
|
43367
|
-
|
|
43368
|
-
|
|
43369
|
-
|
|
43370
|
-
|
|
43371
|
-
|
|
43372
|
-
|
|
43373
|
-
|
|
43374
|
-
|
|
43375
|
-
|
|
43376
|
-
|
|
43377
|
-
|
|
43378
|
-
|
|
43379
|
-
|
|
43380
|
-
|
|
43788
|
+
restartCommand as V,
|
|
43789
|
+
Worktrees as W,
|
|
43790
|
+
catchDefect as X,
|
|
43791
|
+
succeed$3 as Y,
|
|
43792
|
+
callback$1 as Z,
|
|
43793
|
+
timeoutOrElse as _,
|
|
43794
|
+
spaced as a,
|
|
43795
|
+
TaggedError as a0,
|
|
43796
|
+
promise as a1,
|
|
43797
|
+
optional$6 as a2,
|
|
43798
|
+
RpcCall as a3,
|
|
43799
|
+
decodeUnknownOption as a4,
|
|
43800
|
+
EVENT_CHANNEL as a5,
|
|
43801
|
+
RPC_CHANNEL as a6,
|
|
43802
|
+
isTrustedSender as a7,
|
|
43803
|
+
getOrUndefined$1 as a8,
|
|
43804
|
+
dispatch as a9,
|
|
43805
|
+
Environments as aa,
|
|
43806
|
+
catch_$2 as ab,
|
|
43807
|
+
all as ac,
|
|
43808
|
+
map$3 as ad,
|
|
43809
|
+
decodeUnknownEffect as ae,
|
|
43810
|
+
RpcMethods as af,
|
|
43811
|
+
inlineSource as ag,
|
|
43812
|
+
runFork as ah,
|
|
43813
|
+
logWarning as ai,
|
|
43814
|
+
ignore$1 as aj,
|
|
43815
|
+
ATTACHMENT_PROTOCOL as ak,
|
|
43816
|
+
GITHUB_ASSET_PROTOCOL as al,
|
|
43817
|
+
PROJECT_FILE_PROTOCOL as am,
|
|
43818
|
+
Keyring as an,
|
|
43819
|
+
isInside as ao,
|
|
43820
|
+
githubAssetId as ap,
|
|
43821
|
+
GitHub as aq,
|
|
43822
|
+
externalUrl as ar,
|
|
43823
|
+
projectFileRequest as as,
|
|
43824
|
+
Files as at,
|
|
43825
|
+
BROWSER_PARTITION as au,
|
|
43826
|
+
lockDownWebview as av,
|
|
43827
|
+
isAllowedNavigation as aw,
|
|
43828
|
+
Terminals as b,
|
|
43829
|
+
forEach$1 as c,
|
|
43830
|
+
decodeUnknownSync as d,
|
|
43831
|
+
effect as e,
|
|
43832
|
+
forkScoped as f,
|
|
43833
|
+
gen as g,
|
|
43834
|
+
sync as h,
|
|
43835
|
+
isThreadBusy as i,
|
|
43836
|
+
String$1 as j,
|
|
43837
|
+
andThen as k,
|
|
43838
|
+
matchEffect as l,
|
|
43839
|
+
make$1c as m,
|
|
43840
|
+
forkDetach as n,
|
|
43841
|
+
orElseSucceed as o,
|
|
43842
|
+
flatMap$1 as p,
|
|
43843
|
+
UsageError as q,
|
|
43844
|
+
repeat as r,
|
|
43845
|
+
suspend$2 as s,
|
|
43846
|
+
tryPromise as t,
|
|
43381
43847
|
unsupported as u,
|
|
43382
43848
|
void_$1 as v,
|
|
43383
|
-
|
|
43384
|
-
|
|
43385
|
-
|
|
43386
|
-
|
|
43849
|
+
USAGE as w,
|
|
43850
|
+
parseCommand as x,
|
|
43851
|
+
serveConfig as y,
|
|
43852
|
+
hydratePath as z
|
|
43387
43853
|
};
|