@p4code/cli 0.2.22 → 0.2.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.mjs +1387 -658
- package/dist/client/assets/DiffPanel-De-w8hOu.js +98 -0
- package/dist/client/assets/{FilePreviewPanel-D5bhmoRv.js → FilePreviewPanel-BFLGOpey.js} +14 -14
- package/dist/client/assets/PreviewPanel-DPou_ItV.js +2 -0
- package/dist/client/assets/PullRequestCodeTab-CQumjJMI.js +251 -0
- package/dist/client/assets/arrow-right-CW83eQ9E.js +2 -0
- package/dist/client/assets/{fileCommentAnnotations-ykJSseAb.js → fileCommentAnnotations-CS8p2mt-.js} +2 -2
- package/dist/client/assets/index-CbyMk5N4.css +1 -0
- package/dist/client/assets/index-Cv8L2Qdc.js +2495 -0
- package/dist/client/assets/previewAssetResource-kDlikuCq.js +48 -0
- package/dist/client/assets/{renderFileChildren-BzvRnJFx.js → renderFileChildren-KFCpWGdA.js} +2 -2
- package/dist/client/assets/{toggle-group-CtVhHB94.js → toggle-group-BZWAwN3D.js} +2 -2
- package/dist/client/index.html +3 -3
- package/package.json +1 -1
- package/dist/client/assets/DiffPanel-ClzdFUS1.js +0 -98
- package/dist/client/assets/PreviewPanel-DR6nPMIL.js +0 -2
- package/dist/client/assets/PullRequestCodeTab-C-WmxVSc.js +0 -251
- package/dist/client/assets/arrow-right-DQUNvhnY.js +0 -2
- package/dist/client/assets/index-CKTw6SgQ.js +0 -2478
- package/dist/client/assets/index-CQ1glo_i.css +0 -1
- package/dist/client/assets/previewAssetResource-mc-rcVvk.js +0 -47
package/dist/bin.mjs
CHANGED
|
@@ -126,7 +126,7 @@ const closeServer = (server) => {
|
|
|
126
126
|
* NetService - Service tag for startup networking helpers.
|
|
127
127
|
*/
|
|
128
128
|
var NetService = class extends Context.Service()("@p4code/shared/Net/NetService") {};
|
|
129
|
-
const make$
|
|
129
|
+
const make$90 = () => {
|
|
130
130
|
/**
|
|
131
131
|
* Returns true when a TCP server can bind to {host, port}.
|
|
132
132
|
* `EADDRNOTAVAIL` is treated as available so IPv6-absent hosts don't fail
|
|
@@ -235,10 +235,10 @@ const make$89 = () => {
|
|
|
235
235
|
})
|
|
236
236
|
};
|
|
237
237
|
};
|
|
238
|
-
const layer$
|
|
238
|
+
const layer$81 = Layer.sync(NetService, make$90);
|
|
239
239
|
//#endregion
|
|
240
240
|
//#region package.json
|
|
241
|
-
var version = "0.2.
|
|
241
|
+
var version = "0.2.24";
|
|
242
242
|
//#endregion
|
|
243
243
|
//#region src/config.ts
|
|
244
244
|
/**
|
|
@@ -259,8 +259,8 @@ var ServerConfig$1 = class extends Context.Service()("@p4code/cli/config/ServerC
|
|
|
259
259
|
/** @deprecated Import and use `layerTest` from this module. */
|
|
260
260
|
static layerTest = (cwd, baseDirOrPrefix) => layerTest$3(cwd, baseDirOrPrefix);
|
|
261
261
|
};
|
|
262
|
-
const make$
|
|
263
|
-
const layer$
|
|
262
|
+
const make$89 = (config) => ServerConfig$1.of(config);
|
|
263
|
+
const layer$80 = (config) => Layer.succeed(ServerConfig$1, make$89(config));
|
|
264
264
|
const deriveServerPaths = Effect.fn(function* (baseDir, devUrl, options = {}) {
|
|
265
265
|
const { join } = yield* Path.Path;
|
|
266
266
|
const stateDir = join(baseDir, devUrl !== void 0 && !options.baseDirIsExplicit ? "dev" : "userdata");
|
|
@@ -1329,6 +1329,9 @@ const ExecutionEnvironmentCapabilities = Schema$1.Struct({
|
|
|
1329
1329
|
/** Server understands thread.snooze / thread.unsnooze commands. Same
|
|
1330
1330
|
version-skew contract as threadSettlement. */
|
|
1331
1331
|
threadSnooze: Schema$1.optionalKey(Schema$1.Boolean),
|
|
1332
|
+
/** Server understands thread.pin / thread.unpin / thread.pin.reorder
|
|
1333
|
+
commands. Same version-skew contract as threadSettlement. */
|
|
1334
|
+
threadPinning: Schema$1.optionalKey(Schema$1.Boolean),
|
|
1332
1335
|
/** Server exposes the pull-request list, detail, activity, diff, and mutation APIs. Absent on
|
|
1333
1336
|
servers from before the pull-request workspace shipped, so clients must not probe them. */
|
|
1334
1337
|
pullRequests: Schema$1.optionalKey(Schema$1.Boolean),
|
|
@@ -1961,6 +1964,8 @@ const OrchestrationThread = Schema$1.Struct({
|
|
|
1961
1964
|
settledAt: Schema$1.NullOr(IsoDateTime).pipe(Schema$1.withDecodingDefault(Effect.succeed(null))),
|
|
1962
1965
|
snoozedUntil: Schema$1.optional(Schema$1.NullOr(IsoDateTime)),
|
|
1963
1966
|
snoozedAt: Schema$1.optional(Schema$1.NullOr(IsoDateTime)),
|
|
1967
|
+
pinnedAt: Schema$1.optional(Schema$1.NullOr(IsoDateTime)),
|
|
1968
|
+
pinOrderKey: Schema$1.optional(Schema$1.NullOr(Schema$1.String)),
|
|
1964
1969
|
deletedAt: Schema$1.NullOr(IsoDateTime),
|
|
1965
1970
|
messages: Schema$1.Array(OrchestrationMessage),
|
|
1966
1971
|
proposedPlans: Schema$1.Array(OrchestrationProposedPlan).pipe(Schema$1.withDecodingDefault(Effect.succeed([]))),
|
|
@@ -2058,11 +2063,19 @@ const OrchestrationThreadShell = Schema$1.Struct({
|
|
|
2058
2063
|
settledAt: Schema$1.NullOr(IsoDateTime).pipe(Schema$1.withDecodingDefault(Effect.succeed(null))),
|
|
2059
2064
|
snoozedUntil: Schema$1.optional(Schema$1.NullOr(IsoDateTime)),
|
|
2060
2065
|
snoozedAt: Schema$1.optional(Schema$1.NullOr(IsoDateTime)),
|
|
2066
|
+
pinnedAt: Schema$1.optional(Schema$1.NullOr(IsoDateTime)),
|
|
2067
|
+
pinOrderKey: Schema$1.optional(Schema$1.NullOr(Schema$1.String)),
|
|
2061
2068
|
session: Schema$1.NullOr(OrchestrationSession),
|
|
2062
2069
|
latestUserMessageAt: Schema$1.NullOr(IsoDateTime),
|
|
2063
2070
|
hasPendingApprovals: Schema$1.Boolean,
|
|
2064
2071
|
hasPendingUserInput: Schema$1.Boolean,
|
|
2065
2072
|
hasActionableProposedPlan: Schema$1.Boolean,
|
|
2073
|
+
/**
|
|
2074
|
+
* Native background work alive after the turn settles: "working" while
|
|
2075
|
+
* subagents/workflows run, "monitoring" when watch loops are the only
|
|
2076
|
+
* live work. Optional so old servers/clients interop; absent = none.
|
|
2077
|
+
*/
|
|
2078
|
+
backgroundLiveness: Schema$1.optional(Schema$1.NullOr(Schema$1.Literals(["working", "monitoring"]))),
|
|
2066
2079
|
hasBackgroundTasks: Schema$1.optional(Schema$1.Boolean),
|
|
2067
2080
|
scheduledWakeAt: Schema$1.optional(Schema$1.NullOr(IsoDateTime))
|
|
2068
2081
|
});
|
|
@@ -2227,6 +2240,23 @@ const ThreadUnsnoozeCommand = Schema$1.Struct({
|
|
|
2227
2240
|
threadId: ThreadId,
|
|
2228
2241
|
reason: Schema$1.Literal("user")
|
|
2229
2242
|
});
|
|
2243
|
+
const ThreadPinCommand = Schema$1.Struct({
|
|
2244
|
+
type: Schema$1.Literal("thread.pin"),
|
|
2245
|
+
commandId: CommandId,
|
|
2246
|
+
threadId: ThreadId
|
|
2247
|
+
});
|
|
2248
|
+
const ThreadUnpinCommand = Schema$1.Struct({
|
|
2249
|
+
type: Schema$1.Literal("thread.unpin"),
|
|
2250
|
+
commandId: CommandId,
|
|
2251
|
+
threadId: ThreadId
|
|
2252
|
+
});
|
|
2253
|
+
/** Writes one key to one thread, so neighbours on other servers stay untouched. */
|
|
2254
|
+
const ThreadPinReorderCommand = Schema$1.Struct({
|
|
2255
|
+
type: Schema$1.Literal("thread.pin.reorder"),
|
|
2256
|
+
commandId: CommandId,
|
|
2257
|
+
threadId: ThreadId,
|
|
2258
|
+
pinOrderKey: Schema$1.NullOr(Schema$1.String)
|
|
2259
|
+
});
|
|
2230
2260
|
const ThreadMetaUpdateCommand = Schema$1.Struct({
|
|
2231
2261
|
type: Schema$1.Literal("thread.meta.update"),
|
|
2232
2262
|
commandId: CommandId,
|
|
@@ -2411,6 +2441,9 @@ const DispatchableClientOrchestrationCommand = Schema$1.Union([
|
|
|
2411
2441
|
ThreadUnsettleCommand,
|
|
2412
2442
|
ThreadSnoozeCommand,
|
|
2413
2443
|
ThreadUnsnoozeCommand,
|
|
2444
|
+
ThreadPinCommand,
|
|
2445
|
+
ThreadUnpinCommand,
|
|
2446
|
+
ThreadPinReorderCommand,
|
|
2414
2447
|
ThreadMetaUpdateCommand,
|
|
2415
2448
|
ThreadRuntimeModeSetCommand,
|
|
2416
2449
|
ThreadInteractionModeSetCommand,
|
|
@@ -2438,6 +2471,9 @@ const ClientOrchestrationCommand = Schema$1.Union([
|
|
|
2438
2471
|
ThreadUnsettleCommand,
|
|
2439
2472
|
ThreadSnoozeCommand,
|
|
2440
2473
|
ThreadUnsnoozeCommand,
|
|
2474
|
+
ThreadPinCommand,
|
|
2475
|
+
ThreadUnpinCommand,
|
|
2476
|
+
ThreadPinReorderCommand,
|
|
2441
2477
|
ThreadMetaUpdateCommand,
|
|
2442
2478
|
ThreadRuntimeModeSetCommand,
|
|
2443
2479
|
ThreadInteractionModeSetCommand,
|
|
@@ -2582,6 +2618,9 @@ const OrchestrationEventType = Schema$1.Literals([
|
|
|
2582
2618
|
"thread.unsettled",
|
|
2583
2619
|
"thread.snoozed",
|
|
2584
2620
|
"thread.unsnoozed",
|
|
2621
|
+
"thread.pinned",
|
|
2622
|
+
"thread.unpinned",
|
|
2623
|
+
"thread.pin-reordered",
|
|
2585
2624
|
"thread.meta-updated",
|
|
2586
2625
|
"thread.runtime-mode-set",
|
|
2587
2626
|
"thread.interaction-mode-set",
|
|
@@ -2688,6 +2727,21 @@ const ThreadUnsnoozedPayload$1 = Schema$1.Struct({
|
|
|
2688
2727
|
reason: Schema$1.Literals(["user", "activity"]),
|
|
2689
2728
|
updatedAt: IsoDateTime
|
|
2690
2729
|
});
|
|
2730
|
+
const ThreadPinnedPayload$1 = Schema$1.Struct({
|
|
2731
|
+
threadId: ThreadId,
|
|
2732
|
+
pinnedAt: IsoDateTime,
|
|
2733
|
+
pinOrderKey: Schema$1.optional(Schema$1.NullOr(Schema$1.String)),
|
|
2734
|
+
updatedAt: IsoDateTime
|
|
2735
|
+
});
|
|
2736
|
+
const ThreadUnpinnedPayload$1 = Schema$1.Struct({
|
|
2737
|
+
threadId: ThreadId,
|
|
2738
|
+
updatedAt: IsoDateTime
|
|
2739
|
+
});
|
|
2740
|
+
const ThreadPinReorderedPayload$1 = Schema$1.Struct({
|
|
2741
|
+
threadId: ThreadId,
|
|
2742
|
+
pinOrderKey: Schema$1.NullOr(Schema$1.String),
|
|
2743
|
+
updatedAt: IsoDateTime
|
|
2744
|
+
});
|
|
2691
2745
|
const ThreadMetaUpdatedPayload$1 = Schema$1.Struct({
|
|
2692
2746
|
threadId: ThreadId,
|
|
2693
2747
|
title: Schema$1.optional(TrimmedNonEmptyString),
|
|
@@ -2933,6 +2987,21 @@ const OrchestrationEvent = Schema$1.Union([
|
|
|
2933
2987
|
type: Schema$1.Literal("thread.unsnoozed"),
|
|
2934
2988
|
payload: ThreadUnsnoozedPayload$1
|
|
2935
2989
|
}),
|
|
2990
|
+
Schema$1.Struct({
|
|
2991
|
+
...EventBaseFields,
|
|
2992
|
+
type: Schema$1.Literal("thread.pinned"),
|
|
2993
|
+
payload: ThreadPinnedPayload$1
|
|
2994
|
+
}),
|
|
2995
|
+
Schema$1.Struct({
|
|
2996
|
+
...EventBaseFields,
|
|
2997
|
+
type: Schema$1.Literal("thread.unpinned"),
|
|
2998
|
+
payload: ThreadUnpinnedPayload$1
|
|
2999
|
+
}),
|
|
3000
|
+
Schema$1.Struct({
|
|
3001
|
+
...EventBaseFields,
|
|
3002
|
+
type: Schema$1.Literal("thread.pin-reordered"),
|
|
3003
|
+
payload: ThreadPinReorderedPayload$1
|
|
3004
|
+
}),
|
|
2936
3005
|
Schema$1.Struct({
|
|
2937
3006
|
...EventBaseFields,
|
|
2938
3007
|
type: Schema$1.Literal("thread.meta-updated"),
|
|
@@ -6787,6 +6856,19 @@ const UserInputQuestion = Schema$1.Struct({
|
|
|
6787
6856
|
});
|
|
6788
6857
|
const UserInputRequestedPayload = Schema$1.Struct({ questions: Schema$1.Array(UserInputQuestion) });
|
|
6789
6858
|
const UserInputResolvedPayload = Schema$1.Struct({ answers: UnknownRecordSchema });
|
|
6859
|
+
/**
|
|
6860
|
+
* Watch-loop task types: Monitor-tool tasks plus background shells (a shell
|
|
6861
|
+
* that outlives its turn is in practice a watch loop). Canonical single copy,
|
|
6862
|
+
* so the server liveness registry and any client fold classify identically.
|
|
6863
|
+
*/
|
|
6864
|
+
const MONITOR_TASK_TYPES = /* @__PURE__ */ new Set([
|
|
6865
|
+
"monitor",
|
|
6866
|
+
"monitor_mcp",
|
|
6867
|
+
"local_bash",
|
|
6868
|
+
"shell"
|
|
6869
|
+
]);
|
|
6870
|
+
/** Task types that are neither agents nor watch loops (plan-mode bookkeeping). */
|
|
6871
|
+
const INERT_TASK_TYPES = /* @__PURE__ */ new Set(["plan", "dream"]);
|
|
6790
6872
|
const TaskStartedPayload = Schema$1.Struct({
|
|
6791
6873
|
taskId: RuntimeTaskId,
|
|
6792
6874
|
description: Schema$1.optional(TrimmedNonEmptyStringSchema$1),
|
|
@@ -7852,6 +7934,8 @@ const SidebarProjectSortOrder = Schema$1.Literals([
|
|
|
7852
7934
|
const DEFAULT_SIDEBAR_PROJECT_SORT_ORDER = "updated_at";
|
|
7853
7935
|
const SidebarThreadSortOrder = Schema$1.Literals(["updated_at", "created_at"]);
|
|
7854
7936
|
const DEFAULT_SIDEBAR_THREAD_SORT_ORDER = "updated_at";
|
|
7937
|
+
const SidebarDisplayStyle = Schema$1.Literals(["project", "thread"]);
|
|
7938
|
+
const DEFAULT_SIDEBAR_DISPLAY_STYLE = "project";
|
|
7855
7939
|
const SidebarProjectGroupingMode = Schema$1.Literals([
|
|
7856
7940
|
"repository",
|
|
7857
7941
|
"repository_path",
|
|
@@ -7894,6 +7978,7 @@ const ClientSettingsSchema = Schema$1.Struct({
|
|
|
7894
7978
|
})).pipe(Schema$1.withDecodingDefault(Effect.succeed({}))),
|
|
7895
7979
|
showBuildModeToggle: Schema$1.Boolean.pipe(Schema$1.withDecodingDefault(Effect.succeed(false))),
|
|
7896
7980
|
sidebarAutoSettleAfterDays: Schema$1.NullOr(SidebarAutoSettleAfterDays).pipe(Schema$1.withDecodingDefault(Effect.succeed(3))),
|
|
7981
|
+
sidebarDisplayStyle: SidebarDisplayStyle.pipe(Schema$1.withDecodingDefault(Effect.succeed(DEFAULT_SIDEBAR_DISPLAY_STYLE))),
|
|
7897
7982
|
sidebarProjectGroupingMode: SidebarProjectGroupingMode.pipe(Schema$1.withDecodingDefault(Effect.succeed(DEFAULT_SIDEBAR_PROJECT_GROUPING_MODE))),
|
|
7898
7983
|
sidebarProjectGroupingOverrides: Schema$1.Record(TrimmedNonEmptyString, SidebarProjectGroupingMode).pipe(Schema$1.withDecodingDefault(Effect.succeed({}))),
|
|
7899
7984
|
sidebarProjectSortOrder: SidebarProjectSortOrder.pipe(Schema$1.withDecodingDefault(Effect.succeed(DEFAULT_SIDEBAR_PROJECT_SORT_ORDER))),
|
|
@@ -8151,6 +8236,12 @@ const ServerSettings = Schema$1.Struct({
|
|
|
8151
8236
|
instanceId: ProviderInstanceId.make("codex"),
|
|
8152
8237
|
model: DEFAULT_TEXT_GENERATION_MODEL
|
|
8153
8238
|
}))),
|
|
8239
|
+
/**
|
|
8240
|
+
* The supervisor model a Fusion pair starts with. Null until the user picks
|
|
8241
|
+
* one; kept in settings rather than per-draft state so the choice survives
|
|
8242
|
+
* the next thread instead of resetting to none each time.
|
|
8243
|
+
*/
|
|
8244
|
+
fusionWatcherModelSelection: Schema$1.NullOr(ModelSelection).pipe(Schema$1.withDecodingDefault(Effect.succeed(null))),
|
|
8154
8245
|
sourceControlWritingStyle: SourceControlWritingStyleSettings.pipe(Schema$1.withDecodingDefault(Effect.succeed({}))),
|
|
8155
8246
|
sourceControlWriterModelSelection: Schema$1.NullOr(ModelSelection).pipe(Schema$1.withDecodingDefault(Effect.succeed(null))),
|
|
8156
8247
|
/** Prefix used for tasks without a project or project-specific override. */
|
|
@@ -8288,6 +8379,7 @@ const ServerSettingsPatch = Schema$1.Struct({
|
|
|
8288
8379
|
newWorktreesStartFromOrigin: Schema$1.optionalKey(Schema$1.Boolean),
|
|
8289
8380
|
addProjectBaseDirectory: Schema$1.optionalKey(TrimmedString),
|
|
8290
8381
|
textGenerationModelSelection: Schema$1.optionalKey(ModelSelectionPatch),
|
|
8382
|
+
fusionWatcherModelSelection: Schema$1.optionalKey(Schema$1.NullOr(ModelSelection)),
|
|
8291
8383
|
sourceControlWritingStyle: Schema$1.optionalKey(Schema$1.Struct({
|
|
8292
8384
|
mode: Schema$1.optionalKey(SourceControlWritingStyleMode),
|
|
8293
8385
|
customInstructions: Schema$1.optionalKey(TrimmedString),
|
|
@@ -8331,6 +8423,7 @@ Schema$1.Struct({
|
|
|
8331
8423
|
}))),
|
|
8332
8424
|
showBuildModeToggle: Schema$1.optionalKey(Schema$1.Boolean),
|
|
8333
8425
|
sidebarAutoSettleAfterDays: Schema$1.optionalKey(Schema$1.NullOr(SidebarAutoSettleAfterDays)),
|
|
8426
|
+
sidebarDisplayStyle: Schema$1.optionalKey(SidebarDisplayStyle),
|
|
8334
8427
|
sidebarProjectGroupingMode: Schema$1.optionalKey(SidebarProjectGroupingMode),
|
|
8335
8428
|
sidebarProjectGroupingOverrides: Schema$1.optionalKey(Schema$1.Record(TrimmedNonEmptyString, SidebarProjectGroupingMode)),
|
|
8336
8429
|
sidebarProjectSortOrder: Schema$1.optionalKey(SidebarProjectSortOrder),
|
|
@@ -9404,7 +9497,17 @@ const TrackerStatus = Schema$1.Struct({
|
|
|
9404
9497
|
* Null in `mcp` and `none` modes, where p4code holds no credential to ask
|
|
9405
9498
|
* with.
|
|
9406
9499
|
*/
|
|
9407
|
-
workspace: Schema$1.NullOr(Schema$1.String)
|
|
9500
|
+
workspace: Schema$1.NullOr(Schema$1.String),
|
|
9501
|
+
/**
|
|
9502
|
+
* The stored key with its middle replaced by bullets, for the settings row
|
|
9503
|
+
* to display. Null in `mcp` and `none` modes.
|
|
9504
|
+
*
|
|
9505
|
+
* The full key is never sent back out. This exists so the panel can show
|
|
9506
|
+
* that a key is present, and which one, without the reader being able to
|
|
9507
|
+
* reconstruct it: the mask is a fixed width, so it does not disclose the
|
|
9508
|
+
* key's length either.
|
|
9509
|
+
*/
|
|
9510
|
+
maskedKey: Schema$1.NullOr(Schema$1.String)
|
|
9408
9511
|
});
|
|
9409
9512
|
const TrackerProviderInput = Schema$1.Struct({ provider: TrackerProviderName });
|
|
9410
9513
|
const TrackerApiKeyInput = Schema$1.Struct({
|
|
@@ -12098,7 +12201,7 @@ function deriveAuthClientMetadata(input) {
|
|
|
12098
12201
|
//#endregion
|
|
12099
12202
|
//#region src/auth/EnvironmentAuthPolicy.ts
|
|
12100
12203
|
var EnvironmentAuthPolicy = class extends Context.Service()("@p4code/cli/auth/EnvironmentAuthPolicy") {};
|
|
12101
|
-
const make$
|
|
12204
|
+
const make$88 = Effect.gen(function* () {
|
|
12102
12205
|
const config = yield* ServerConfig$1;
|
|
12103
12206
|
const isRemoteReachable = isRemoteReachableHost(config.host);
|
|
12104
12207
|
const policy = config.mode === "desktop" ? isRemoteReachable ? "remote-reachable" : "desktop-managed-local" : isRemoteReachable ? "remote-reachable" : "loopback-browser";
|
|
@@ -12116,7 +12219,7 @@ const make$87 = Effect.gen(function* () {
|
|
|
12116
12219
|
};
|
|
12117
12220
|
return EnvironmentAuthPolicy.of({ getDescriptor: () => Effect.succeed(descriptor).pipe(Effect.withSpan("EnvironmentAuthPolicy.getDescriptor")) });
|
|
12118
12221
|
});
|
|
12119
|
-
const layer$
|
|
12222
|
+
const layer$79 = Layer.effect(EnvironmentAuthPolicy, make$88);
|
|
12120
12223
|
//#endregion
|
|
12121
12224
|
//#region src/persistence/Errors.ts
|
|
12122
12225
|
function summarizeSchemaIssue(issue) {
|
|
@@ -12297,7 +12400,7 @@ function toPersistenceSqlOrDecodeError$6(sqlOperation, decodeOperation, correlat
|
|
|
12297
12400
|
cause
|
|
12298
12401
|
});
|
|
12299
12402
|
}
|
|
12300
|
-
const make$
|
|
12403
|
+
const make$87 = Effect.gen(function* () {
|
|
12301
12404
|
const sql = yield* SqlClient.SqlClient;
|
|
12302
12405
|
const createSessionRow = SqlSchema.void({
|
|
12303
12406
|
Request: CreateAuthSessionInput,
|
|
@@ -12431,7 +12534,7 @@ const make$86 = Effect.gen(function* () {
|
|
|
12431
12534
|
setLastConnectedAt
|
|
12432
12535
|
};
|
|
12433
12536
|
});
|
|
12434
|
-
const layer$
|
|
12537
|
+
const layer$78 = Layer.effect(AuthSessionRepository, make$87);
|
|
12435
12538
|
//#endregion
|
|
12436
12539
|
//#region src/auth/ServerSecretStore.ts
|
|
12437
12540
|
const secretStoreErrorContext = {
|
|
@@ -12498,7 +12601,7 @@ const isSecretStoreError = Schema$1.is(SecretStoreError);
|
|
|
12498
12601
|
const isPlatformError = (value) => Predicate.isTagged(value, "PlatformError");
|
|
12499
12602
|
const isSecretAlreadyExistsError = (error) => "cause" in error && isPlatformError(error.cause) && error.cause.reason._tag === "AlreadyExists";
|
|
12500
12603
|
var ServerSecretStore = class extends Context.Service()("@p4code/cli/auth/ServerSecretStore") {};
|
|
12501
|
-
const make$
|
|
12604
|
+
const make$86 = Effect.gen(function* () {
|
|
12502
12605
|
const crypto = yield* Crypto.Crypto;
|
|
12503
12606
|
const fileSystem = yield* FileSystem.FileSystem;
|
|
12504
12607
|
const path = yield* Path.Path;
|
|
@@ -12568,7 +12671,7 @@ const make$85 = Effect.gen(function* () {
|
|
|
12568
12671
|
remove
|
|
12569
12672
|
});
|
|
12570
12673
|
});
|
|
12571
|
-
const layer$
|
|
12674
|
+
const layer$77 = Layer.effect(ServerSecretStore, make$86);
|
|
12572
12675
|
//#endregion
|
|
12573
12676
|
//#region src/auth/SessionStore.ts
|
|
12574
12677
|
var MalformedSessionTokenError = class extends Schema$1.TaggedErrorClass()("MalformedSessionTokenError", {}) {
|
|
@@ -12806,7 +12909,7 @@ function toAuthClientSession(input) {
|
|
|
12806
12909
|
current: false
|
|
12807
12910
|
};
|
|
12808
12911
|
}
|
|
12809
|
-
const make$
|
|
12912
|
+
const make$85 = Effect.gen(function* () {
|
|
12810
12913
|
const crypto = yield* Crypto.Crypto;
|
|
12811
12914
|
const serverConfig = yield* ServerConfig$1;
|
|
12812
12915
|
const secretStore = yield* ServerSecretStore;
|
|
@@ -13120,7 +13223,7 @@ const make$84 = Effect.gen(function* () {
|
|
|
13120
13223
|
markDisconnected
|
|
13121
13224
|
});
|
|
13122
13225
|
});
|
|
13123
|
-
const layer$
|
|
13226
|
+
const layer$76 = Layer.effect(SessionStore, make$85).pipe(Layer.provideMerge(layer$78));
|
|
13124
13227
|
//#endregion
|
|
13125
13228
|
//#region src/persistence/AuthPairingLinks.ts
|
|
13126
13229
|
const AuthPairingLinkRecord = Schema$1.Struct({
|
|
@@ -13181,7 +13284,7 @@ function toPersistenceSqlOrDecodeError$5(sqlOperation, decodeOperation, correlat
|
|
|
13181
13284
|
cause
|
|
13182
13285
|
});
|
|
13183
13286
|
}
|
|
13184
|
-
const make$
|
|
13287
|
+
const make$84 = Effect.gen(function* () {
|
|
13185
13288
|
const sql = yield* SqlClient.SqlClient;
|
|
13186
13289
|
const createPairingLinkRow = SqlSchema.void({
|
|
13187
13290
|
Request: CreateAuthPairingLinkInput,
|
|
@@ -13316,7 +13419,7 @@ const make$83 = Effect.gen(function* () {
|
|
|
13316
13419
|
getByCredential
|
|
13317
13420
|
};
|
|
13318
13421
|
});
|
|
13319
|
-
const layer$
|
|
13422
|
+
const layer$75 = Layer.effect(AuthPairingLinkRepository, make$84);
|
|
13320
13423
|
//#endregion
|
|
13321
13424
|
//#region src/auth/PairingGrantStore.ts
|
|
13322
13425
|
var UnknownBootstrapCredentialError = class extends Schema$1.TaggedErrorClass()("UnknownBootstrapCredentialError", {}) {
|
|
@@ -13411,7 +13514,7 @@ const DEV_STARTUP_TTL_HOURS = Duration.hours(24);
|
|
|
13411
13514
|
const PAIRING_TOKEN_ALPHABET = "23456789ABCDEFGHJKLMNPQRSTUVWXYZ";
|
|
13412
13515
|
const PAIRING_TOKEN_LENGTH = 12;
|
|
13413
13516
|
const PAIRING_TOKEN_REJECTION_LIMIT = Math.floor(256 / 32) * 32;
|
|
13414
|
-
const make$
|
|
13517
|
+
const make$83 = Effect.gen(function* () {
|
|
13415
13518
|
const crypto = yield* Crypto.Crypto;
|
|
13416
13519
|
const config = yield* ServerConfig$1;
|
|
13417
13520
|
const pairingLinks = yield* AuthPairingLinkRepository;
|
|
@@ -13609,7 +13712,7 @@ const make$82 = Effect.gen(function* () {
|
|
|
13609
13712
|
consume
|
|
13610
13713
|
});
|
|
13611
13714
|
});
|
|
13612
|
-
const layer$
|
|
13715
|
+
const layer$74 = Layer.effect(PairingGrantStore, make$83).pipe(Layer.provideMerge(layer$75));
|
|
13613
13716
|
//#endregion
|
|
13614
13717
|
//#region src/persistence/DatabaseSnapshot.ts
|
|
13615
13718
|
/**
|
|
@@ -15450,6 +15553,27 @@ var _047_ThreadPairGates_default = Effect.gen(function* () {
|
|
|
15450
15553
|
`;
|
|
15451
15554
|
});
|
|
15452
15555
|
//#endregion
|
|
15556
|
+
//#region src/persistence/Migrations/048_ProjectionThreadsPinned.ts
|
|
15557
|
+
/**
|
|
15558
|
+
* Server-side thread pinning. `pinned_at` holds the pin itself; `pin_order_key`
|
|
15559
|
+
* is the fractional index that orders the pinned block, written one key at a
|
|
15560
|
+
* time so a reorder never touches threads living on other servers.
|
|
15561
|
+
*
|
|
15562
|
+
* Both are nullable with no default: an unpinned thread is the absence of a
|
|
15563
|
+
* pin, and every existing thread starts unpinned.
|
|
15564
|
+
*/
|
|
15565
|
+
var _048_ProjectionThreadsPinned_default = Effect.gen(function* () {
|
|
15566
|
+
const sql = yield* SqlClient.SqlClient;
|
|
15567
|
+
yield* sql`
|
|
15568
|
+
ALTER TABLE projection_threads
|
|
15569
|
+
ADD COLUMN pinned_at TEXT
|
|
15570
|
+
`;
|
|
15571
|
+
yield* sql`
|
|
15572
|
+
ALTER TABLE projection_threads
|
|
15573
|
+
ADD COLUMN pin_order_key TEXT
|
|
15574
|
+
`;
|
|
15575
|
+
});
|
|
15576
|
+
//#endregion
|
|
15453
15577
|
//#region src/persistence/Migrations.ts
|
|
15454
15578
|
/**
|
|
15455
15579
|
* MigrationsLive - Migration runner with inline loader
|
|
@@ -15705,6 +15829,11 @@ const migrationEntries = [
|
|
|
15705
15829
|
47,
|
|
15706
15830
|
"ThreadPairGates",
|
|
15707
15831
|
_047_ThreadPairGates_default
|
|
15832
|
+
],
|
|
15833
|
+
[
|
|
15834
|
+
48,
|
|
15835
|
+
"ProjectionThreadsPinned",
|
|
15836
|
+
_048_ProjectionThreadsPinned_default
|
|
15708
15837
|
]
|
|
15709
15838
|
];
|
|
15710
15839
|
const makeMigrationLoader = (throughId) => Migrator.fromRecord(Object.fromEntries(migrationEntries.filter(([id]) => throughId === void 0 || id <= throughId).map(([id, name, migration]) => [`${id}_${name}`, migration])));
|
|
@@ -15955,7 +16084,7 @@ function parseBearerToken(request) {
|
|
|
15955
16084
|
const token = header.slice(7).trim();
|
|
15956
16085
|
return token.length > 0 ? token : null;
|
|
15957
16086
|
}
|
|
15958
|
-
const make$
|
|
16087
|
+
const make$82 = Effect.gen(function* () {
|
|
15959
16088
|
const policy = yield* EnvironmentAuthPolicy;
|
|
15960
16089
|
const bootstrapCredentials = yield* PairingGrantStore;
|
|
15961
16090
|
const sessions = yield* SessionStore;
|
|
@@ -16150,9 +16279,9 @@ const make$81 = Effect.gen(function* () {
|
|
|
16150
16279
|
issueStartupPairingUrl
|
|
16151
16280
|
});
|
|
16152
16281
|
});
|
|
16153
|
-
const layer$
|
|
16154
|
-
const storageLayer = Layer.mergeAll(layer$
|
|
16155
|
-
const runtimeLayer = layer$
|
|
16282
|
+
const layer$73 = Layer.effect(EnvironmentAuth, make$82).pipe(Layer.provideMerge(layer$74), Layer.provideMerge(layer$76), Layer.provideMerge(layer$79));
|
|
16283
|
+
const storageLayer = Layer.mergeAll(layer$77, layerConfig);
|
|
16284
|
+
const runtimeLayer = layer$73.pipe(Layer.provideMerge(storageLayer));
|
|
16156
16285
|
//#endregion
|
|
16157
16286
|
//#region src/cliAuthFormat.ts
|
|
16158
16287
|
const newline = "\n";
|
|
@@ -16907,7 +17036,7 @@ const runWithEnvironmentAuth = (flags, run, options) => Effect.gen(function* ()
|
|
|
16907
17036
|
}
|
|
16908
17037
|
return yield* Effect.gen(function* () {
|
|
16909
17038
|
return yield* run(yield* EnvironmentAuth);
|
|
16910
|
-
}).pipe(Effect.provide(Layer.mergeAll(runtimeLayer).pipe(Layer.provide(layer$
|
|
17039
|
+
}).pipe(Effect.provide(Layer.mergeAll(runtimeLayer).pipe(Layer.provide(layer$80(config)), Layer.provide(Layer.succeed(References.MinimumLogLevel, minimumLogLevel)))));
|
|
16911
17040
|
});
|
|
16912
17041
|
const ttlFlag = Flag.string("ttl").pipe(Flag.withSchema(DurationFromString), Flag.withDescription("TTL, for example `5m`, `1h`, `30d`, or `15 minutes`."), Flag.optional);
|
|
16913
17042
|
const jsonFlag = Flag.boolean("json").pipe(Flag.withDescription("Emit JSON instead of human-readable output."), Flag.withDefault(false));
|
|
@@ -17047,7 +17176,7 @@ const DEFAULT_LIMITS = {
|
|
|
17047
17176
|
windowMillis: FAILURE_WINDOW_MS,
|
|
17048
17177
|
blockMillis: BLOCK_DURATION_MS
|
|
17049
17178
|
};
|
|
17050
|
-
const make$
|
|
17179
|
+
const make$81 = Effect.fn("HubAuthThrottle.make")(function* (limits = DEFAULT_LIMITS) {
|
|
17051
17180
|
const state = yield* Ref.make(initialThrottleState);
|
|
17052
17181
|
return HubAuthThrottle.of({
|
|
17053
17182
|
shouldRefuse: Effect.gen(function* () {
|
|
@@ -17061,7 +17190,7 @@ const make$80 = Effect.fn("HubAuthThrottle.make")(function* (limits = DEFAULT_LI
|
|
|
17061
17190
|
})
|
|
17062
17191
|
});
|
|
17063
17192
|
});
|
|
17064
|
-
const layer$
|
|
17193
|
+
const layer$72 = Layer.effect(HubAuthThrottle, make$81());
|
|
17065
17194
|
//#endregion
|
|
17066
17195
|
//#region src/hub/HubAuth.ts
|
|
17067
17196
|
/**
|
|
@@ -18120,7 +18249,7 @@ const releaseFeedLeaseRoute = HttpRouter.add("DELETE", "/feed/lease", respondToH
|
|
|
18120
18249
|
yield* (yield* SqlClient.SqlClient)`DELETE FROM feed_refresh_lease WHERE lease_key='refresh' AND owner=${body.owner}`;
|
|
18121
18250
|
return HttpServerResponse.empty({ status: 204 });
|
|
18122
18251
|
})));
|
|
18123
|
-
const layer$
|
|
18252
|
+
const layer$71 = Layer.mergeAll(healthRoute, listTasksRoute, getTaskRoute, createTaskRoute, putTaskRoute, updateTaskRoute, deleteTaskRoute, listAssetsRoute, getAssetRoute, putAssetRoute, deleteAssetRoute, listFeedSourcesRoute, upsertFeedSourceRoute, deleteFeedSourceRoute, listFeedRoute, putFeedArticleRoute, putFeedEngagementRoute, markFeedReadRoute, cleanupFeedRoute, setFeedRefreshedAtRoute, acquireFeedLeaseRoute, renewFeedLeaseRoute, releaseFeedLeaseRoute);
|
|
18124
18253
|
//#endregion
|
|
18125
18254
|
//#region src/hub/Migrations/001_Tasks.ts
|
|
18126
18255
|
/**
|
|
@@ -18635,7 +18764,7 @@ const announce = Layer.effectDiscard(Effect.gen(function* () {
|
|
|
18635
18764
|
});
|
|
18636
18765
|
if (isRemoteReachableHost(config.host)) yield* Effect.logWarning("Hub is reachable beyond loopback. The bearer token is the only control — repeated auth failures are not rate limited.", { host: config.host });
|
|
18637
18766
|
}));
|
|
18638
|
-
const makeHubLayer = HttpRouter.serve(layer$
|
|
18767
|
+
const makeHubLayer = HttpRouter.serve(layer$71).pipe(Layer.provideMerge(announce), Layer.provideMerge(HubHttpServerLive), Layer.provideMerge(layer$72), Layer.provideMerge(TaskRepositoryLive), Layer.provideMerge(AgentAssetRepositoryLive), Layer.provideMerge(HubPersistenceLive));
|
|
18639
18768
|
const runHub = Layer.launch(makeHubLayer);
|
|
18640
18769
|
//#endregion
|
|
18641
18770
|
//#region src/atomicWrite.ts
|
|
@@ -18759,7 +18888,7 @@ function stripDefaultServerSettings(current, defaults) {
|
|
|
18759
18888
|
}
|
|
18760
18889
|
return Object.is(current, defaults) ? void 0 : current;
|
|
18761
18890
|
}
|
|
18762
|
-
const make$
|
|
18891
|
+
const make$80 = Effect.gen(function* () {
|
|
18763
18892
|
const { settingsPath } = yield* ServerConfig$1;
|
|
18764
18893
|
const fs = yield* FileSystem.FileSystem;
|
|
18765
18894
|
const pathService = yield* Path.Path;
|
|
@@ -18980,7 +19109,7 @@ const make$79 = Effect.gen(function* () {
|
|
|
18980
19109
|
}
|
|
18981
19110
|
};
|
|
18982
19111
|
});
|
|
18983
|
-
const layer$
|
|
19112
|
+
const layer$70 = Layer.effect(ServerSettingsService, make$80);
|
|
18984
19113
|
//#endregion
|
|
18985
19114
|
//#region src/pathExpansion.ts
|
|
18986
19115
|
/**
|
|
@@ -19354,7 +19483,7 @@ function claudeEntryFromRegistration(registration) {
|
|
|
19354
19483
|
};
|
|
19355
19484
|
}
|
|
19356
19485
|
var ClaudeMcpFiles = class extends Context.Service()("@p4code/cli/mcp/ClaudeMcpFiles") {};
|
|
19357
|
-
const make$
|
|
19486
|
+
const make$79 = Effect.gen(function* () {
|
|
19358
19487
|
const fileSystem = yield* FileSystem.FileSystem;
|
|
19359
19488
|
const path = yield* Path.Path;
|
|
19360
19489
|
const services = yield* Effect.context();
|
|
@@ -19419,7 +19548,7 @@ const make$78 = Effect.gen(function* () {
|
|
|
19419
19548
|
removeProject: (projectDir, name) => removeAt(Effect.succeed(projectFile(projectDir)))(name)
|
|
19420
19549
|
};
|
|
19421
19550
|
});
|
|
19422
|
-
const layer$
|
|
19551
|
+
const layer$69 = Layer.effect(ClaudeMcpFiles, make$79);
|
|
19423
19552
|
Layer.succeed(ClaudeMcpFiles, {
|
|
19424
19553
|
readUser: Effect.succeed([]),
|
|
19425
19554
|
upsertUser: () => Effect.fail(new McpRegistryError({ detail: "No Claude config in tests." })),
|
|
@@ -19555,7 +19684,7 @@ const decodeClientRegistration = Schema$1.decodeUnknownExit(ClientRegistrationRe
|
|
|
19555
19684
|
const decodeTokenResponse = Schema$1.decodeUnknownExit(TokenResponse);
|
|
19556
19685
|
var McpOAuth = class extends Context.Service()("@p4code/cli/mcp/McpOAuth") {};
|
|
19557
19686
|
const registryError = (detail) => new McpRegistryError({ detail });
|
|
19558
|
-
const make$
|
|
19687
|
+
const make$78 = Effect.gen(function* () {
|
|
19559
19688
|
const config = yield* ServerConfig$1;
|
|
19560
19689
|
const secrets = yield* ServerSecretStore;
|
|
19561
19690
|
const http = yield* HttpClient.HttpClient;
|
|
@@ -19875,7 +20004,7 @@ const make$77 = Effect.gen(function* () {
|
|
|
19875
20004
|
accessTokenFor
|
|
19876
20005
|
};
|
|
19877
20006
|
});
|
|
19878
|
-
const layer$
|
|
20007
|
+
const layer$68 = Layer.effect(McpOAuth, make$78);
|
|
19879
20008
|
Layer.succeed(McpOAuth, {
|
|
19880
20009
|
statusFor: () => Effect.succeed(Option.none()),
|
|
19881
20010
|
begin: () => Effect.fail(new McpRegistryError({ detail: "OAuth sign-in is not available." })),
|
|
@@ -19893,7 +20022,7 @@ const decodeRegistration$1 = Schema$1.decodeUnknownExit(RegistrationFromJson$1);
|
|
|
19893
20022
|
const encodeRegistration = Schema$1.encodeSync(RegistrationFromJson$1);
|
|
19894
20023
|
var McpRegistry = class extends Context.Service()("@p4code/cli/mcp/McpRegistry") {};
|
|
19895
20024
|
const slotsOf = (registration) => registration.secrets ?? [];
|
|
19896
|
-
const make$
|
|
20025
|
+
const make$77 = Effect.gen(function* () {
|
|
19897
20026
|
const config = yield* ServerConfig$1;
|
|
19898
20027
|
const secrets = yield* ServerSecretStore;
|
|
19899
20028
|
const oauth = yield* McpOAuth;
|
|
@@ -20044,7 +20173,7 @@ const make$76 = Effect.gen(function* () {
|
|
|
20044
20173
|
}).pipe(Effect.provide(services), Effect.catchCause((cause) => Effect.logWarning("mcp registry resolve failed", { cause }).pipe(Effect.as({}))))
|
|
20045
20174
|
};
|
|
20046
20175
|
});
|
|
20047
|
-
const layer$
|
|
20176
|
+
const layer$67 = Layer.effect(McpRegistry, make$77);
|
|
20048
20177
|
//#endregion
|
|
20049
20178
|
//#region src/sync/skillDirectory.ts
|
|
20050
20179
|
/**
|
|
@@ -20423,7 +20552,7 @@ const formatHubLink = (input) => encodeStoredHubLink({
|
|
|
20423
20552
|
shareMode: input.shareMode
|
|
20424
20553
|
});
|
|
20425
20554
|
const fromEnvironment = (environment) => validateHubLink(environment.P4CODE_HUB_URL ?? "", environment.P4CODE_HUB_TOKEN ?? "");
|
|
20426
|
-
const make$
|
|
20555
|
+
const make$76 = Effect.fn("HubLink.make")(function* (environment) {
|
|
20427
20556
|
const secrets = yield* ServerSecretStore;
|
|
20428
20557
|
const env = environment ?? process.env;
|
|
20429
20558
|
const fromEnv = fromEnvironment(env);
|
|
@@ -20489,7 +20618,7 @@ const make$75 = Effect.fn("HubLink.make")(function* (environment) {
|
|
|
20489
20618
|
})
|
|
20490
20619
|
};
|
|
20491
20620
|
});
|
|
20492
|
-
const layer$
|
|
20621
|
+
const layer$66 = Layer.effect(HubLink, make$76());
|
|
20493
20622
|
//#endregion
|
|
20494
20623
|
//#region src/sync/HubAssetClient.ts
|
|
20495
20624
|
/**
|
|
@@ -20522,7 +20651,7 @@ const decodeAssetListPage = Schema$1.decodeUnknownEffect(AssetListPage);
|
|
|
20522
20651
|
const decodeConflictBody$1 = Schema$1.decodeUnknownEffect(ConflictBody$1);
|
|
20523
20652
|
const decodeAsset = Schema$1.decodeUnknownEffect(AgentAsset);
|
|
20524
20653
|
var HubAssetClient = class extends Context.Service()("@p4code/cli/sync/HubAssetClient") {};
|
|
20525
|
-
const make$
|
|
20654
|
+
const make$75 = Effect.gen(function* () {
|
|
20526
20655
|
const http = yield* HttpClient.HttpClient;
|
|
20527
20656
|
const link = yield* HubLink;
|
|
20528
20657
|
const requireSettings = Effect.gen(function* () {
|
|
@@ -20604,7 +20733,7 @@ const make$74 = Effect.gen(function* () {
|
|
|
20604
20733
|
remove
|
|
20605
20734
|
};
|
|
20606
20735
|
});
|
|
20607
|
-
const layer$
|
|
20736
|
+
const layer$65 = Layer.effect(HubAssetClient, make$75);
|
|
20608
20737
|
//#endregion
|
|
20609
20738
|
//#region src/sync/mcpRegistrationFiles.ts
|
|
20610
20739
|
/**
|
|
@@ -21179,7 +21308,7 @@ const EMPTY_REPORT = {
|
|
|
21179
21308
|
unavailable: null
|
|
21180
21309
|
};
|
|
21181
21310
|
var AssetSync = class extends Context.Service()("@p4code/cli/sync/AssetSync") {};
|
|
21182
|
-
const make$
|
|
21311
|
+
const make$74 = Effect.gen(function* () {
|
|
21183
21312
|
const client = yield* HubAssetClient;
|
|
21184
21313
|
const link = yield* HubLink;
|
|
21185
21314
|
const settingsStore = yield* ServerSettingsService;
|
|
@@ -21892,7 +22021,7 @@ const make$73 = Effect.gen(function* () {
|
|
|
21892
22021
|
removeLocal
|
|
21893
22022
|
};
|
|
21894
22023
|
});
|
|
21895
|
-
const layer$
|
|
22024
|
+
const layer$64 = Layer.effect(AssetSync, make$74);
|
|
21896
22025
|
//#endregion
|
|
21897
22026
|
//#region src/provider/CompressPrompts.ts
|
|
21898
22027
|
/**
|
|
@@ -22266,7 +22395,7 @@ const findAgentPreset = (requested) => {
|
|
|
22266
22395
|
};
|
|
22267
22396
|
//#endregion
|
|
22268
22397
|
//#region src/cli/assets.ts
|
|
22269
|
-
const SyncServicesLive = layer$
|
|
22398
|
+
const SyncServicesLive = layer$64.pipe(Layer.provideMerge(layer$65), Layer.provideMerge(layer$66), Layer.provideMerge(layer$70.pipe(Layer.provide(layer$77))), Layer.provideMerge(layer$77), Layer.provideMerge(FetchHttpClient.layer));
|
|
22270
22399
|
const runWithSync = (flags, run) => Effect.gen(function* () {
|
|
22271
22400
|
const config = yield* resolveCliAuthConfig(flags, yield* GlobalFlag.LogLevel);
|
|
22272
22401
|
return yield* Effect.gen(function* () {
|
|
@@ -22274,7 +22403,7 @@ const runWithSync = (flags, run) => Effect.gen(function* () {
|
|
|
22274
22403
|
sync: yield* AssetSync,
|
|
22275
22404
|
link: yield* HubLink
|
|
22276
22405
|
});
|
|
22277
|
-
}).pipe(Effect.provide(SyncServicesLive.pipe(Layer.provide(layer$
|
|
22406
|
+
}).pipe(Effect.provide(SyncServicesLive.pipe(Layer.provide(layer$80(config)), Layer.provide(Layer.succeed(References.MinimumLogLevel, "Error")))));
|
|
22278
22407
|
});
|
|
22279
22408
|
const STATE_LABEL = {
|
|
22280
22409
|
synced: "synced",
|
|
@@ -23305,6 +23434,9 @@ const ThreadUnpromptedSubagentsSetPayload = ThreadUnpromptedSubagentsSetPayload$
|
|
|
23305
23434
|
const ThreadDeletedPayload = ThreadDeletedPayload$1;
|
|
23306
23435
|
const ThreadUnarchivedPayload = ThreadUnarchivedPayload$1;
|
|
23307
23436
|
const ThreadUnsettledPayload = ThreadUnsettledPayload$1;
|
|
23437
|
+
const ThreadPinnedPayload = ThreadPinnedPayload$1;
|
|
23438
|
+
const ThreadPinReorderedPayload = ThreadPinReorderedPayload$1;
|
|
23439
|
+
const ThreadUnpinnedPayload = ThreadUnpinnedPayload$1;
|
|
23308
23440
|
const ThreadSnoozedPayload = ThreadSnoozedPayload$1;
|
|
23309
23441
|
const ThreadUnsnoozedPayload = ThreadUnsnoozedPayload$1;
|
|
23310
23442
|
const MessageSentPayloadSchema = ThreadMessageSentPayload;
|
|
@@ -23574,6 +23706,29 @@ function projectEvent(model, event) {
|
|
|
23574
23706
|
updatedAt: payload.updatedAt
|
|
23575
23707
|
})
|
|
23576
23708
|
})));
|
|
23709
|
+
case "thread.pinned": return decodeForEvent(ThreadPinnedPayload, event.payload, event.type, "payload").pipe(Effect.map((payload) => ({
|
|
23710
|
+
...nextBase,
|
|
23711
|
+
threads: updateThread(nextBase.threads, payload.threadId, {
|
|
23712
|
+
pinnedAt: payload.pinnedAt,
|
|
23713
|
+
...payload.pinOrderKey === void 0 ? {} : { pinOrderKey: payload.pinOrderKey },
|
|
23714
|
+
updatedAt: payload.updatedAt
|
|
23715
|
+
})
|
|
23716
|
+
})));
|
|
23717
|
+
case "thread.unpinned": return decodeForEvent(ThreadUnpinnedPayload, event.payload, event.type, "payload").pipe(Effect.map((payload) => ({
|
|
23718
|
+
...nextBase,
|
|
23719
|
+
threads: updateThread(nextBase.threads, payload.threadId, {
|
|
23720
|
+
pinnedAt: null,
|
|
23721
|
+
pinOrderKey: null,
|
|
23722
|
+
updatedAt: payload.updatedAt
|
|
23723
|
+
})
|
|
23724
|
+
})));
|
|
23725
|
+
case "thread.pin-reordered": return decodeForEvent(ThreadPinReorderedPayload, event.payload, event.type, "payload").pipe(Effect.map((payload) => ({
|
|
23726
|
+
...nextBase,
|
|
23727
|
+
threads: updateThread(nextBase.threads, payload.threadId, {
|
|
23728
|
+
pinOrderKey: payload.pinOrderKey,
|
|
23729
|
+
updatedAt: payload.updatedAt
|
|
23730
|
+
})
|
|
23731
|
+
})));
|
|
23577
23732
|
case "thread.meta-updated": return decodeForEvent(ThreadMetaUpdatedPayload, event.payload, event.type, "payload").pipe(Effect.map((payload) => ({
|
|
23578
23733
|
...nextBase,
|
|
23579
23734
|
threads: updateThread(nextBase.threads, payload.threadId, {
|
|
@@ -24305,7 +24460,7 @@ const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand")(funct
|
|
|
24305
24460
|
detail: `thread ${command.threadId} has a queued turn start and cannot be settled`
|
|
24306
24461
|
}));
|
|
24307
24462
|
const alreadySettled = thread.settledOverride === "settled" && thread.settledAt !== null;
|
|
24308
|
-
|
|
24463
|
+
const settledEvent = {
|
|
24309
24464
|
...yield* withEventBase({
|
|
24310
24465
|
aggregateKind: "thread",
|
|
24311
24466
|
aggregateId: command.threadId,
|
|
@@ -24319,6 +24474,20 @@ const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand")(funct
|
|
|
24319
24474
|
updatedAt: alreadySettled ? thread.updatedAt : occurredAt
|
|
24320
24475
|
}
|
|
24321
24476
|
};
|
|
24477
|
+
if (thread.pinnedAt == null) return settledEvent;
|
|
24478
|
+
return [settledEvent, {
|
|
24479
|
+
...yield* withEventBase({
|
|
24480
|
+
aggregateKind: "thread",
|
|
24481
|
+
aggregateId: command.threadId,
|
|
24482
|
+
occurredAt,
|
|
24483
|
+
commandId: command.commandId
|
|
24484
|
+
}),
|
|
24485
|
+
type: "thread.unpinned",
|
|
24486
|
+
payload: {
|
|
24487
|
+
threadId: command.threadId,
|
|
24488
|
+
updatedAt: occurredAt
|
|
24489
|
+
}
|
|
24490
|
+
}];
|
|
24322
24491
|
}
|
|
24323
24492
|
case "thread.unsettle": {
|
|
24324
24493
|
const thread = yield* requireThreadNotArchived({
|
|
@@ -24402,6 +24571,105 @@ const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand")(funct
|
|
|
24402
24571
|
}
|
|
24403
24572
|
};
|
|
24404
24573
|
}
|
|
24574
|
+
case "thread.pin": {
|
|
24575
|
+
const thread = yield* requireThreadNotArchived({
|
|
24576
|
+
readModel,
|
|
24577
|
+
command,
|
|
24578
|
+
threadId: command.threadId
|
|
24579
|
+
});
|
|
24580
|
+
const occurredAt = yield* nowIso$8;
|
|
24581
|
+
const existingPinnedAt = thread.pinnedAt ?? null;
|
|
24582
|
+
const pinnedEvent = {
|
|
24583
|
+
...yield* withEventBase({
|
|
24584
|
+
aggregateKind: "thread",
|
|
24585
|
+
aggregateId: command.threadId,
|
|
24586
|
+
occurredAt,
|
|
24587
|
+
commandId: command.commandId
|
|
24588
|
+
}),
|
|
24589
|
+
type: "thread.pinned",
|
|
24590
|
+
payload: {
|
|
24591
|
+
threadId: command.threadId,
|
|
24592
|
+
pinnedAt: existingPinnedAt ?? occurredAt,
|
|
24593
|
+
updatedAt: existingPinnedAt !== null ? thread.updatedAt : occurredAt
|
|
24594
|
+
}
|
|
24595
|
+
};
|
|
24596
|
+
const promotionEvents = [];
|
|
24597
|
+
if (thread.settledOverride === "settled") promotionEvents.push({
|
|
24598
|
+
...yield* withEventBase({
|
|
24599
|
+
aggregateKind: "thread",
|
|
24600
|
+
aggregateId: command.threadId,
|
|
24601
|
+
occurredAt,
|
|
24602
|
+
commandId: command.commandId
|
|
24603
|
+
}),
|
|
24604
|
+
type: "thread.unsettled",
|
|
24605
|
+
payload: {
|
|
24606
|
+
threadId: command.threadId,
|
|
24607
|
+
reason: "user",
|
|
24608
|
+
updatedAt: occurredAt
|
|
24609
|
+
}
|
|
24610
|
+
});
|
|
24611
|
+
if (thread.snoozedUntil != null) promotionEvents.push({
|
|
24612
|
+
...yield* withEventBase({
|
|
24613
|
+
aggregateKind: "thread",
|
|
24614
|
+
aggregateId: command.threadId,
|
|
24615
|
+
occurredAt,
|
|
24616
|
+
commandId: command.commandId
|
|
24617
|
+
}),
|
|
24618
|
+
type: "thread.unsnoozed",
|
|
24619
|
+
payload: {
|
|
24620
|
+
threadId: command.threadId,
|
|
24621
|
+
reason: "user",
|
|
24622
|
+
updatedAt: occurredAt
|
|
24623
|
+
}
|
|
24624
|
+
});
|
|
24625
|
+
return promotionEvents.length > 0 ? [pinnedEvent, ...promotionEvents] : pinnedEvent;
|
|
24626
|
+
}
|
|
24627
|
+
case "thread.unpin": {
|
|
24628
|
+
const thread = yield* requireThreadNotArchived({
|
|
24629
|
+
readModel,
|
|
24630
|
+
command,
|
|
24631
|
+
threadId: command.threadId
|
|
24632
|
+
});
|
|
24633
|
+
const alreadyUnpinned = thread.pinnedAt == null;
|
|
24634
|
+
const occurredAt = yield* nowIso$8;
|
|
24635
|
+
return {
|
|
24636
|
+
...yield* withEventBase({
|
|
24637
|
+
aggregateKind: "thread",
|
|
24638
|
+
aggregateId: command.threadId,
|
|
24639
|
+
occurredAt,
|
|
24640
|
+
commandId: command.commandId
|
|
24641
|
+
}),
|
|
24642
|
+
type: "thread.unpinned",
|
|
24643
|
+
payload: {
|
|
24644
|
+
threadId: command.threadId,
|
|
24645
|
+
updatedAt: alreadyUnpinned ? thread.updatedAt : occurredAt
|
|
24646
|
+
}
|
|
24647
|
+
};
|
|
24648
|
+
}
|
|
24649
|
+
case "thread.pin.reorder": {
|
|
24650
|
+
const thread = yield* requireThreadNotArchived({
|
|
24651
|
+
readModel,
|
|
24652
|
+
command,
|
|
24653
|
+
threadId: command.threadId
|
|
24654
|
+
});
|
|
24655
|
+
const occurredAt = yield* nowIso$8;
|
|
24656
|
+
const nextKey = thread.pinnedAt == null ? null : command.pinOrderKey;
|
|
24657
|
+
const unchanged = (thread.pinOrderKey ?? null) === nextKey;
|
|
24658
|
+
return {
|
|
24659
|
+
...yield* withEventBase({
|
|
24660
|
+
aggregateKind: "thread",
|
|
24661
|
+
aggregateId: command.threadId,
|
|
24662
|
+
occurredAt,
|
|
24663
|
+
commandId: command.commandId
|
|
24664
|
+
}),
|
|
24665
|
+
type: "thread.pin-reordered",
|
|
24666
|
+
payload: {
|
|
24667
|
+
threadId: command.threadId,
|
|
24668
|
+
pinOrderKey: nextKey,
|
|
24669
|
+
updatedAt: unchanged ? thread.updatedAt : occurredAt
|
|
24670
|
+
}
|
|
24671
|
+
};
|
|
24672
|
+
}
|
|
24405
24673
|
case "thread.meta.update": {
|
|
24406
24674
|
const thread = yield* requireThread({
|
|
24407
24675
|
readModel,
|
|
@@ -25362,6 +25630,8 @@ const ProjectionThread = Schema$1.Struct({
|
|
|
25362
25630
|
settledAt: Schema$1.NullOr(IsoDateTime),
|
|
25363
25631
|
snoozedUntil: Schema$1.NullOr(IsoDateTime),
|
|
25364
25632
|
snoozedAt: Schema$1.NullOr(IsoDateTime),
|
|
25633
|
+
pinnedAt: Schema$1.NullOr(IsoDateTime),
|
|
25634
|
+
pinOrderKey: Schema$1.NullOr(Schema$1.String),
|
|
25365
25635
|
latestUserMessageAt: Schema$1.NullOr(IsoDateTime),
|
|
25366
25636
|
pendingApprovalCount: NonNegativeInt,
|
|
25367
25637
|
pendingUserInputCount: NonNegativeInt,
|
|
@@ -26255,6 +26525,8 @@ const makeProjectionThreadRepository = Effect.gen(function* () {
|
|
|
26255
26525
|
settled_at,
|
|
26256
26526
|
snoozed_until,
|
|
26257
26527
|
snoozed_at,
|
|
26528
|
+
pinned_at,
|
|
26529
|
+
pin_order_key,
|
|
26258
26530
|
latest_user_message_at,
|
|
26259
26531
|
pending_approval_count,
|
|
26260
26532
|
pending_user_input_count,
|
|
@@ -26282,6 +26554,8 @@ const makeProjectionThreadRepository = Effect.gen(function* () {
|
|
|
26282
26554
|
${row.settledAt},
|
|
26283
26555
|
${row.snoozedUntil},
|
|
26284
26556
|
${row.snoozedAt},
|
|
26557
|
+
${row.pinnedAt},
|
|
26558
|
+
${row.pinOrderKey},
|
|
26285
26559
|
${row.latestUserMessageAt},
|
|
26286
26560
|
${row.pendingApprovalCount},
|
|
26287
26561
|
${row.pendingUserInputCount},
|
|
@@ -26309,6 +26583,8 @@ const makeProjectionThreadRepository = Effect.gen(function* () {
|
|
|
26309
26583
|
settled_at = excluded.settled_at,
|
|
26310
26584
|
snoozed_until = excluded.snoozed_until,
|
|
26311
26585
|
snoozed_at = excluded.snoozed_at,
|
|
26586
|
+
pinned_at = excluded.pinned_at,
|
|
26587
|
+
pin_order_key = excluded.pin_order_key,
|
|
26312
26588
|
latest_user_message_at = excluded.latest_user_message_at,
|
|
26313
26589
|
pending_approval_count = excluded.pending_approval_count,
|
|
26314
26590
|
pending_user_input_count = excluded.pending_user_input_count,
|
|
@@ -26341,6 +26617,8 @@ const makeProjectionThreadRepository = Effect.gen(function* () {
|
|
|
26341
26617
|
settled_at AS "settledAt",
|
|
26342
26618
|
snoozed_until AS "snoozedUntil",
|
|
26343
26619
|
snoozed_at AS "snoozedAt",
|
|
26620
|
+
pinned_at AS "pinnedAt",
|
|
26621
|
+
pin_order_key AS "pinOrderKey",
|
|
26344
26622
|
latest_user_message_at AS "latestUserMessageAt",
|
|
26345
26623
|
pending_approval_count AS "pendingApprovalCount",
|
|
26346
26624
|
pending_user_input_count AS "pendingUserInputCount",
|
|
@@ -26375,6 +26653,8 @@ const makeProjectionThreadRepository = Effect.gen(function* () {
|
|
|
26375
26653
|
settled_at AS "settledAt",
|
|
26376
26654
|
snoozed_until AS "snoozedUntil",
|
|
26377
26655
|
snoozed_at AS "snoozedAt",
|
|
26656
|
+
pinned_at AS "pinnedAt",
|
|
26657
|
+
pin_order_key AS "pinOrderKey",
|
|
26378
26658
|
latest_user_message_at AS "latestUserMessageAt",
|
|
26379
26659
|
pending_approval_count AS "pendingApprovalCount",
|
|
26380
26660
|
pending_user_input_count AS "pendingUserInputCount",
|
|
@@ -26969,6 +27249,8 @@ const makeOrchestrationProjectionPipeline = Effect.fn("makeOrchestrationProjecti
|
|
|
26969
27249
|
settledAt: null,
|
|
26970
27250
|
snoozedUntil: null,
|
|
26971
27251
|
snoozedAt: null,
|
|
27252
|
+
pinnedAt: null,
|
|
27253
|
+
pinOrderKey: null,
|
|
26972
27254
|
latestUserMessageAt: null,
|
|
26973
27255
|
pendingApprovalCount: 0,
|
|
26974
27256
|
pendingUserInputCount: 0,
|
|
@@ -27042,6 +27324,38 @@ const makeOrchestrationProjectionPipeline = Effect.fn("makeOrchestrationProjecti
|
|
|
27042
27324
|
});
|
|
27043
27325
|
return;
|
|
27044
27326
|
}
|
|
27327
|
+
case "thread.pinned": {
|
|
27328
|
+
const existingRow = yield* projectionThreadRepository.getById({ threadId: event.payload.threadId });
|
|
27329
|
+
if (Option.isNone(existingRow)) return;
|
|
27330
|
+
yield* projectionThreadRepository.upsert({
|
|
27331
|
+
...existingRow.value,
|
|
27332
|
+
pinnedAt: event.payload.pinnedAt,
|
|
27333
|
+
...event.payload.pinOrderKey === void 0 ? {} : { pinOrderKey: event.payload.pinOrderKey },
|
|
27334
|
+
updatedAt: event.payload.updatedAt
|
|
27335
|
+
});
|
|
27336
|
+
return;
|
|
27337
|
+
}
|
|
27338
|
+
case "thread.unpinned": {
|
|
27339
|
+
const existingRow = yield* projectionThreadRepository.getById({ threadId: event.payload.threadId });
|
|
27340
|
+
if (Option.isNone(existingRow)) return;
|
|
27341
|
+
yield* projectionThreadRepository.upsert({
|
|
27342
|
+
...existingRow.value,
|
|
27343
|
+
pinnedAt: null,
|
|
27344
|
+
pinOrderKey: null,
|
|
27345
|
+
updatedAt: event.payload.updatedAt
|
|
27346
|
+
});
|
|
27347
|
+
return;
|
|
27348
|
+
}
|
|
27349
|
+
case "thread.pin-reordered": {
|
|
27350
|
+
const existingRow = yield* projectionThreadRepository.getById({ threadId: event.payload.threadId });
|
|
27351
|
+
if (Option.isNone(existingRow)) return;
|
|
27352
|
+
yield* projectionThreadRepository.upsert({
|
|
27353
|
+
...existingRow.value,
|
|
27354
|
+
pinOrderKey: event.payload.pinOrderKey,
|
|
27355
|
+
updatedAt: event.payload.updatedAt
|
|
27356
|
+
});
|
|
27357
|
+
return;
|
|
27358
|
+
}
|
|
27045
27359
|
case "thread.meta-updated": {
|
|
27046
27360
|
const existingRow = yield* projectionThreadRepository.getById({ threadId: event.payload.threadId });
|
|
27047
27361
|
if (Option.isNone(existingRow)) return;
|
|
@@ -27616,6 +27930,84 @@ const makeOrchestrationProjectionPipeline = Effect.fn("makeOrchestrationProjecti
|
|
|
27616
27930
|
});
|
|
27617
27931
|
const OrchestrationProjectionPipelineLive = Layer.effect(OrchestrationProjectionPipeline, makeOrchestrationProjectionPipeline()).pipe(Layer.provideMerge(ProjectionProjectRepositoryLive), Layer.provideMerge(ProjectionThreadRepositoryLive), Layer.provideMerge(ProjectionThreadMessageRepositoryLive), Layer.provideMerge(ProjectionThreadProposedPlanRepositoryLive), Layer.provideMerge(ProjectionThreadActivityRepositoryLive), Layer.provideMerge(ProjectionThreadSessionRepositoryLive), Layer.provideMerge(ProjectionTurnRepositoryLive), Layer.provideMerge(ProjectionPendingApprovalRepositoryLive), Layer.provideMerge(ProjectionStateRepositoryLive));
|
|
27618
27932
|
//#endregion
|
|
27933
|
+
//#region src/orchestration/ThreadBackgroundLiveness.ts
|
|
27934
|
+
/**
|
|
27935
|
+
* ThreadBackgroundLivenessService - in-memory per-thread background liveness
|
|
27936
|
+
* for the sidebar status pill.
|
|
27937
|
+
*
|
|
27938
|
+
* The turn can settle while native background work runs on (subagent fleets,
|
|
27939
|
+
* workflow runs, Monitor watch loops); the shell previously showed nothing.
|
|
27940
|
+
* Ingestion records task lifecycle transitions and the shell query reads the
|
|
27941
|
+
* derived state at mapping time — no persistence, no migration. After a
|
|
27942
|
+
* server restart the registry is empty until new task events arrive, which
|
|
27943
|
+
* matches reality: orphaned background work is not live.
|
|
27944
|
+
*
|
|
27945
|
+
* "monitoring" is reserved for watch loops (monitor tasks and background
|
|
27946
|
+
* shells) when they are the ONLY live work; any agent work presents as
|
|
27947
|
+
* "working".
|
|
27948
|
+
*
|
|
27949
|
+
* @module ThreadBackgroundLivenessService
|
|
27950
|
+
*/
|
|
27951
|
+
const TERMINAL_STATUSES = /* @__PURE__ */ new Set([
|
|
27952
|
+
"completed",
|
|
27953
|
+
"failed",
|
|
27954
|
+
"stopped",
|
|
27955
|
+
"cancelled",
|
|
27956
|
+
"interrupted"
|
|
27957
|
+
]);
|
|
27958
|
+
var ThreadBackgroundLivenessService = class extends Context.Service()("p4code/orchestration/ThreadBackgroundLiveness/ThreadBackgroundLivenessService") {};
|
|
27959
|
+
function make$73() {
|
|
27960
|
+
const stateByThreadId = /* @__PURE__ */ new Map();
|
|
27961
|
+
const stateFor = (threadId) => {
|
|
27962
|
+
const existing = stateByThreadId.get(threadId);
|
|
27963
|
+
if (existing) return existing;
|
|
27964
|
+
const created = {
|
|
27965
|
+
agents: /* @__PURE__ */ new Set(),
|
|
27966
|
+
monitors: /* @__PURE__ */ new Set()
|
|
27967
|
+
};
|
|
27968
|
+
stateByThreadId.set(threadId, created);
|
|
27969
|
+
return created;
|
|
27970
|
+
};
|
|
27971
|
+
const drop = (threadId, taskId) => {
|
|
27972
|
+
const state = stateByThreadId.get(threadId);
|
|
27973
|
+
if (!state) return;
|
|
27974
|
+
state.agents.delete(taskId);
|
|
27975
|
+
state.monitors.delete(taskId);
|
|
27976
|
+
if (state.agents.size === 0 && state.monitors.size === 0) stateByThreadId.delete(threadId);
|
|
27977
|
+
};
|
|
27978
|
+
return {
|
|
27979
|
+
recordTaskLiveness: (input) => {
|
|
27980
|
+
const taskType = input.taskType;
|
|
27981
|
+
if (taskType !== void 0 && INERT_TASK_TYPES.has(taskType)) {
|
|
27982
|
+
drop(input.threadId, input.taskId);
|
|
27983
|
+
return;
|
|
27984
|
+
}
|
|
27985
|
+
if (input.agentId !== void 0 && (taskType === void 0 || MONITOR_TASK_TYPES.has(taskType))) {
|
|
27986
|
+
drop(input.threadId, input.taskId);
|
|
27987
|
+
return;
|
|
27988
|
+
}
|
|
27989
|
+
if (input.kind === "completed" || input.status === "idle" || input.status !== void 0 && TERMINAL_STATUSES.has(input.status)) {
|
|
27990
|
+
drop(input.threadId, input.taskId);
|
|
27991
|
+
return;
|
|
27992
|
+
}
|
|
27993
|
+
drop(input.threadId, input.taskId);
|
|
27994
|
+
const state = stateFor(input.threadId);
|
|
27995
|
+
(taskType !== void 0 && MONITOR_TASK_TYPES.has(taskType) ? state.monitors : state.agents).add(input.taskId);
|
|
27996
|
+
},
|
|
27997
|
+
clearThreadLiveness: (threadId) => {
|
|
27998
|
+
stateByThreadId.delete(threadId);
|
|
27999
|
+
},
|
|
28000
|
+
getThreadBackgroundLiveness: (threadId) => {
|
|
28001
|
+
const state = stateByThreadId.get(threadId);
|
|
28002
|
+
if (!state) return null;
|
|
28003
|
+
if (state.agents.size > 0) return "working";
|
|
28004
|
+
if (state.monitors.size > 0) return "monitoring";
|
|
28005
|
+
return null;
|
|
28006
|
+
}
|
|
28007
|
+
};
|
|
28008
|
+
}
|
|
28009
|
+
const layer$63 = Layer.effect(ThreadBackgroundLivenessService, Effect.sync(make$73));
|
|
28010
|
+
//#endregion
|
|
27619
28011
|
//#region src/persistence/Services/ProjectionCheckpoints.ts
|
|
27620
28012
|
/**
|
|
27621
28013
|
* ProjectionCheckpointRepository - Projection repository interface for checkpoints.
|
|
@@ -28463,6 +28855,7 @@ function toPersistenceSqlOrDecodeError$1(sqlOperation, decodeOperation) {
|
|
|
28463
28855
|
const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
|
28464
28856
|
const sql = yield* SqlClient.SqlClient;
|
|
28465
28857
|
const repositoryIdentityResolver = yield* RepositoryIdentityResolver;
|
|
28858
|
+
const threadBackgroundLiveness = yield* ThreadBackgroundLivenessService;
|
|
28466
28859
|
const repositoryIdentityResolutionConcurrency = 4;
|
|
28467
28860
|
const resolveRepositoryIdentitiesForProjects = Effect.fn("ProjectionSnapshotQuery.resolveRepositoryIdentitiesForProjects")(function* (projectRows, options) {
|
|
28468
28861
|
const filteredProjectRows = options?.includeDeleted === true ? projectRows : projectRows.filter((row) => row.deletedAt === null);
|
|
@@ -28546,6 +28939,8 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
|
|
28546
28939
|
settled_at AS "settledAt",
|
|
28547
28940
|
snoozed_until AS "snoozedUntil",
|
|
28548
28941
|
snoozed_at AS "snoozedAt",
|
|
28942
|
+
pinned_at AS "pinnedAt",
|
|
28943
|
+
pin_order_key AS "pinOrderKey",
|
|
28549
28944
|
latest_user_message_at AS "latestUserMessageAt",
|
|
28550
28945
|
pending_approval_count AS "pendingApprovalCount",
|
|
28551
28946
|
pending_user_input_count AS "pendingUserInputCount",
|
|
@@ -28580,6 +28975,8 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
|
|
28580
28975
|
settled_at AS "settledAt",
|
|
28581
28976
|
snoozed_until AS "snoozedUntil",
|
|
28582
28977
|
snoozed_at AS "snoozedAt",
|
|
28978
|
+
pinned_at AS "pinnedAt",
|
|
28979
|
+
pin_order_key AS "pinOrderKey",
|
|
28583
28980
|
latest_user_message_at AS "latestUserMessageAt",
|
|
28584
28981
|
pending_approval_count AS "pendingApprovalCount",
|
|
28585
28982
|
pending_user_input_count AS "pendingUserInputCount",
|
|
@@ -28616,6 +29013,8 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
|
|
28616
29013
|
settled_at AS "settledAt",
|
|
28617
29014
|
snoozed_until AS "snoozedUntil",
|
|
28618
29015
|
snoozed_at AS "snoozedAt",
|
|
29016
|
+
pinned_at AS "pinnedAt",
|
|
29017
|
+
pin_order_key AS "pinOrderKey",
|
|
28619
29018
|
latest_user_message_at AS "latestUserMessageAt",
|
|
28620
29019
|
pending_approval_count AS "pendingApprovalCount",
|
|
28621
29020
|
pending_user_input_count AS "pendingUserInputCount",
|
|
@@ -29036,6 +29435,8 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
|
|
29036
29435
|
settled_at AS "settledAt",
|
|
29037
29436
|
snoozed_until AS "snoozedUntil",
|
|
29038
29437
|
snoozed_at AS "snoozedAt",
|
|
29438
|
+
pinned_at AS "pinnedAt",
|
|
29439
|
+
pin_order_key AS "pinOrderKey",
|
|
29039
29440
|
latest_user_message_at AS "latestUserMessageAt",
|
|
29040
29441
|
pending_approval_count AS "pendingApprovalCount",
|
|
29041
29442
|
pending_user_input_count AS "pendingUserInputCount",
|
|
@@ -29356,6 +29757,8 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
|
|
29356
29757
|
settledAt: row.settledAt,
|
|
29357
29758
|
snoozedUntil: row.snoozedUntil,
|
|
29358
29759
|
snoozedAt: row.snoozedAt,
|
|
29760
|
+
pinnedAt: row.pinnedAt,
|
|
29761
|
+
pinOrderKey: row.pinOrderKey ?? null,
|
|
29359
29762
|
deletedAt: row.deletedAt,
|
|
29360
29763
|
messages: messagesByThread.get(row.threadId) ?? [],
|
|
29361
29764
|
proposedPlans: proposedPlansByThread.get(row.threadId) ?? [],
|
|
@@ -29472,6 +29875,8 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
|
|
29472
29875
|
settledAt: row.settledAt,
|
|
29473
29876
|
snoozedUntil: row.snoozedUntil,
|
|
29474
29877
|
snoozedAt: row.snoozedAt,
|
|
29878
|
+
pinnedAt: row.pinnedAt,
|
|
29879
|
+
pinOrderKey: row.pinOrderKey ?? null,
|
|
29475
29880
|
deletedAt: row.deletedAt,
|
|
29476
29881
|
messages: [],
|
|
29477
29882
|
proposedPlans: proposedPlansByThread.get(row.threadId) ?? [],
|
|
@@ -29534,11 +29939,14 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
|
|
29534
29939
|
settledAt: row.settledAt,
|
|
29535
29940
|
snoozedUntil: row.snoozedUntil,
|
|
29536
29941
|
snoozedAt: row.snoozedAt,
|
|
29942
|
+
pinnedAt: row.pinnedAt,
|
|
29943
|
+
pinOrderKey: row.pinOrderKey ?? null,
|
|
29537
29944
|
session: sessionByThread.get(row.threadId) ?? null,
|
|
29538
29945
|
latestUserMessageAt: row.latestUserMessageAt,
|
|
29539
29946
|
hasPendingApprovals: row.pendingApprovalCount > 0,
|
|
29540
29947
|
hasPendingUserInput: row.pendingUserInputCount > 0,
|
|
29541
29948
|
hasActionableProposedPlan: row.hasActionableProposedPlan > 0,
|
|
29949
|
+
backgroundLiveness: threadBackgroundLiveness.getThreadBackgroundLiveness(row.threadId),
|
|
29542
29950
|
hasBackgroundTasks: row.backgroundTaskCount > 0,
|
|
29543
29951
|
scheduledWakeAt: row.scheduledWakeAt
|
|
29544
29952
|
}) : Result.failVoid),
|
|
@@ -29593,11 +30001,14 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
|
|
29593
30001
|
settledAt: row.settledAt,
|
|
29594
30002
|
snoozedUntil: row.snoozedUntil,
|
|
29595
30003
|
snoozedAt: row.snoozedAt,
|
|
30004
|
+
pinnedAt: row.pinnedAt,
|
|
30005
|
+
pinOrderKey: row.pinOrderKey ?? null,
|
|
29596
30006
|
session: sessionByThread.get(row.threadId) ?? null,
|
|
29597
30007
|
latestUserMessageAt: row.latestUserMessageAt,
|
|
29598
30008
|
hasPendingApprovals: row.pendingApprovalCount > 0,
|
|
29599
30009
|
hasPendingUserInput: row.pendingUserInputCount > 0,
|
|
29600
30010
|
hasActionableProposedPlan: row.hasActionableProposedPlan > 0,
|
|
30011
|
+
backgroundLiveness: threadBackgroundLiveness.getThreadBackgroundLiveness(row.threadId),
|
|
29601
30012
|
hasBackgroundTasks: row.backgroundTaskCount > 0,
|
|
29602
30013
|
scheduledWakeAt: row.scheduledWakeAt
|
|
29603
30014
|
})),
|
|
@@ -29702,11 +30113,14 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
|
|
29702
30113
|
settledAt: threadRow.value.settledAt,
|
|
29703
30114
|
snoozedUntil: threadRow.value.snoozedUntil,
|
|
29704
30115
|
snoozedAt: threadRow.value.snoozedAt,
|
|
30116
|
+
pinnedAt: threadRow.value.pinnedAt,
|
|
30117
|
+
pinOrderKey: threadRow.value.pinOrderKey ?? null,
|
|
29705
30118
|
session: Option.isSome(sessionRow) ? mapSessionRow(sessionRow.value) : null,
|
|
29706
30119
|
latestUserMessageAt: threadRow.value.latestUserMessageAt,
|
|
29707
30120
|
hasPendingApprovals: threadRow.value.pendingApprovalCount > 0,
|
|
29708
30121
|
hasPendingUserInput: threadRow.value.pendingUserInputCount > 0,
|
|
29709
30122
|
hasActionableProposedPlan: threadRow.value.hasActionableProposedPlan > 0,
|
|
30123
|
+
backgroundLiveness: threadBackgroundLiveness.getThreadBackgroundLiveness(threadRow.value.threadId),
|
|
29710
30124
|
hasBackgroundTasks: threadRow.value.backgroundTaskCount > 0,
|
|
29711
30125
|
scheduledWakeAt: threadRow.value.scheduledWakeAt
|
|
29712
30126
|
});
|
|
@@ -29743,6 +30157,8 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
|
|
29743
30157
|
settledAt: threadRow.value.settledAt,
|
|
29744
30158
|
snoozedUntil: threadRow.value.snoozedUntil,
|
|
29745
30159
|
snoozedAt: threadRow.value.snoozedAt,
|
|
30160
|
+
pinnedAt: threadRow.value.pinnedAt,
|
|
30161
|
+
pinOrderKey: threadRow.value.pinOrderKey ?? null,
|
|
29746
30162
|
deletedAt: null,
|
|
29747
30163
|
messages: messageRows.map((row) => {
|
|
29748
30164
|
const message = {
|
|
@@ -29812,7 +30228,7 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
|
|
29812
30228
|
getThreadDetailSnapshot
|
|
29813
30229
|
};
|
|
29814
30230
|
});
|
|
29815
|
-
const OrchestrationProjectionSnapshotQueryLive = Layer.effect(ProjectionSnapshotQuery, makeProjectionSnapshotQuery);
|
|
30231
|
+
const OrchestrationProjectionSnapshotQueryLive = Layer.effect(ProjectionSnapshotQuery, makeProjectionSnapshotQuery).pipe(Layer.provide(layer$63));
|
|
29816
30232
|
//#endregion
|
|
29817
30233
|
//#region src/orchestration/Services/ThreadEventStream.ts
|
|
29818
30234
|
var ThreadEventStreamService = class extends Context.Service()("@p4code/cli/orchestration/Services/ThreadEventStream/ThreadEventStreamService") {};
|
|
@@ -29871,7 +30287,14 @@ const ThreadEventStreamLive = Layer.effect(ThreadEventStreamService, makeThreadE
|
|
|
29871
30287
|
//#region src/orchestration/runtimeLayer.ts
|
|
29872
30288
|
const OrchestrationEventInfrastructureLayerLive = Layer.mergeAll(OrchestrationEventStoreLive, OrchestrationCommandReceiptRepositoryLive);
|
|
29873
30289
|
const OrchestrationProjectionPipelineLayerLive = OrchestrationProjectionPipelineLive.pipe(Layer.provide(OrchestrationEventStoreLive));
|
|
29874
|
-
|
|
30290
|
+
/**
|
|
30291
|
+
* In-memory registry of background work that outlives a turn. Exported as one
|
|
30292
|
+
* reference on purpose: the snapshot query reads liveness while provider
|
|
30293
|
+
* ingestion writes it, and layers memoize by reference, so both must receive
|
|
30294
|
+
* THIS layer or they would each get their own empty registry.
|
|
30295
|
+
*/
|
|
30296
|
+
const ThreadBackgroundLivenessLayerLive = layer$63;
|
|
30297
|
+
const OrchestrationInfrastructureLayerLive = Layer.mergeAll(OrchestrationProjectionSnapshotQueryLive, OrchestrationEventInfrastructureLayerLive, OrchestrationProjectionPipelineLayerLive, ThreadBackgroundLivenessLayerLive);
|
|
29875
30298
|
const OrchestrationEngineLayerLive = OrchestrationEngineLive.pipe(Layer.provide(OrchestrationInfrastructureLayerLive));
|
|
29876
30299
|
const OrchestrationLayerLive = Layer.mergeAll(OrchestrationInfrastructureLayerLive, OrchestrationEngineLayerLive, ThreadEventStreamLive.pipe(Layer.provide(OrchestrationEngineLayerLive)));
|
|
29877
30300
|
//#endregion
|
|
@@ -32091,6 +32514,7 @@ const make$64 = Effect.gen(function* () {
|
|
|
32091
32514
|
pullRequests: true,
|
|
32092
32515
|
threadSettlement: true,
|
|
32093
32516
|
threadSnooze: true,
|
|
32517
|
+
threadPinning: true,
|
|
32094
32518
|
...serverSelfUpdate === null ? {} : { serverSelfUpdate },
|
|
32095
32519
|
...serverServiceSupervised ? { serverServiceSupervised } : {}
|
|
32096
32520
|
}
|
|
@@ -33735,7 +34159,7 @@ const runProjectMutation = Effect.fn("runProjectMutation")(function* (flags, run
|
|
|
33735
34159
|
});
|
|
33736
34160
|
yield* Console.log(output);
|
|
33737
34161
|
}));
|
|
33738
|
-
const offlineRuntimeLayer = ProjectCliRuntimeLive.pipe(Layer.provide(layer$
|
|
34162
|
+
const offlineRuntimeLayer = ProjectCliRuntimeLive.pipe(Layer.provide(layer$80(config)), Layer.provide(Layer.succeed(References.MinimumLogLevel, minimumLogLevel)));
|
|
33739
34163
|
return yield* Effect.gen(function* () {
|
|
33740
34164
|
const snapshot = yield* getOfflineSnapshot();
|
|
33741
34165
|
const orchestrationEngine = yield* OrchestrationEngineService;
|
|
@@ -33746,7 +34170,7 @@ const runProjectMutation = Effect.fn("runProjectMutation")(function* (flags, run
|
|
|
33746
34170
|
});
|
|
33747
34171
|
yield* Console.log(output);
|
|
33748
34172
|
}).pipe(Effect.provide(offlineRuntimeLayer));
|
|
33749
|
-
}).pipe(Effect.provide(Layer.mergeAll(runtimeLayer, layer$52).pipe(Layer.provideMerge(FetchHttpClient.layer), Layer.provide(layer$
|
|
34173
|
+
}).pipe(Effect.provide(Layer.mergeAll(runtimeLayer, layer$52).pipe(Layer.provideMerge(FetchHttpClient.layer), Layer.provide(layer$80(config)), Layer.provide(Layer.succeed(References.MinimumLogLevel, minimumLogLevel)))));
|
|
33750
34174
|
});
|
|
33751
34175
|
const projectAddCommand = Command.make("add", {
|
|
33752
34176
|
...projectLocationFlags,
|
|
@@ -40506,6 +40930,24 @@ const makeLinearApiTransport = Effect.gen(function* () {
|
|
|
40506
40930
|
* @module tracker/LinearClient
|
|
40507
40931
|
*/
|
|
40508
40932
|
var LinearClient = class extends Context.Service()("@p4code/cli/tracker/LinearClient") {};
|
|
40933
|
+
/**
|
|
40934
|
+
* How much of a stored key the settings row may show.
|
|
40935
|
+
*
|
|
40936
|
+
* The prefix identifies the provider (`lin_api_`) and the suffix is enough to
|
|
40937
|
+
* tell two keys apart when one is being replaced. The bullet run is a fixed
|
|
40938
|
+
* width rather than the number of characters hidden, so the mask says nothing
|
|
40939
|
+
* about how long the key is.
|
|
40940
|
+
*/
|
|
40941
|
+
const MASK_PREFIX_CHARS = 8;
|
|
40942
|
+
const MASK_BULLETS = "•".repeat(8);
|
|
40943
|
+
/**
|
|
40944
|
+
* A stored key rendered for display, never for use.
|
|
40945
|
+
*
|
|
40946
|
+
* A key too short to reveal both ends without meeting in the middle is shown
|
|
40947
|
+
* as bullets alone: a mask that gives away most of a short key is worse than
|
|
40948
|
+
* one that gives away nothing.
|
|
40949
|
+
*/
|
|
40950
|
+
const maskApiKey = (apiKey) => apiKey.length > 12 ? `${apiKey.slice(0, MASK_PREFIX_CHARS)}${MASK_BULLETS}${apiKey.slice(-4)}` : MASK_BULLETS;
|
|
40509
40951
|
const makeLinearClient = Effect.gen(function* () {
|
|
40510
40952
|
const secrets = yield* TrackerSecrets;
|
|
40511
40953
|
const api = yield* makeLinearApiTransport;
|
|
@@ -40524,12 +40966,14 @@ const makeLinearClient = Effect.gen(function* () {
|
|
|
40524
40966
|
if (Option.isSome(credential)) return {
|
|
40525
40967
|
provider: "linear",
|
|
40526
40968
|
mode: "api",
|
|
40527
|
-
workspace: credential.value.workspace
|
|
40969
|
+
workspace: credential.value.workspace,
|
|
40970
|
+
maskedKey: maskApiKey(credential.value.apiKey)
|
|
40528
40971
|
};
|
|
40529
40972
|
return {
|
|
40530
40973
|
provider: "linear",
|
|
40531
40974
|
mode: (yield* mcp.isConfigured) ? "mcp" : "none",
|
|
40532
|
-
workspace: null
|
|
40975
|
+
workspace: null,
|
|
40976
|
+
maskedKey: null
|
|
40533
40977
|
};
|
|
40534
40978
|
});
|
|
40535
40979
|
const setApiKey = (apiKey) => Effect.gen(function* () {
|
|
@@ -42436,8 +42880,32 @@ const resolveClaudeHomePath = Effect.fn("resolveClaudeHomePath")(function* (conf
|
|
|
42436
42880
|
const homePath = config.homePath.trim();
|
|
42437
42881
|
return path.resolve(homePath.length > 0 ? expandHomePath$3(homePath) : NodeOS.homedir());
|
|
42438
42882
|
});
|
|
42883
|
+
/**
|
|
42884
|
+
* The macOS login keychain stores the CLI's OAuth credentials under the account
|
|
42885
|
+
* name in `USER`. A server started outside a login shell — a desktop app
|
|
42886
|
+
* launched from Finder, a launchd job — can hand the child an environment
|
|
42887
|
+
* without it, and the CLI then reports no subscription at all rather than
|
|
42888
|
+
* failing: `/usage` quietly answers with the session cost report instead of the
|
|
42889
|
+
* account's limits. Filling the name back in keeps the lookup working.
|
|
42890
|
+
*/
|
|
42891
|
+
function withProcessUserName(env) {
|
|
42892
|
+
if (env.USER?.trim() && env.LOGNAME?.trim()) return env;
|
|
42893
|
+
const username = (() => {
|
|
42894
|
+
try {
|
|
42895
|
+
return NodeOS.userInfo().username;
|
|
42896
|
+
} catch {
|
|
42897
|
+
return "";
|
|
42898
|
+
}
|
|
42899
|
+
})();
|
|
42900
|
+
if (username.length === 0) return env;
|
|
42901
|
+
return {
|
|
42902
|
+
...env,
|
|
42903
|
+
...env.USER?.trim() ? {} : { USER: username },
|
|
42904
|
+
...env.LOGNAME?.trim() ? {} : { LOGNAME: username }
|
|
42905
|
+
};
|
|
42906
|
+
}
|
|
42439
42907
|
const makeClaudeEnvironment = Effect.fn("makeClaudeEnvironment")(function* (config, baseEnv) {
|
|
42440
|
-
const resolvedBaseEnv = baseEnv ?? process.env;
|
|
42908
|
+
const resolvedBaseEnv = withProcessUserName(baseEnv ?? process.env);
|
|
42441
42909
|
if (config.homePath.trim().length === 0) return resolvedBaseEnv;
|
|
42442
42910
|
const resolvedHomePath = yield* resolveClaudeHomePath(config);
|
|
42443
42911
|
return {
|
|
@@ -64555,7 +65023,7 @@ const makeOpenCodeRuntime = Effect.gen(function* () {
|
|
|
64555
65023
|
};
|
|
64556
65024
|
});
|
|
64557
65025
|
var OpenCodeRuntime = class extends Context.Service()("@p4code/cli/provider/opencodeRuntime") {};
|
|
64558
|
-
const OpenCodeRuntimeLive = Layer.effect(OpenCodeRuntime, makeOpenCodeRuntime).pipe(Layer.provide(layer$
|
|
65026
|
+
const OpenCodeRuntimeLive = Layer.effect(OpenCodeRuntime, makeOpenCodeRuntime).pipe(Layer.provide(layer$81));
|
|
64559
65027
|
//#endregion
|
|
64560
65028
|
//#region src/textGeneration/TextGenerationUtils.ts
|
|
64561
65029
|
const isTextGenerationError$3 = Schema$1.is(TextGenerationError);
|
|
@@ -65663,7 +66131,7 @@ const makePendingClaudeProvider = (claudeSettings) => Effect.gen(function* () {
|
|
|
65663
66131
|
*/
|
|
65664
66132
|
const CLAUDE_TIMEOUT_MS = 18e4;
|
|
65665
66133
|
/** The usage report is a local lookup, so it should return in seconds, not minutes. */
|
|
65666
|
-
const USAGE_REPORT_TIMEOUT_MS = 6e4;
|
|
66134
|
+
const USAGE_REPORT_TIMEOUT_MS$1 = 6e4;
|
|
65667
66135
|
/**
|
|
65668
66136
|
* Schema for the wrapper JSON returned by `claude -p --output-format json`.
|
|
65669
66137
|
* We only care about `structured_output`.
|
|
@@ -65674,6 +66142,16 @@ const ClaudeOutputEnvelope = Schema$1.Struct({ structured_output: Schema$1.Unkno
|
|
|
65674
66142
|
* CLI-local command, so this costs no turn and no tokens.
|
|
65675
66143
|
*/
|
|
65676
66144
|
const ClaudeResultEnvelope = Schema$1.Struct({ result: Schema$1.String });
|
|
66145
|
+
const USAGE_LIMIT_LINE = /^.+:\s+\d+(?:\.\d+)?%\s+used/mu;
|
|
66146
|
+
/**
|
|
66147
|
+
* When the CLI cannot resolve the account behind its config directory it does
|
|
66148
|
+
* not fail: it prints the session's own cost summary — all zeroes for a
|
|
66149
|
+
* one-shot run — in place of the account's limits. Only a report that carries a
|
|
66150
|
+
* limit line is the report that was asked for.
|
|
66151
|
+
*/
|
|
66152
|
+
function isClaudeUsageReport(report) {
|
|
66153
|
+
return USAGE_LIMIT_LINE.test(report);
|
|
66154
|
+
}
|
|
65677
66155
|
const encodeJsonString$2 = Schema$1.encodeEffect(Schema$1.UnknownFromJsonString);
|
|
65678
66156
|
const decodeClaudeOutputEnvelope = Schema$1.decodeEffect(Schema$1.fromJsonString(ClaudeOutputEnvelope));
|
|
65679
66157
|
const decodeClaudeResultEnvelope = Schema$1.decodeEffect(Schema$1.fromJsonString(ClaudeResultEnvelope));
|
|
@@ -65861,18 +66339,23 @@ const makeClaudeTextGeneration = Effect.fn("makeClaudeTextGeneration")(function*
|
|
|
65861
66339
|
});
|
|
65862
66340
|
}
|
|
65863
66341
|
return stdout;
|
|
65864
|
-
})().pipe(Effect.scoped, Effect.timeoutOption(USAGE_REPORT_TIMEOUT_MS), Effect.flatMap(Option.match({
|
|
66342
|
+
})().pipe(Effect.scoped, Effect.timeoutOption(USAGE_REPORT_TIMEOUT_MS$1), Effect.flatMap(Option.match({
|
|
65865
66343
|
onNone: () => Effect.fail(new TextGenerationError({
|
|
65866
66344
|
operation,
|
|
65867
66345
|
detail: "Claude CLI request timed out."
|
|
65868
66346
|
})),
|
|
65869
66347
|
onSome: (value) => Effect.succeed(value)
|
|
65870
66348
|
})));
|
|
65871
|
-
|
|
66349
|
+
const report = (yield* decodeClaudeResultEnvelope(rawStdout).pipe(Effect.catchTags({ SchemaError: (cause) => Effect.fail(new TextGenerationError({
|
|
65872
66350
|
operation,
|
|
65873
66351
|
detail: "Claude CLI returned unexpected output format.",
|
|
65874
66352
|
cause
|
|
65875
|
-
})) }))).result.trim()
|
|
66353
|
+
})) }))).result.trim();
|
|
66354
|
+
if (!isClaudeUsageReport(report)) return yield* new TextGenerationError({
|
|
66355
|
+
operation,
|
|
66356
|
+
detail: "Claude CLI answered with its session cost summary instead of the account report. That means it could not read the subscription behind its config directory - run `claude /login` for this instance's CLAUDE_CONFIG_DIR and try again."
|
|
66357
|
+
});
|
|
66358
|
+
return { report };
|
|
65876
66359
|
})
|
|
65877
66360
|
};
|
|
65878
66361
|
});
|
|
@@ -69144,529 +69627,6 @@ const ClaudeDriver = {
|
|
|
69144
69627
|
};
|
|
69145
69628
|
})
|
|
69146
69629
|
};
|
|
69147
|
-
const resolveCodexLaunchArgs = (launchArgs, environment = process.env) => environment["P4CODE_CODEX_LAUNCH_ARGS"]?.trim() || launchArgs?.trim() || "";
|
|
69148
|
-
const codexLaunchArgv = (launchArgs) => tokenizeCliArgs(launchArgs);
|
|
69149
|
-
const codexAppServerArgs = (launchArgs) => ["app-server", ...codexLaunchArgv(launchArgs)];
|
|
69150
|
-
const codexExecLaunchArgs = (launchArgs) => {
|
|
69151
|
-
const args = codexLaunchArgv(launchArgs);
|
|
69152
|
-
const execArgs = [];
|
|
69153
|
-
for (let index = 0; index < args.length; index++) {
|
|
69154
|
-
const arg = args[index];
|
|
69155
|
-
if (arg === void 0) continue;
|
|
69156
|
-
if (arg === "--strict-config" || arg.startsWith("--config=") || arg.startsWith("-c=")) execArgs.push(arg);
|
|
69157
|
-
else if (arg === "--config" || arg === "-c" || arg === "--enable" || arg === "--disable") {
|
|
69158
|
-
const value = args[index + 1];
|
|
69159
|
-
if (value !== void 0 && !value.startsWith("-")) {
|
|
69160
|
-
execArgs.push(arg, value);
|
|
69161
|
-
index++;
|
|
69162
|
-
}
|
|
69163
|
-
} else if (arg.startsWith("--enable=") || arg.startsWith("--disable=")) execArgs.push(arg);
|
|
69164
|
-
}
|
|
69165
|
-
return execArgs;
|
|
69166
|
-
};
|
|
69167
|
-
const codexSessionAppServerArgs = (appServerArgs, launchArgs) => {
|
|
69168
|
-
const launchAppServerArgs = codexAppServerArgs(launchArgs);
|
|
69169
|
-
return appServerArgs ? [...launchAppServerArgs, ...appServerArgs] : launchAppServerArgs;
|
|
69170
|
-
};
|
|
69171
|
-
//#endregion
|
|
69172
|
-
//#region src/codexModelOptions.ts
|
|
69173
|
-
function getCodexServiceTierOptionValue(modelSelection) {
|
|
69174
|
-
return getModelSelectionStringOptionValue(modelSelection, "serviceTier") ?? (getModelSelectionBooleanOptionValue(modelSelection, "fastMode") === true ? "fast" : void 0);
|
|
69175
|
-
}
|
|
69176
|
-
//#endregion
|
|
69177
|
-
//#region src/textGeneration/CodexTextGeneration.ts
|
|
69178
|
-
const CODEX_GIT_TEXT_GENERATION_REASONING_EFFORT = "low";
|
|
69179
|
-
const CODEX_TIMEOUT_MS = 18e4;
|
|
69180
|
-
const encodeJsonString$1 = Schema$1.encodeEffect(Schema$1.UnknownFromJsonString);
|
|
69181
|
-
/**
|
|
69182
|
-
* Build a Codex text-generation closure bound to a specific `CodexSettings`
|
|
69183
|
-
* payload. See `makeCodexAdapter` for the overall per-instance rationale.
|
|
69184
|
-
*/
|
|
69185
|
-
const makeCodexTextGeneration = Effect.fn("makeCodexTextGeneration")(function* (codexConfig, environment) {
|
|
69186
|
-
const fileSystem = yield* FileSystem.FileSystem;
|
|
69187
|
-
const path = yield* Path.Path;
|
|
69188
|
-
const commandSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
|
|
69189
|
-
const serverConfig = yield* Effect.service(ServerConfig$1);
|
|
69190
|
-
const resolvedEnvironment = environment ?? process.env;
|
|
69191
|
-
const readStreamAsString = (operation, stream) => stream.pipe(Stream.decodeText(), Stream.runFold(() => "", (acc, chunk) => acc + chunk), Effect.mapError((cause) => normalizeCliError("codex", operation, cause, "Failed to collect process output")));
|
|
69192
|
-
const writeTempFile = (operation, prefix, content) => fileSystem.makeTempFileScoped({ prefix: `p4code-${prefix}-${process.pid}-` }).pipe(Effect.tap((filePath) => fileSystem.writeFileString(filePath, content)), Effect.mapError((cause) => new TextGenerationError({
|
|
69193
|
-
operation,
|
|
69194
|
-
detail: `Failed to write temp file`,
|
|
69195
|
-
cause
|
|
69196
|
-
})));
|
|
69197
|
-
const safeUnlink = (filePath) => fileSystem.remove(filePath).pipe(Effect.catch(() => Effect.void));
|
|
69198
|
-
const encodeJsonForOperation = (operation, value) => encodeJsonString$1(value).pipe(Effect.mapError((cause) => new TextGenerationError({
|
|
69199
|
-
operation,
|
|
69200
|
-
detail: "Failed to encode structured output schema.",
|
|
69201
|
-
cause
|
|
69202
|
-
})));
|
|
69203
|
-
const materializeImageAttachments = Effect.fn("materializeImageAttachments")(function* (_operation, attachments) {
|
|
69204
|
-
if (!attachments || attachments.length === 0) return { imagePaths: [] };
|
|
69205
|
-
const imagePaths = [];
|
|
69206
|
-
for (const attachment of attachments) {
|
|
69207
|
-
if (attachment.type !== "image") continue;
|
|
69208
|
-
const resolvedPath = resolveAttachmentPath({
|
|
69209
|
-
attachmentsDir: serverConfig.attachmentsDir,
|
|
69210
|
-
attachment
|
|
69211
|
-
});
|
|
69212
|
-
if (!resolvedPath || !path.isAbsolute(resolvedPath)) continue;
|
|
69213
|
-
const fileInfo = yield* fileSystem.stat(resolvedPath).pipe(Effect.orElseSucceed(() => null));
|
|
69214
|
-
if (!fileInfo || fileInfo.type !== "File") continue;
|
|
69215
|
-
imagePaths.push(resolvedPath);
|
|
69216
|
-
}
|
|
69217
|
-
return { imagePaths };
|
|
69218
|
-
});
|
|
69219
|
-
const runCodexJson = Effect.fn("runCodexJson")(function* ({ operation, cwd, prompt, outputSchemaJson, imagePaths = [], cleanupPaths = [], modelSelection }) {
|
|
69220
|
-
const schemaJson = yield* encodeJsonForOperation(operation, toJsonSchemaObject(outputSchemaJson));
|
|
69221
|
-
const schemaPath = yield* writeTempFile(operation, "codex-schema", schemaJson);
|
|
69222
|
-
const outputPath = yield* writeTempFile(operation, "codex-output", "");
|
|
69223
|
-
const runCodexCommand = Effect.fn("runCodexJson.runCodexCommand")(function* () {
|
|
69224
|
-
const launchArgs = resolveCodexLaunchArgs(codexConfig.launchArgs, resolvedEnvironment);
|
|
69225
|
-
const reasoningEffort = getModelSelectionStringOptionValue(modelSelection, "reasoningEffort") ?? CODEX_GIT_TEXT_GENERATION_REASONING_EFFORT;
|
|
69226
|
-
const serviceTier = getCodexServiceTierOptionValue(modelSelection);
|
|
69227
|
-
const spawnCommand = yield* resolveSpawnCommand(codexConfig.binaryPath || "codex", [
|
|
69228
|
-
"exec",
|
|
69229
|
-
...codexExecLaunchArgs(launchArgs),
|
|
69230
|
-
"--ephemeral",
|
|
69231
|
-
"--skip-git-repo-check",
|
|
69232
|
-
"-s",
|
|
69233
|
-
"read-only",
|
|
69234
|
-
"--model",
|
|
69235
|
-
modelSelection.model,
|
|
69236
|
-
"--config",
|
|
69237
|
-
`model_reasoning_effort="${reasoningEffort}"`,
|
|
69238
|
-
...serviceTier ? ["--config", `service_tier="${serviceTier}"`] : [],
|
|
69239
|
-
"--output-schema",
|
|
69240
|
-
schemaPath,
|
|
69241
|
-
"--output-last-message",
|
|
69242
|
-
outputPath,
|
|
69243
|
-
...imagePaths.flatMap((imagePath) => ["--image", imagePath]),
|
|
69244
|
-
"-"
|
|
69245
|
-
], { env: resolvedEnvironment });
|
|
69246
|
-
const command = ChildProcess.make(spawnCommand.command, spawnCommand.args, {
|
|
69247
|
-
env: {
|
|
69248
|
-
...resolvedEnvironment,
|
|
69249
|
-
...codexConfig.homePath ? { CODEX_HOME: expandHomePath$3(codexConfig.homePath) } : {}
|
|
69250
|
-
},
|
|
69251
|
-
cwd,
|
|
69252
|
-
shell: spawnCommand.shell,
|
|
69253
|
-
stdin: { stream: Stream.encodeText(Stream.make(prompt)) }
|
|
69254
|
-
});
|
|
69255
|
-
const child = yield* commandSpawner.spawn(command).pipe(Effect.mapError((cause) => normalizeCliError("codex", operation, cause, "Failed to spawn Codex CLI process")));
|
|
69256
|
-
const [stdout, stderr, exitCode] = yield* Effect.all([
|
|
69257
|
-
readStreamAsString(operation, child.stdout),
|
|
69258
|
-
readStreamAsString(operation, child.stderr),
|
|
69259
|
-
child.exitCode.pipe(Effect.mapError((cause) => normalizeCliError("codex", operation, cause, "Failed to read Codex CLI exit code")))
|
|
69260
|
-
], { concurrency: "unbounded" });
|
|
69261
|
-
if (exitCode !== 0) {
|
|
69262
|
-
const stderrDetail = stderr.trim();
|
|
69263
|
-
const stdoutDetail = stdout.trim();
|
|
69264
|
-
const detail = stderrDetail.length > 0 ? stderrDetail : stdoutDetail;
|
|
69265
|
-
return yield* new TextGenerationError({
|
|
69266
|
-
operation,
|
|
69267
|
-
detail: detail.length > 0 ? `Codex CLI command failed: ${detail}` : `Codex CLI command failed with code ${exitCode}.`
|
|
69268
|
-
});
|
|
69269
|
-
}
|
|
69270
|
-
});
|
|
69271
|
-
const cleanup = Effect.all([
|
|
69272
|
-
schemaPath,
|
|
69273
|
-
outputPath,
|
|
69274
|
-
...cleanupPaths
|
|
69275
|
-
].map((filePath) => safeUnlink(filePath)), { concurrency: "unbounded" }).pipe(Effect.asVoid);
|
|
69276
|
-
return yield* Effect.gen(function* () {
|
|
69277
|
-
yield* runCodexCommand().pipe(Effect.scoped, Effect.timeoutOption(CODEX_TIMEOUT_MS), Effect.flatMap(Option.match({
|
|
69278
|
-
onNone: () => Effect.fail(new TextGenerationError({
|
|
69279
|
-
operation,
|
|
69280
|
-
detail: "Codex CLI request timed out."
|
|
69281
|
-
})),
|
|
69282
|
-
onSome: () => Effect.void
|
|
69283
|
-
})));
|
|
69284
|
-
const decodeOutput = Schema$1.decodeEffect(Schema$1.fromJsonString(outputSchemaJson));
|
|
69285
|
-
return yield* fileSystem.readFileString(outputPath).pipe(Effect.mapError((cause) => new TextGenerationError({
|
|
69286
|
-
operation,
|
|
69287
|
-
detail: "Failed to read Codex output file.",
|
|
69288
|
-
cause
|
|
69289
|
-
})), Effect.flatMap(decodeOutput), Effect.catchTags({ SchemaError: (cause) => Effect.fail(new TextGenerationError({
|
|
69290
|
-
operation,
|
|
69291
|
-
detail: "Codex returned invalid structured output.",
|
|
69292
|
-
cause
|
|
69293
|
-
})) }));
|
|
69294
|
-
}).pipe(Effect.ensuring(cleanup));
|
|
69295
|
-
});
|
|
69296
|
-
return {
|
|
69297
|
-
generateCommitMessage: Effect.fn("CodexTextGeneration.generateCommitMessage")(function* (input) {
|
|
69298
|
-
const { prompt, outputSchema } = buildCommitMessagePrompt({
|
|
69299
|
-
branch: input.branch,
|
|
69300
|
-
stagedSummary: input.stagedSummary,
|
|
69301
|
-
stagedPatch: input.stagedPatch,
|
|
69302
|
-
includeBranch: input.includeBranch === true,
|
|
69303
|
-
policy: input.policy
|
|
69304
|
-
});
|
|
69305
|
-
const generated = yield* runCodexJson({
|
|
69306
|
-
operation: "generateCommitMessage",
|
|
69307
|
-
cwd: input.cwd,
|
|
69308
|
-
prompt,
|
|
69309
|
-
outputSchemaJson: outputSchema,
|
|
69310
|
-
modelSelection: input.modelSelection
|
|
69311
|
-
});
|
|
69312
|
-
return {
|
|
69313
|
-
subject: sanitizeCommitSubject(generated.subject),
|
|
69314
|
-
body: generated.body.trim(),
|
|
69315
|
-
..."branch" in generated && typeof generated.branch === "string" ? { branch: sanitizeFeatureBranchName(generated.branch) } : {}
|
|
69316
|
-
};
|
|
69317
|
-
}),
|
|
69318
|
-
generatePrContent: Effect.fn("CodexTextGeneration.generatePrContent")(function* (input) {
|
|
69319
|
-
const { prompt, outputSchema } = buildPrContentPrompt({
|
|
69320
|
-
baseBranch: input.baseBranch,
|
|
69321
|
-
headBranch: input.headBranch,
|
|
69322
|
-
commitSummary: input.commitSummary,
|
|
69323
|
-
diffSummary: input.diffSummary,
|
|
69324
|
-
diffPatch: input.diffPatch,
|
|
69325
|
-
policy: input.policy,
|
|
69326
|
-
changeRequestTemplate: input.changeRequestTemplate
|
|
69327
|
-
});
|
|
69328
|
-
const generated = yield* runCodexJson({
|
|
69329
|
-
operation: "generatePrContent",
|
|
69330
|
-
cwd: input.cwd,
|
|
69331
|
-
prompt,
|
|
69332
|
-
outputSchemaJson: outputSchema,
|
|
69333
|
-
modelSelection: input.modelSelection
|
|
69334
|
-
});
|
|
69335
|
-
return {
|
|
69336
|
-
title: sanitizePrTitle(generated.title),
|
|
69337
|
-
body: generated.body.trim()
|
|
69338
|
-
};
|
|
69339
|
-
}),
|
|
69340
|
-
generateBranchName: Effect.fn("CodexTextGeneration.generateBranchName")(function* (input) {
|
|
69341
|
-
const { imagePaths } = yield* materializeImageAttachments("generateBranchName", input.attachments);
|
|
69342
|
-
const { prompt, outputSchema } = buildBranchNamePrompt({
|
|
69343
|
-
message: input.message,
|
|
69344
|
-
attachments: input.attachments
|
|
69345
|
-
});
|
|
69346
|
-
return { branch: sanitizeBranchFragment((yield* runCodexJson({
|
|
69347
|
-
operation: "generateBranchName",
|
|
69348
|
-
cwd: input.cwd,
|
|
69349
|
-
prompt,
|
|
69350
|
-
outputSchemaJson: outputSchema,
|
|
69351
|
-
imagePaths,
|
|
69352
|
-
modelSelection: input.modelSelection
|
|
69353
|
-
})).branch) };
|
|
69354
|
-
}),
|
|
69355
|
-
generateThreadTitle: Effect.fn("CodexTextGeneration.generateThreadTitle")(function* (input) {
|
|
69356
|
-
const { imagePaths } = yield* materializeImageAttachments("generateThreadTitle", input.attachments);
|
|
69357
|
-
const { prompt, outputSchema } = buildThreadTitlePrompt({
|
|
69358
|
-
message: input.message,
|
|
69359
|
-
attachments: input.attachments
|
|
69360
|
-
});
|
|
69361
|
-
return { title: sanitizeThreadTitle((yield* runCodexJson({
|
|
69362
|
-
operation: "generateThreadTitle",
|
|
69363
|
-
cwd: input.cwd,
|
|
69364
|
-
prompt,
|
|
69365
|
-
outputSchemaJson: outputSchema,
|
|
69366
|
-
imagePaths,
|
|
69367
|
-
modelSelection: input.modelSelection
|
|
69368
|
-
})).title) };
|
|
69369
|
-
})
|
|
69370
|
-
};
|
|
69371
|
-
});
|
|
69372
|
-
//#endregion
|
|
69373
|
-
//#region ../../packages/effect-codex-app-server/src/errors.ts
|
|
69374
|
-
const CodexAppServerRequestOperation = Schema$1.Literals([
|
|
69375
|
-
"decode-payload",
|
|
69376
|
-
"encode-payload",
|
|
69377
|
-
"handle-request",
|
|
69378
|
-
"receive-response"
|
|
69379
|
-
]);
|
|
69380
|
-
const CodexAppServerSchemaIssueKind = Schema$1.Literals([
|
|
69381
|
-
"Filter",
|
|
69382
|
-
"Encoding",
|
|
69383
|
-
"Pointer",
|
|
69384
|
-
"Composite",
|
|
69385
|
-
"AnyOf",
|
|
69386
|
-
"InvalidType",
|
|
69387
|
-
"InvalidValue",
|
|
69388
|
-
"MissingKey",
|
|
69389
|
-
"UnexpectedKey",
|
|
69390
|
-
"Forbidden",
|
|
69391
|
-
"OneOf"
|
|
69392
|
-
]);
|
|
69393
|
-
const schemaIssueDiagnostics$1 = (root) => {
|
|
69394
|
-
let issueCount = 0;
|
|
69395
|
-
let maximumPathDepth = 0;
|
|
69396
|
-
const issueKinds = /* @__PURE__ */ new Set();
|
|
69397
|
-
const visit = (issue, pathDepth) => {
|
|
69398
|
-
issueCount += 1;
|
|
69399
|
-
issueKinds.add(issue._tag);
|
|
69400
|
-
maximumPathDepth = Math.max(maximumPathDepth, pathDepth);
|
|
69401
|
-
switch (issue._tag) {
|
|
69402
|
-
case "Filter":
|
|
69403
|
-
case "Encoding":
|
|
69404
|
-
visit(issue.issue, pathDepth);
|
|
69405
|
-
break;
|
|
69406
|
-
case "Pointer":
|
|
69407
|
-
visit(issue.issue, pathDepth + issue.path.length);
|
|
69408
|
-
break;
|
|
69409
|
-
case "Composite":
|
|
69410
|
-
case "AnyOf":
|
|
69411
|
-
for (const child of issue.issues) visit(child, pathDepth);
|
|
69412
|
-
break;
|
|
69413
|
-
}
|
|
69414
|
-
};
|
|
69415
|
-
visit(root, 0);
|
|
69416
|
-
return {
|
|
69417
|
-
issueCount,
|
|
69418
|
-
issueKinds: [...issueKinds],
|
|
69419
|
-
maximumPathDepth
|
|
69420
|
-
};
|
|
69421
|
-
};
|
|
69422
|
-
const CodexAppServerPayloadKind = Schema$1.Literals([
|
|
69423
|
-
"null",
|
|
69424
|
-
"array",
|
|
69425
|
-
"string",
|
|
69426
|
-
"number",
|
|
69427
|
-
"boolean",
|
|
69428
|
-
"bigint",
|
|
69429
|
-
"object",
|
|
69430
|
-
"symbol",
|
|
69431
|
-
"function",
|
|
69432
|
-
"undefined"
|
|
69433
|
-
]);
|
|
69434
|
-
const payloadKind = (payload) => {
|
|
69435
|
-
if (payload === null) return "null";
|
|
69436
|
-
if (Array.isArray(payload)) return "array";
|
|
69437
|
-
return typeof payload;
|
|
69438
|
-
};
|
|
69439
|
-
const protocolMessageFields = [
|
|
69440
|
-
"id",
|
|
69441
|
-
"method",
|
|
69442
|
-
"params",
|
|
69443
|
-
"result",
|
|
69444
|
-
"error"
|
|
69445
|
-
];
|
|
69446
|
-
const CodexAppServerProtocolMessageField = Schema$1.Literals(protocolMessageFields);
|
|
69447
|
-
const CodexAppServerProtocolParseOperation = Schema$1.Literals([
|
|
69448
|
-
"encode-wire-message",
|
|
69449
|
-
"decode-wire-message",
|
|
69450
|
-
"route-wire-message",
|
|
69451
|
-
"decode-notification-payload",
|
|
69452
|
-
"decode-request-payload",
|
|
69453
|
-
"decode-response-payload"
|
|
69454
|
-
]);
|
|
69455
|
-
const CodexAppServerTransportOperation = Schema$1.Literals(["read-input-stream", "read-process-exit-status"]);
|
|
69456
|
-
const CodexAppServerIdentifierPurpose = Schema$1.Literals([
|
|
69457
|
-
"provider-event",
|
|
69458
|
-
"command-approval-request",
|
|
69459
|
-
"file-change-approval-request",
|
|
69460
|
-
"user-input-request"
|
|
69461
|
-
]);
|
|
69462
|
-
var CodexAppServerSpawnError = class extends Schema$1.TaggedErrorClass()("CodexAppServerSpawnError", {
|
|
69463
|
-
command: Schema$1.optional(Schema$1.String),
|
|
69464
|
-
cause: Schema$1.Defect()
|
|
69465
|
-
}) {
|
|
69466
|
-
get message() {
|
|
69467
|
-
return this.command ? `Failed to spawn Codex App Server process for command: ${this.command}` : "Failed to spawn Codex App Server process";
|
|
69468
|
-
}
|
|
69469
|
-
};
|
|
69470
|
-
var CodexAppServerProcessExitedError = class extends Schema$1.TaggedErrorClass()("CodexAppServerProcessExitedError", {
|
|
69471
|
-
code: Schema$1.optional(Schema$1.Number),
|
|
69472
|
-
pid: Schema$1.optionalKey(Schema$1.Int),
|
|
69473
|
-
cause: Schema$1.optional(Schema$1.Defect())
|
|
69474
|
-
}) {
|
|
69475
|
-
get message() {
|
|
69476
|
-
return this.code === void 0 ? "Codex App Server process exited" : `Codex App Server process exited with code ${this.code}`;
|
|
69477
|
-
}
|
|
69478
|
-
};
|
|
69479
|
-
var CodexAppServerProtocolParseError = class CodexAppServerProtocolParseError extends Schema$1.TaggedErrorClass()("CodexAppServerProtocolParseError", {
|
|
69480
|
-
operation: CodexAppServerProtocolParseOperation,
|
|
69481
|
-
method: Schema$1.optionalKey(Schema$1.String),
|
|
69482
|
-
requestId: Schema$1.optionalKey(Schema$1.String),
|
|
69483
|
-
payloadKind: Schema$1.optionalKey(CodexAppServerPayloadKind),
|
|
69484
|
-
presentFields: Schema$1.optionalKey(Schema$1.Array(CodexAppServerProtocolMessageField)),
|
|
69485
|
-
issueCount: Schema$1.optionalKey(Schema$1.Number),
|
|
69486
|
-
issueKinds: Schema$1.optionalKey(Schema$1.Array(CodexAppServerSchemaIssueKind)),
|
|
69487
|
-
maximumPathDepth: Schema$1.optionalKey(Schema$1.Number),
|
|
69488
|
-
cause: Schema$1.optional(Schema$1.Defect())
|
|
69489
|
-
}) {
|
|
69490
|
-
get message() {
|
|
69491
|
-
const method = this.method === void 0 ? "" : ` for method '${this.method}'`;
|
|
69492
|
-
return `Codex App Server protocol operation '${this.operation}' failed${method}.`;
|
|
69493
|
-
}
|
|
69494
|
-
static fromSchemaError(operation, cause, context = {}) {
|
|
69495
|
-
return new CodexAppServerProtocolParseError({
|
|
69496
|
-
operation,
|
|
69497
|
-
...context,
|
|
69498
|
-
...schemaIssueDiagnostics$1(cause.issue),
|
|
69499
|
-
cause
|
|
69500
|
-
});
|
|
69501
|
-
}
|
|
69502
|
-
static fromRequestError(operation, method, cause) {
|
|
69503
|
-
return new CodexAppServerProtocolParseError({
|
|
69504
|
-
operation,
|
|
69505
|
-
method,
|
|
69506
|
-
...cause.issueCount === void 0 ? {} : { issueCount: cause.issueCount },
|
|
69507
|
-
...cause.issueKinds === void 0 ? {} : { issueKinds: cause.issueKinds },
|
|
69508
|
-
...cause.maximumPathDepth === void 0 ? {} : { maximumPathDepth: cause.maximumPathDepth },
|
|
69509
|
-
cause
|
|
69510
|
-
});
|
|
69511
|
-
}
|
|
69512
|
-
static fromUnroutableMessage(message) {
|
|
69513
|
-
const diagnostics = { payloadKind: payloadKind(message) };
|
|
69514
|
-
if (typeof message !== "object" || message === null || Array.isArray(message)) return new CodexAppServerProtocolParseError({
|
|
69515
|
-
operation: "route-wire-message",
|
|
69516
|
-
...diagnostics
|
|
69517
|
-
});
|
|
69518
|
-
const presentFields = protocolMessageFields.filter((field) => field in message);
|
|
69519
|
-
const method = "method" in message && typeof message.method === "string" ? message.method : void 0;
|
|
69520
|
-
const requestId = "id" in message && (typeof message.id === "string" || typeof message.id === "number") ? String(message.id) : void 0;
|
|
69521
|
-
return new CodexAppServerProtocolParseError({
|
|
69522
|
-
operation: "route-wire-message",
|
|
69523
|
-
...diagnostics,
|
|
69524
|
-
presentFields,
|
|
69525
|
-
...method === void 0 ? {} : { method },
|
|
69526
|
-
...requestId === void 0 ? {} : { requestId }
|
|
69527
|
-
});
|
|
69528
|
-
}
|
|
69529
|
-
};
|
|
69530
|
-
var CodexAppServerTransportError = class extends Schema$1.TaggedErrorClass()("CodexAppServerTransportError", {
|
|
69531
|
-
operation: CodexAppServerTransportOperation,
|
|
69532
|
-
pid: Schema$1.optionalKey(Schema$1.Int),
|
|
69533
|
-
cause: Schema$1.Defect()
|
|
69534
|
-
}) {
|
|
69535
|
-
get message() {
|
|
69536
|
-
return `Codex App Server transport operation '${this.operation}' failed.`;
|
|
69537
|
-
}
|
|
69538
|
-
};
|
|
69539
|
-
var CodexAppServerIdentifierGenerationError = class extends Schema$1.TaggedErrorClass()("CodexAppServerIdentifierGenerationError", {
|
|
69540
|
-
purpose: CodexAppServerIdentifierPurpose,
|
|
69541
|
-
cause: Schema$1.Defect()
|
|
69542
|
-
}) {
|
|
69543
|
-
get message() {
|
|
69544
|
-
return `Failed to generate Codex App Server identifier for ${this.purpose}.`;
|
|
69545
|
-
}
|
|
69546
|
-
};
|
|
69547
|
-
var CodexAppServerInputStreamEndedError = class extends Schema$1.TaggedErrorClass()("CodexAppServerInputStreamEndedError", {}) {
|
|
69548
|
-
get message() {
|
|
69549
|
-
return "Codex App Server input stream ended.";
|
|
69550
|
-
}
|
|
69551
|
-
};
|
|
69552
|
-
var CodexAppServerRequestError = class CodexAppServerRequestError extends Schema$1.TaggedErrorClass()("CodexAppServerRequestError", {
|
|
69553
|
-
code: Schema$1.Number,
|
|
69554
|
-
errorMessage: Schema$1.String,
|
|
69555
|
-
data: Schema$1.optional(Schema$1.Unknown),
|
|
69556
|
-
method: Schema$1.optionalKey(Schema$1.String),
|
|
69557
|
-
requestId: Schema$1.optionalKey(Schema$1.String),
|
|
69558
|
-
operation: Schema$1.optionalKey(CodexAppServerRequestOperation),
|
|
69559
|
-
issueCount: Schema$1.optionalKey(Schema$1.Number),
|
|
69560
|
-
issueKinds: Schema$1.optionalKey(Schema$1.Array(CodexAppServerSchemaIssueKind)),
|
|
69561
|
-
maximumPathDepth: Schema$1.optionalKey(Schema$1.Number),
|
|
69562
|
-
payloadKind: Schema$1.optionalKey(CodexAppServerPayloadKind),
|
|
69563
|
-
cause: Schema$1.optionalKey(Schema$1.Defect())
|
|
69564
|
-
}) {
|
|
69565
|
-
get message() {
|
|
69566
|
-
return this.errorMessage;
|
|
69567
|
-
}
|
|
69568
|
-
static fromProtocolError(error, method, requestId) {
|
|
69569
|
-
return new CodexAppServerRequestError({
|
|
69570
|
-
code: error.code,
|
|
69571
|
-
errorMessage: error.message,
|
|
69572
|
-
...error.data !== void 0 ? { data: error.data } : {},
|
|
69573
|
-
method,
|
|
69574
|
-
requestId,
|
|
69575
|
-
operation: "receive-response",
|
|
69576
|
-
cause: error
|
|
69577
|
-
});
|
|
69578
|
-
}
|
|
69579
|
-
static fromAppServerError(error, method) {
|
|
69580
|
-
if (error._tag === "CodexAppServerRequestError") return error;
|
|
69581
|
-
return CodexAppServerRequestError.internalError(`Codex App Server request handler failed for method '${method}'`, void 0, {
|
|
69582
|
-
method,
|
|
69583
|
-
operation: "handle-request",
|
|
69584
|
-
cause: error
|
|
69585
|
-
});
|
|
69586
|
-
}
|
|
69587
|
-
static parseError(message = "Parse error", data) {
|
|
69588
|
-
return new CodexAppServerRequestError({
|
|
69589
|
-
code: -32700,
|
|
69590
|
-
errorMessage: message,
|
|
69591
|
-
...data !== void 0 ? { data } : {}
|
|
69592
|
-
});
|
|
69593
|
-
}
|
|
69594
|
-
static invalidRequest(message = "Invalid request", data) {
|
|
69595
|
-
return new CodexAppServerRequestError({
|
|
69596
|
-
code: -32600,
|
|
69597
|
-
errorMessage: message,
|
|
69598
|
-
...data !== void 0 ? { data } : {}
|
|
69599
|
-
});
|
|
69600
|
-
}
|
|
69601
|
-
static methodNotFound(method) {
|
|
69602
|
-
return new CodexAppServerRequestError({
|
|
69603
|
-
code: -32601,
|
|
69604
|
-
errorMessage: `Method not found: ${method}`
|
|
69605
|
-
});
|
|
69606
|
-
}
|
|
69607
|
-
static invalidParams(message = "Invalid params", data, diagnostics = {}) {
|
|
69608
|
-
return new CodexAppServerRequestError({
|
|
69609
|
-
code: -32602,
|
|
69610
|
-
errorMessage: message,
|
|
69611
|
-
...data !== void 0 ? { data } : {},
|
|
69612
|
-
...diagnostics
|
|
69613
|
-
});
|
|
69614
|
-
}
|
|
69615
|
-
static invalidPayload(method, operation, cause) {
|
|
69616
|
-
const diagnostics = schemaIssueDiagnostics$1(cause.issue);
|
|
69617
|
-
return new CodexAppServerRequestError({
|
|
69618
|
-
code: -32602,
|
|
69619
|
-
errorMessage: `Invalid payload for method '${method}' during '${operation}'`,
|
|
69620
|
-
data: diagnostics,
|
|
69621
|
-
method,
|
|
69622
|
-
operation,
|
|
69623
|
-
...diagnostics,
|
|
69624
|
-
cause
|
|
69625
|
-
});
|
|
69626
|
-
}
|
|
69627
|
-
static unexpectedPayload(method, operation, payload) {
|
|
69628
|
-
const diagnostics = { payloadKind: payloadKind(payload) };
|
|
69629
|
-
return new CodexAppServerRequestError({
|
|
69630
|
-
code: -32602,
|
|
69631
|
-
errorMessage: `Method '${method}' does not accept a payload during '${operation}'`,
|
|
69632
|
-
data: diagnostics,
|
|
69633
|
-
method,
|
|
69634
|
-
operation,
|
|
69635
|
-
...diagnostics
|
|
69636
|
-
});
|
|
69637
|
-
}
|
|
69638
|
-
static internalError(message = "Internal error", data, diagnostics = {}) {
|
|
69639
|
-
return new CodexAppServerRequestError({
|
|
69640
|
-
code: -32603,
|
|
69641
|
-
errorMessage: message,
|
|
69642
|
-
...data !== void 0 ? { data } : {},
|
|
69643
|
-
...diagnostics
|
|
69644
|
-
});
|
|
69645
|
-
}
|
|
69646
|
-
static overloaded(message = "Server overloaded; retry later.", data) {
|
|
69647
|
-
return new CodexAppServerRequestError({
|
|
69648
|
-
code: -32001,
|
|
69649
|
-
errorMessage: message,
|
|
69650
|
-
...data !== void 0 ? { data } : {}
|
|
69651
|
-
});
|
|
69652
|
-
}
|
|
69653
|
-
toProtocolError() {
|
|
69654
|
-
return {
|
|
69655
|
-
code: this.code,
|
|
69656
|
-
message: this.errorMessage,
|
|
69657
|
-
...this.data !== void 0 ? { data: this.data } : {}
|
|
69658
|
-
};
|
|
69659
|
-
}
|
|
69660
|
-
};
|
|
69661
|
-
const CodexAppServerError = Schema$1.Union([
|
|
69662
|
-
CodexAppServerRequestError,
|
|
69663
|
-
CodexAppServerSpawnError,
|
|
69664
|
-
CodexAppServerProcessExitedError,
|
|
69665
|
-
CodexAppServerProtocolParseError,
|
|
69666
|
-
CodexAppServerTransportError,
|
|
69667
|
-
CodexAppServerIdentifierGenerationError,
|
|
69668
|
-
CodexAppServerInputStreamEndedError
|
|
69669
|
-
]);
|
|
69670
69630
|
//#endregion
|
|
69671
69631
|
//#region ../../packages/effect-codex-app-server/src/_generated/schema.gen.ts
|
|
69672
69632
|
const ApplyPatchApprovalParams__FileChange = Schema$1.Union([
|
|
@@ -87129,80 +87089,303 @@ const SERVER_NOTIFICATION_PARAMS = {
|
|
|
87129
87089
|
"account/login/completed": V2AccountLoginCompletedNotification
|
|
87130
87090
|
};
|
|
87131
87091
|
//#endregion
|
|
87132
|
-
//#region
|
|
87133
|
-
|
|
87134
|
-
|
|
87135
|
-
|
|
87136
|
-
|
|
87137
|
-
|
|
87138
|
-
|
|
87139
|
-
const
|
|
87140
|
-
|
|
87141
|
-
|
|
87142
|
-
|
|
87143
|
-
|
|
87144
|
-
|
|
87145
|
-
|
|
87146
|
-
|
|
87147
|
-
|
|
87148
|
-
|
|
87149
|
-
|
|
87150
|
-
|
|
87151
|
-
|
|
87152
|
-
|
|
87153
|
-
|
|
87154
|
-
|
|
87155
|
-
|
|
87156
|
-
|
|
87157
|
-
|
|
87158
|
-
|
|
87159
|
-
|
|
87160
|
-
|
|
87161
|
-
|
|
87162
|
-
|
|
87163
|
-
|
|
87164
|
-
|
|
87165
|
-
|
|
87166
|
-
|
|
87167
|
-
|
|
87168
|
-
|
|
87169
|
-
|
|
87170
|
-
|
|
87171
|
-
|
|
87172
|
-
continue;
|
|
87173
|
-
}
|
|
87174
|
-
if (server.type === "sse") {
|
|
87175
|
-
skipped.push({
|
|
87176
|
-
name,
|
|
87177
|
-
reason: "Codex speaks streamable HTTP, not SSE."
|
|
87178
|
-
});
|
|
87179
|
-
continue;
|
|
87180
|
-
}
|
|
87181
|
-
const headerNames = Object.keys(server.headers);
|
|
87182
|
-
const authorization = headerNames.find((key) => key.toLowerCase() === AUTHORIZATION_HEADER);
|
|
87183
|
-
const otherHeaders = headerNames.filter((key) => key !== authorization);
|
|
87184
|
-
if (otherHeaders.length > 0) {
|
|
87185
|
-
skipped.push({
|
|
87186
|
-
name,
|
|
87187
|
-
reason: `Codex sends no custom headers, and this server needs ${otherHeaders.join(", ")}.`
|
|
87188
|
-
});
|
|
87189
|
-
continue;
|
|
87190
|
-
}
|
|
87191
|
-
push(name, "url", JSON.stringify(server.url));
|
|
87192
|
-
if (authorization !== void 0) {
|
|
87193
|
-
const token = server.headers[authorization]?.replace(BEARER_PREFIX, "") ?? "";
|
|
87194
|
-
const variable = bearerTokenEnvVar(name, index);
|
|
87195
|
-
env[variable] = token;
|
|
87196
|
-
push(name, "bearer_token_env_var", JSON.stringify(variable));
|
|
87092
|
+
//#region ../../packages/effect-codex-app-server/src/errors.ts
|
|
87093
|
+
const CodexAppServerRequestOperation = Schema$1.Literals([
|
|
87094
|
+
"decode-payload",
|
|
87095
|
+
"encode-payload",
|
|
87096
|
+
"handle-request",
|
|
87097
|
+
"receive-response"
|
|
87098
|
+
]);
|
|
87099
|
+
const CodexAppServerSchemaIssueKind = Schema$1.Literals([
|
|
87100
|
+
"Filter",
|
|
87101
|
+
"Encoding",
|
|
87102
|
+
"Pointer",
|
|
87103
|
+
"Composite",
|
|
87104
|
+
"AnyOf",
|
|
87105
|
+
"InvalidType",
|
|
87106
|
+
"InvalidValue",
|
|
87107
|
+
"MissingKey",
|
|
87108
|
+
"UnexpectedKey",
|
|
87109
|
+
"Forbidden",
|
|
87110
|
+
"OneOf"
|
|
87111
|
+
]);
|
|
87112
|
+
const schemaIssueDiagnostics$1 = (root) => {
|
|
87113
|
+
let issueCount = 0;
|
|
87114
|
+
let maximumPathDepth = 0;
|
|
87115
|
+
const issueKinds = /* @__PURE__ */ new Set();
|
|
87116
|
+
const visit = (issue, pathDepth) => {
|
|
87117
|
+
issueCount += 1;
|
|
87118
|
+
issueKinds.add(issue._tag);
|
|
87119
|
+
maximumPathDepth = Math.max(maximumPathDepth, pathDepth);
|
|
87120
|
+
switch (issue._tag) {
|
|
87121
|
+
case "Filter":
|
|
87122
|
+
case "Encoding":
|
|
87123
|
+
visit(issue.issue, pathDepth);
|
|
87124
|
+
break;
|
|
87125
|
+
case "Pointer":
|
|
87126
|
+
visit(issue.issue, pathDepth + issue.path.length);
|
|
87127
|
+
break;
|
|
87128
|
+
case "Composite":
|
|
87129
|
+
case "AnyOf":
|
|
87130
|
+
for (const child of issue.issues) visit(child, pathDepth);
|
|
87131
|
+
break;
|
|
87197
87132
|
}
|
|
87198
|
-
|
|
87199
|
-
|
|
87133
|
+
};
|
|
87134
|
+
visit(root, 0);
|
|
87200
87135
|
return {
|
|
87201
|
-
|
|
87202
|
-
|
|
87203
|
-
|
|
87136
|
+
issueCount,
|
|
87137
|
+
issueKinds: [...issueKinds],
|
|
87138
|
+
maximumPathDepth
|
|
87204
87139
|
};
|
|
87205
87140
|
};
|
|
87141
|
+
const CodexAppServerPayloadKind = Schema$1.Literals([
|
|
87142
|
+
"null",
|
|
87143
|
+
"array",
|
|
87144
|
+
"string",
|
|
87145
|
+
"number",
|
|
87146
|
+
"boolean",
|
|
87147
|
+
"bigint",
|
|
87148
|
+
"object",
|
|
87149
|
+
"symbol",
|
|
87150
|
+
"function",
|
|
87151
|
+
"undefined"
|
|
87152
|
+
]);
|
|
87153
|
+
const payloadKind = (payload) => {
|
|
87154
|
+
if (payload === null) return "null";
|
|
87155
|
+
if (Array.isArray(payload)) return "array";
|
|
87156
|
+
return typeof payload;
|
|
87157
|
+
};
|
|
87158
|
+
const protocolMessageFields = [
|
|
87159
|
+
"id",
|
|
87160
|
+
"method",
|
|
87161
|
+
"params",
|
|
87162
|
+
"result",
|
|
87163
|
+
"error"
|
|
87164
|
+
];
|
|
87165
|
+
const CodexAppServerProtocolMessageField = Schema$1.Literals(protocolMessageFields);
|
|
87166
|
+
const CodexAppServerProtocolParseOperation = Schema$1.Literals([
|
|
87167
|
+
"encode-wire-message",
|
|
87168
|
+
"decode-wire-message",
|
|
87169
|
+
"route-wire-message",
|
|
87170
|
+
"decode-notification-payload",
|
|
87171
|
+
"decode-request-payload",
|
|
87172
|
+
"decode-response-payload"
|
|
87173
|
+
]);
|
|
87174
|
+
const CodexAppServerTransportOperation = Schema$1.Literals(["read-input-stream", "read-process-exit-status"]);
|
|
87175
|
+
const CodexAppServerIdentifierPurpose = Schema$1.Literals([
|
|
87176
|
+
"provider-event",
|
|
87177
|
+
"command-approval-request",
|
|
87178
|
+
"file-change-approval-request",
|
|
87179
|
+
"user-input-request"
|
|
87180
|
+
]);
|
|
87181
|
+
var CodexAppServerSpawnError = class extends Schema$1.TaggedErrorClass()("CodexAppServerSpawnError", {
|
|
87182
|
+
command: Schema$1.optional(Schema$1.String),
|
|
87183
|
+
cause: Schema$1.Defect()
|
|
87184
|
+
}) {
|
|
87185
|
+
get message() {
|
|
87186
|
+
return this.command ? `Failed to spawn Codex App Server process for command: ${this.command}` : "Failed to spawn Codex App Server process";
|
|
87187
|
+
}
|
|
87188
|
+
};
|
|
87189
|
+
var CodexAppServerProcessExitedError = class extends Schema$1.TaggedErrorClass()("CodexAppServerProcessExitedError", {
|
|
87190
|
+
code: Schema$1.optional(Schema$1.Number),
|
|
87191
|
+
pid: Schema$1.optionalKey(Schema$1.Int),
|
|
87192
|
+
cause: Schema$1.optional(Schema$1.Defect())
|
|
87193
|
+
}) {
|
|
87194
|
+
get message() {
|
|
87195
|
+
return this.code === void 0 ? "Codex App Server process exited" : `Codex App Server process exited with code ${this.code}`;
|
|
87196
|
+
}
|
|
87197
|
+
};
|
|
87198
|
+
var CodexAppServerProtocolParseError = class CodexAppServerProtocolParseError extends Schema$1.TaggedErrorClass()("CodexAppServerProtocolParseError", {
|
|
87199
|
+
operation: CodexAppServerProtocolParseOperation,
|
|
87200
|
+
method: Schema$1.optionalKey(Schema$1.String),
|
|
87201
|
+
requestId: Schema$1.optionalKey(Schema$1.String),
|
|
87202
|
+
payloadKind: Schema$1.optionalKey(CodexAppServerPayloadKind),
|
|
87203
|
+
presentFields: Schema$1.optionalKey(Schema$1.Array(CodexAppServerProtocolMessageField)),
|
|
87204
|
+
issueCount: Schema$1.optionalKey(Schema$1.Number),
|
|
87205
|
+
issueKinds: Schema$1.optionalKey(Schema$1.Array(CodexAppServerSchemaIssueKind)),
|
|
87206
|
+
maximumPathDepth: Schema$1.optionalKey(Schema$1.Number),
|
|
87207
|
+
cause: Schema$1.optional(Schema$1.Defect())
|
|
87208
|
+
}) {
|
|
87209
|
+
get message() {
|
|
87210
|
+
const method = this.method === void 0 ? "" : ` for method '${this.method}'`;
|
|
87211
|
+
return `Codex App Server protocol operation '${this.operation}' failed${method}.`;
|
|
87212
|
+
}
|
|
87213
|
+
static fromSchemaError(operation, cause, context = {}) {
|
|
87214
|
+
return new CodexAppServerProtocolParseError({
|
|
87215
|
+
operation,
|
|
87216
|
+
...context,
|
|
87217
|
+
...schemaIssueDiagnostics$1(cause.issue),
|
|
87218
|
+
cause
|
|
87219
|
+
});
|
|
87220
|
+
}
|
|
87221
|
+
static fromRequestError(operation, method, cause) {
|
|
87222
|
+
return new CodexAppServerProtocolParseError({
|
|
87223
|
+
operation,
|
|
87224
|
+
method,
|
|
87225
|
+
...cause.issueCount === void 0 ? {} : { issueCount: cause.issueCount },
|
|
87226
|
+
...cause.issueKinds === void 0 ? {} : { issueKinds: cause.issueKinds },
|
|
87227
|
+
...cause.maximumPathDepth === void 0 ? {} : { maximumPathDepth: cause.maximumPathDepth },
|
|
87228
|
+
cause
|
|
87229
|
+
});
|
|
87230
|
+
}
|
|
87231
|
+
static fromUnroutableMessage(message) {
|
|
87232
|
+
const diagnostics = { payloadKind: payloadKind(message) };
|
|
87233
|
+
if (typeof message !== "object" || message === null || Array.isArray(message)) return new CodexAppServerProtocolParseError({
|
|
87234
|
+
operation: "route-wire-message",
|
|
87235
|
+
...diagnostics
|
|
87236
|
+
});
|
|
87237
|
+
const presentFields = protocolMessageFields.filter((field) => field in message);
|
|
87238
|
+
const method = "method" in message && typeof message.method === "string" ? message.method : void 0;
|
|
87239
|
+
const requestId = "id" in message && (typeof message.id === "string" || typeof message.id === "number") ? String(message.id) : void 0;
|
|
87240
|
+
return new CodexAppServerProtocolParseError({
|
|
87241
|
+
operation: "route-wire-message",
|
|
87242
|
+
...diagnostics,
|
|
87243
|
+
presentFields,
|
|
87244
|
+
...method === void 0 ? {} : { method },
|
|
87245
|
+
...requestId === void 0 ? {} : { requestId }
|
|
87246
|
+
});
|
|
87247
|
+
}
|
|
87248
|
+
};
|
|
87249
|
+
var CodexAppServerTransportError = class extends Schema$1.TaggedErrorClass()("CodexAppServerTransportError", {
|
|
87250
|
+
operation: CodexAppServerTransportOperation,
|
|
87251
|
+
pid: Schema$1.optionalKey(Schema$1.Int),
|
|
87252
|
+
cause: Schema$1.Defect()
|
|
87253
|
+
}) {
|
|
87254
|
+
get message() {
|
|
87255
|
+
return `Codex App Server transport operation '${this.operation}' failed.`;
|
|
87256
|
+
}
|
|
87257
|
+
};
|
|
87258
|
+
var CodexAppServerIdentifierGenerationError = class extends Schema$1.TaggedErrorClass()("CodexAppServerIdentifierGenerationError", {
|
|
87259
|
+
purpose: CodexAppServerIdentifierPurpose,
|
|
87260
|
+
cause: Schema$1.Defect()
|
|
87261
|
+
}) {
|
|
87262
|
+
get message() {
|
|
87263
|
+
return `Failed to generate Codex App Server identifier for ${this.purpose}.`;
|
|
87264
|
+
}
|
|
87265
|
+
};
|
|
87266
|
+
var CodexAppServerInputStreamEndedError = class extends Schema$1.TaggedErrorClass()("CodexAppServerInputStreamEndedError", {}) {
|
|
87267
|
+
get message() {
|
|
87268
|
+
return "Codex App Server input stream ended.";
|
|
87269
|
+
}
|
|
87270
|
+
};
|
|
87271
|
+
var CodexAppServerRequestError = class CodexAppServerRequestError extends Schema$1.TaggedErrorClass()("CodexAppServerRequestError", {
|
|
87272
|
+
code: Schema$1.Number,
|
|
87273
|
+
errorMessage: Schema$1.String,
|
|
87274
|
+
data: Schema$1.optional(Schema$1.Unknown),
|
|
87275
|
+
method: Schema$1.optionalKey(Schema$1.String),
|
|
87276
|
+
requestId: Schema$1.optionalKey(Schema$1.String),
|
|
87277
|
+
operation: Schema$1.optionalKey(CodexAppServerRequestOperation),
|
|
87278
|
+
issueCount: Schema$1.optionalKey(Schema$1.Number),
|
|
87279
|
+
issueKinds: Schema$1.optionalKey(Schema$1.Array(CodexAppServerSchemaIssueKind)),
|
|
87280
|
+
maximumPathDepth: Schema$1.optionalKey(Schema$1.Number),
|
|
87281
|
+
payloadKind: Schema$1.optionalKey(CodexAppServerPayloadKind),
|
|
87282
|
+
cause: Schema$1.optionalKey(Schema$1.Defect())
|
|
87283
|
+
}) {
|
|
87284
|
+
get message() {
|
|
87285
|
+
return this.errorMessage;
|
|
87286
|
+
}
|
|
87287
|
+
static fromProtocolError(error, method, requestId) {
|
|
87288
|
+
return new CodexAppServerRequestError({
|
|
87289
|
+
code: error.code,
|
|
87290
|
+
errorMessage: error.message,
|
|
87291
|
+
...error.data !== void 0 ? { data: error.data } : {},
|
|
87292
|
+
method,
|
|
87293
|
+
requestId,
|
|
87294
|
+
operation: "receive-response",
|
|
87295
|
+
cause: error
|
|
87296
|
+
});
|
|
87297
|
+
}
|
|
87298
|
+
static fromAppServerError(error, method) {
|
|
87299
|
+
if (error._tag === "CodexAppServerRequestError") return error;
|
|
87300
|
+
return CodexAppServerRequestError.internalError(`Codex App Server request handler failed for method '${method}'`, void 0, {
|
|
87301
|
+
method,
|
|
87302
|
+
operation: "handle-request",
|
|
87303
|
+
cause: error
|
|
87304
|
+
});
|
|
87305
|
+
}
|
|
87306
|
+
static parseError(message = "Parse error", data) {
|
|
87307
|
+
return new CodexAppServerRequestError({
|
|
87308
|
+
code: -32700,
|
|
87309
|
+
errorMessage: message,
|
|
87310
|
+
...data !== void 0 ? { data } : {}
|
|
87311
|
+
});
|
|
87312
|
+
}
|
|
87313
|
+
static invalidRequest(message = "Invalid request", data) {
|
|
87314
|
+
return new CodexAppServerRequestError({
|
|
87315
|
+
code: -32600,
|
|
87316
|
+
errorMessage: message,
|
|
87317
|
+
...data !== void 0 ? { data } : {}
|
|
87318
|
+
});
|
|
87319
|
+
}
|
|
87320
|
+
static methodNotFound(method) {
|
|
87321
|
+
return new CodexAppServerRequestError({
|
|
87322
|
+
code: -32601,
|
|
87323
|
+
errorMessage: `Method not found: ${method}`
|
|
87324
|
+
});
|
|
87325
|
+
}
|
|
87326
|
+
static invalidParams(message = "Invalid params", data, diagnostics = {}) {
|
|
87327
|
+
return new CodexAppServerRequestError({
|
|
87328
|
+
code: -32602,
|
|
87329
|
+
errorMessage: message,
|
|
87330
|
+
...data !== void 0 ? { data } : {},
|
|
87331
|
+
...diagnostics
|
|
87332
|
+
});
|
|
87333
|
+
}
|
|
87334
|
+
static invalidPayload(method, operation, cause) {
|
|
87335
|
+
const diagnostics = schemaIssueDiagnostics$1(cause.issue);
|
|
87336
|
+
return new CodexAppServerRequestError({
|
|
87337
|
+
code: -32602,
|
|
87338
|
+
errorMessage: `Invalid payload for method '${method}' during '${operation}'`,
|
|
87339
|
+
data: diagnostics,
|
|
87340
|
+
method,
|
|
87341
|
+
operation,
|
|
87342
|
+
...diagnostics,
|
|
87343
|
+
cause
|
|
87344
|
+
});
|
|
87345
|
+
}
|
|
87346
|
+
static unexpectedPayload(method, operation, payload) {
|
|
87347
|
+
const diagnostics = { payloadKind: payloadKind(payload) };
|
|
87348
|
+
return new CodexAppServerRequestError({
|
|
87349
|
+
code: -32602,
|
|
87350
|
+
errorMessage: `Method '${method}' does not accept a payload during '${operation}'`,
|
|
87351
|
+
data: diagnostics,
|
|
87352
|
+
method,
|
|
87353
|
+
operation,
|
|
87354
|
+
...diagnostics
|
|
87355
|
+
});
|
|
87356
|
+
}
|
|
87357
|
+
static internalError(message = "Internal error", data, diagnostics = {}) {
|
|
87358
|
+
return new CodexAppServerRequestError({
|
|
87359
|
+
code: -32603,
|
|
87360
|
+
errorMessage: message,
|
|
87361
|
+
...data !== void 0 ? { data } : {},
|
|
87362
|
+
...diagnostics
|
|
87363
|
+
});
|
|
87364
|
+
}
|
|
87365
|
+
static overloaded(message = "Server overloaded; retry later.", data) {
|
|
87366
|
+
return new CodexAppServerRequestError({
|
|
87367
|
+
code: -32001,
|
|
87368
|
+
errorMessage: message,
|
|
87369
|
+
...data !== void 0 ? { data } : {}
|
|
87370
|
+
});
|
|
87371
|
+
}
|
|
87372
|
+
toProtocolError() {
|
|
87373
|
+
return {
|
|
87374
|
+
code: this.code,
|
|
87375
|
+
message: this.errorMessage,
|
|
87376
|
+
...this.data !== void 0 ? { data: this.data } : {}
|
|
87377
|
+
};
|
|
87378
|
+
}
|
|
87379
|
+
};
|
|
87380
|
+
const CodexAppServerError = Schema$1.Union([
|
|
87381
|
+
CodexAppServerRequestError,
|
|
87382
|
+
CodexAppServerSpawnError,
|
|
87383
|
+
CodexAppServerProcessExitedError,
|
|
87384
|
+
CodexAppServerProtocolParseError,
|
|
87385
|
+
CodexAppServerTransportError,
|
|
87386
|
+
CodexAppServerIdentifierGenerationError,
|
|
87387
|
+
CodexAppServerInputStreamEndedError
|
|
87388
|
+
]);
|
|
87206
87389
|
//#endregion
|
|
87207
87390
|
//#region ../../packages/effect-codex-app-server/src/_internal/shared.ts
|
|
87208
87391
|
const JsonRpcId$1 = Schema$1.Union([Schema$1.Number, Schema$1.String]);
|
|
@@ -87253,9 +87436,9 @@ function isIncomingNotification(value) {
|
|
|
87253
87436
|
function isIncomingResponse(value) {
|
|
87254
87437
|
return isJsonRpcResponseEnvelope(value);
|
|
87255
87438
|
}
|
|
87256
|
-
const encodeJsonString = Schema$1.encodeUnknownEffect(Schema$1.UnknownFromJsonString);
|
|
87439
|
+
const encodeJsonString$1 = Schema$1.encodeUnknownEffect(Schema$1.UnknownFromJsonString);
|
|
87257
87440
|
const decodeJsonString = Schema$1.decodeUnknownEffect(Schema$1.UnknownFromJsonString);
|
|
87258
|
-
const encodeWireMessage = (message) => encodeJsonString(message).pipe(Effect.map((encoded) => `${encoded}\n`), Effect.mapError((cause) => {
|
|
87441
|
+
const encodeWireMessage = (message) => encodeJsonString$1(message).pipe(Effect.map((encoded) => `${encoded}\n`), Effect.mapError((cause) => {
|
|
87259
87442
|
const method = typeof message.method === "string" ? message.method : void 0;
|
|
87260
87443
|
const requestId = typeof message.id === "string" || typeof message.id === "number" ? String(message.id) : void 0;
|
|
87261
87444
|
return CodexAppServerProtocolParseError.fromSchemaError("encode-wire-message", cause, {
|
|
@@ -87511,6 +87694,30 @@ const makeChildProcessClient = Effect.fn("effect-codex-app-server/CodexAppServer
|
|
|
87511
87694
|
yield* Stream.runDrain(handle.stderr).pipe(Effect.ignore, Effect.forkScoped);
|
|
87512
87695
|
return yield* make$8(makeChildStdio$1(handle), options, makeTerminationError$1(handle));
|
|
87513
87696
|
});
|
|
87697
|
+
const resolveCodexLaunchArgs = (launchArgs, environment = process.env) => environment["P4CODE_CODEX_LAUNCH_ARGS"]?.trim() || launchArgs?.trim() || "";
|
|
87698
|
+
const codexLaunchArgv = (launchArgs) => tokenizeCliArgs(launchArgs);
|
|
87699
|
+
const codexAppServerArgs = (launchArgs) => ["app-server", ...codexLaunchArgv(launchArgs)];
|
|
87700
|
+
const codexExecLaunchArgs = (launchArgs) => {
|
|
87701
|
+
const args = codexLaunchArgv(launchArgs);
|
|
87702
|
+
const execArgs = [];
|
|
87703
|
+
for (let index = 0; index < args.length; index++) {
|
|
87704
|
+
const arg = args[index];
|
|
87705
|
+
if (arg === void 0) continue;
|
|
87706
|
+
if (arg === "--strict-config" || arg.startsWith("--config=") || arg.startsWith("-c=")) execArgs.push(arg);
|
|
87707
|
+
else if (arg === "--config" || arg === "-c" || arg === "--enable" || arg === "--disable") {
|
|
87708
|
+
const value = args[index + 1];
|
|
87709
|
+
if (value !== void 0 && !value.startsWith("-")) {
|
|
87710
|
+
execArgs.push(arg, value);
|
|
87711
|
+
index++;
|
|
87712
|
+
}
|
|
87713
|
+
} else if (arg.startsWith("--enable=") || arg.startsWith("--disable=")) execArgs.push(arg);
|
|
87714
|
+
}
|
|
87715
|
+
return execArgs;
|
|
87716
|
+
};
|
|
87717
|
+
const codexSessionAppServerArgs = (appServerArgs, launchArgs) => {
|
|
87718
|
+
const launchAppServerArgs = codexAppServerArgs(launchArgs);
|
|
87719
|
+
return appServerArgs ? [...launchAppServerArgs, ...appServerArgs] : launchAppServerArgs;
|
|
87720
|
+
};
|
|
87514
87721
|
//#endregion
|
|
87515
87722
|
//#region src/provider/Layers/CodexProvider.ts
|
|
87516
87723
|
const isCodexAppServerSpawnError = Schema$1.is(CodexAppServerSpawnError);
|
|
@@ -87878,6 +88085,507 @@ const checkCodexProviderStatus = Effect.fn("checkCodexProviderStatus")(function*
|
|
|
87878
88085
|
});
|
|
87879
88086
|
});
|
|
87880
88087
|
//#endregion
|
|
88088
|
+
//#region src/provider/Layers/CodexAccountUsage.ts
|
|
88089
|
+
/**
|
|
88090
|
+
* Codex has no `/usage` command: the limits live behind the app-server's
|
|
88091
|
+
* `account/*` requests. A short-lived app-server is spawned for the question and
|
|
88092
|
+
* torn down with the scope, the same way the capability probe does it, so asking
|
|
88093
|
+
* about the account never touches a running session.
|
|
88094
|
+
*
|
|
88095
|
+
* @module CodexAccountUsage
|
|
88096
|
+
*/
|
|
88097
|
+
const CODEX_ACCOUNT_USAGE_FORCE_KILL_AFTER = "2 seconds";
|
|
88098
|
+
const readCodexAccountUsage = Effect.fn("readCodexAccountUsage")(function* (input) {
|
|
88099
|
+
const resolvedHomePath = input.homePath ? expandHomePath$3(input.homePath) : void 0;
|
|
88100
|
+
const spawner = yield* ChildProcessSpawner$1.ChildProcessSpawner;
|
|
88101
|
+
const environment = {
|
|
88102
|
+
...input.environment,
|
|
88103
|
+
...resolvedHomePath ? { CODEX_HOME: resolvedHomePath } : {}
|
|
88104
|
+
};
|
|
88105
|
+
const spawnCommand = yield* resolveSpawnCommand(input.binaryPath, codexAppServerArgs(input.launchArgs), {
|
|
88106
|
+
env: environment,
|
|
88107
|
+
extendEnv: true
|
|
88108
|
+
});
|
|
88109
|
+
const child = yield* spawner.spawn(ChildProcess$1.make(spawnCommand.command, spawnCommand.args, {
|
|
88110
|
+
cwd: input.cwd,
|
|
88111
|
+
env: environment,
|
|
88112
|
+
extendEnv: true,
|
|
88113
|
+
forceKillAfter: CODEX_ACCOUNT_USAGE_FORCE_KILL_AFTER,
|
|
88114
|
+
shell: spawnCommand.shell
|
|
88115
|
+
})).pipe(Effect.mapError((cause) => new CodexAppServerSpawnError({
|
|
88116
|
+
command: `${input.binaryPath} app-server`,
|
|
88117
|
+
cause
|
|
88118
|
+
})));
|
|
88119
|
+
const clientContext = yield* Layer.build(layerChildProcess$1(child));
|
|
88120
|
+
const client = yield* Effect.service(CodexAppServerClient).pipe(Effect.provide(clientContext));
|
|
88121
|
+
yield* client.request("initialize", buildCodexInitializeParams());
|
|
88122
|
+
yield* client.notify("initialized", void 0);
|
|
88123
|
+
return {
|
|
88124
|
+
rateLimits: yield* client.request("account/rateLimits/read", void 0),
|
|
88125
|
+
usage: yield* client.request("account/usage/read", void 0).pipe(Effect.orElseSucceed(() => null))
|
|
88126
|
+
};
|
|
88127
|
+
});
|
|
88128
|
+
//#endregion
|
|
88129
|
+
//#region src/codexModelOptions.ts
|
|
88130
|
+
function getCodexServiceTierOptionValue(modelSelection) {
|
|
88131
|
+
return getModelSelectionStringOptionValue(modelSelection, "serviceTier") ?? (getModelSelectionBooleanOptionValue(modelSelection, "fastMode") === true ? "fast" : void 0);
|
|
88132
|
+
}
|
|
88133
|
+
//#endregion
|
|
88134
|
+
//#region src/textGeneration/codexUsageReport.ts
|
|
88135
|
+
const MINUTES_PER_HOUR = 60;
|
|
88136
|
+
const MINUTES_PER_DAY = 1440;
|
|
88137
|
+
const TOP_DAY_COUNT = 3;
|
|
88138
|
+
const PLAN_LABELS = {
|
|
88139
|
+
free: "Free",
|
|
88140
|
+
go: "Go",
|
|
88141
|
+
plus: "Plus",
|
|
88142
|
+
pro: "Pro",
|
|
88143
|
+
prolite: "Pro Lite",
|
|
88144
|
+
team: "Team",
|
|
88145
|
+
business: "Business",
|
|
88146
|
+
enterprise: "Enterprise",
|
|
88147
|
+
edu: "Edu"
|
|
88148
|
+
};
|
|
88149
|
+
function formatNumber(value) {
|
|
88150
|
+
return Math.round(value).toLocaleString("en-US");
|
|
88151
|
+
}
|
|
88152
|
+
/** `10080` reads as `7d`, `300` as `5h`: the window label the limit lines carry. */
|
|
88153
|
+
function formatWindowDuration(minutes) {
|
|
88154
|
+
if (minutes === void 0 || minutes === null || minutes <= 0) return null;
|
|
88155
|
+
if (minutes % MINUTES_PER_DAY === 0) return `${minutes / MINUTES_PER_DAY}d`;
|
|
88156
|
+
if (minutes % MINUTES_PER_HOUR === 0) return `${minutes / MINUTES_PER_HOUR}h`;
|
|
88157
|
+
return `${minutes}m`;
|
|
88158
|
+
}
|
|
88159
|
+
const MILLISECONDS_PER_SECOND = 1e3;
|
|
88160
|
+
function formatResetTime(resetsAt, timeZone) {
|
|
88161
|
+
if (resetsAt === void 0 || resetsAt === null || !Number.isFinite(resetsAt)) return null;
|
|
88162
|
+
const epochMs = resetsAt * MILLISECONDS_PER_SECOND;
|
|
88163
|
+
return `resets ${new Intl.DateTimeFormat("en-US", {
|
|
88164
|
+
month: "short",
|
|
88165
|
+
day: "numeric",
|
|
88166
|
+
timeZone
|
|
88167
|
+
}).format(epochMs)} at ${new Intl.DateTimeFormat("en-US", {
|
|
88168
|
+
hour: "numeric",
|
|
88169
|
+
minute: "2-digit",
|
|
88170
|
+
hour12: true,
|
|
88171
|
+
timeZone
|
|
88172
|
+
}).format(epochMs).replace(/\s/g, "").toLowerCase()} (${timeZone})`;
|
|
88173
|
+
}
|
|
88174
|
+
function limitLabel(snapshot, fallbackId) {
|
|
88175
|
+
const name = snapshot.limitName?.trim();
|
|
88176
|
+
if (name) return name;
|
|
88177
|
+
const id = snapshot.limitId?.trim() || fallbackId;
|
|
88178
|
+
return id === "codex" ? "Codex" : id;
|
|
88179
|
+
}
|
|
88180
|
+
function limitLine(label, window, timeZone) {
|
|
88181
|
+
if (!window) return null;
|
|
88182
|
+
const duration = formatWindowDuration(window.windowDurationMins);
|
|
88183
|
+
const resets = formatResetTime(window.resetsAt, timeZone);
|
|
88184
|
+
return `${duration ? `${label} (${duration})` : label}: ${window.usedPercent}% used${resets ? ` · ${resets}` : ""}`;
|
|
88185
|
+
}
|
|
88186
|
+
/**
|
|
88187
|
+
* Every limit Codex knows about, not just the account-wide one: model-specific
|
|
88188
|
+
* limits arrive under `rateLimitsByLimitId` and are the ones that actually stop
|
|
88189
|
+
* a turn.
|
|
88190
|
+
*/
|
|
88191
|
+
function collectRateLimitSnapshots(response) {
|
|
88192
|
+
const activeId = response.rateLimits.limitId ?? "codex";
|
|
88193
|
+
const byId = response.rateLimitsByLimitId;
|
|
88194
|
+
if (byId && Object.keys(byId).length > 0) return Object.entries(byId).map(([id, snapshot]) => ({
|
|
88195
|
+
id,
|
|
88196
|
+
snapshot
|
|
88197
|
+
})).sort((left, right) => Number(right.id === activeId) - Number(left.id === activeId));
|
|
88198
|
+
return [{
|
|
88199
|
+
id: activeId,
|
|
88200
|
+
snapshot: response.rateLimits
|
|
88201
|
+
}];
|
|
88202
|
+
}
|
|
88203
|
+
function planSentence(response) {
|
|
88204
|
+
const planType = response.rateLimits.planType;
|
|
88205
|
+
if (!planType || planType === "unknown") return null;
|
|
88206
|
+
return `You are currently using your Codex ${PLAN_LABELS[planType] ?? planType} plan.`;
|
|
88207
|
+
}
|
|
88208
|
+
function creditsSentence(response) {
|
|
88209
|
+
const credits = response.rateLimits.credits;
|
|
88210
|
+
if (!credits) return null;
|
|
88211
|
+
if (credits.unlimited) return "Credits: unlimited.";
|
|
88212
|
+
if (!credits.hasCredits) return null;
|
|
88213
|
+
return credits.balance ? `Credits: ${credits.balance} available.` : "Credits available.";
|
|
88214
|
+
}
|
|
88215
|
+
function resetCreditSentence(response) {
|
|
88216
|
+
const available = response.rateLimitResetCredits?.availableCount ?? 0;
|
|
88217
|
+
if (available <= 0) return null;
|
|
88218
|
+
return available === 1 ? "1 rate limit reset is available on this account." : `${available} rate limit resets are available on this account.`;
|
|
88219
|
+
}
|
|
88220
|
+
const MONTH_NAMES = [
|
|
88221
|
+
"Jan",
|
|
88222
|
+
"Feb",
|
|
88223
|
+
"Mar",
|
|
88224
|
+
"Apr",
|
|
88225
|
+
"May",
|
|
88226
|
+
"Jun",
|
|
88227
|
+
"Jul",
|
|
88228
|
+
"Aug",
|
|
88229
|
+
"Sep",
|
|
88230
|
+
"Oct",
|
|
88231
|
+
"Nov",
|
|
88232
|
+
"Dec"
|
|
88233
|
+
];
|
|
88234
|
+
/** A stat line only earns its place when the account actually reports the number. */
|
|
88235
|
+
function countStat(value, label) {
|
|
88236
|
+
if (value === void 0 || value === null || value <= 0) return null;
|
|
88237
|
+
return `${formatNumber(value)} ${label}`;
|
|
88238
|
+
}
|
|
88239
|
+
/** Buckets are calendar days (`2026-08-17`), read as written rather than as an instant. */
|
|
88240
|
+
function formatBucketDay(startDate) {
|
|
88241
|
+
const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(startDate);
|
|
88242
|
+
const month = MONTH_NAMES[Number(match?.[2]) - 1];
|
|
88243
|
+
if (!match || !month) return startDate;
|
|
88244
|
+
return `${month} ${Number(match[3])}`;
|
|
88245
|
+
}
|
|
88246
|
+
function usageWindowLines(usage) {
|
|
88247
|
+
const lines = [];
|
|
88248
|
+
const buckets = (usage.dailyUsageBuckets ?? []).filter((bucket) => bucket.tokens > 0);
|
|
88249
|
+
const bucketTotal = buckets.reduce((total, bucket) => total + bucket.tokens, 0);
|
|
88250
|
+
if (buckets.length > 0 && bucketTotal > 0) {
|
|
88251
|
+
const perDay = Math.round(bucketTotal / buckets.length);
|
|
88252
|
+
lines.push(`Last ${buckets.length}d · ${formatNumber(bucketTotal)} tokens · ${formatNumber(perDay)} tokens per day`);
|
|
88253
|
+
const topDays = [...buckets].sort((left, right) => right.tokens - left.tokens).slice(0, TOP_DAY_COUNT).map((bucket) => `${formatBucketDay(bucket.startDate)} ${Math.round(bucket.tokens / bucketTotal * 100)}%`);
|
|
88254
|
+
if (topDays.length > 0) lines.push(` Top days: ${topDays.join(", ")}`);
|
|
88255
|
+
}
|
|
88256
|
+
const summary = usage.summary;
|
|
88257
|
+
const allTimeStats = [
|
|
88258
|
+
countStat(summary.lifetimeTokens, "tokens"),
|
|
88259
|
+
countStat(summary.peakDailyTokens, "peak daily tokens"),
|
|
88260
|
+
countStat(summary.currentStreakDays, "day streak")
|
|
88261
|
+
].filter((stat) => stat !== null);
|
|
88262
|
+
if (allTimeStats.length > 0) lines.push(`All time · ${allTimeStats.join(" · ")}`);
|
|
88263
|
+
return lines;
|
|
88264
|
+
}
|
|
88265
|
+
/**
|
|
88266
|
+
* Render the Codex account report. `timeZone` is the server's, matching how the
|
|
88267
|
+
* Claude CLI stamps its own reset times.
|
|
88268
|
+
*/
|
|
88269
|
+
function formatCodexUsageReport(input) {
|
|
88270
|
+
const { rateLimits, usage, timeZone } = input;
|
|
88271
|
+
const sections = [];
|
|
88272
|
+
const intro = [
|
|
88273
|
+
planSentence(rateLimits),
|
|
88274
|
+
creditsSentence(rateLimits),
|
|
88275
|
+
resetCreditSentence(rateLimits)
|
|
88276
|
+
].filter((sentence) => sentence !== null).join("\n");
|
|
88277
|
+
if (intro.length > 0) sections.push(intro);
|
|
88278
|
+
const limits = collectRateLimitSnapshots(rateLimits).flatMap(({ id, snapshot }) => {
|
|
88279
|
+
const label = limitLabel(snapshot, id);
|
|
88280
|
+
return [limitLine(label, snapshot.primary, timeZone), limitLine(label, snapshot.secondary, timeZone)].filter((line) => line !== null);
|
|
88281
|
+
});
|
|
88282
|
+
if (limits.length > 0) sections.push(limits.join("\n"));
|
|
88283
|
+
const windows = usage ? usageWindowLines(usage) : [];
|
|
88284
|
+
if (windows.length > 0) {
|
|
88285
|
+
sections.push(["What's contributing to your limits usage?", "Token totals Codex reports for this account. Day shares are of the tokens in that window."].join("\n"));
|
|
88286
|
+
sections.push(windows.join("\n"));
|
|
88287
|
+
}
|
|
88288
|
+
return sections.join("\n\n");
|
|
88289
|
+
}
|
|
88290
|
+
//#endregion
|
|
88291
|
+
//#region src/textGeneration/CodexTextGeneration.ts
|
|
88292
|
+
const CODEX_GIT_TEXT_GENERATION_REASONING_EFFORT = "low";
|
|
88293
|
+
const CODEX_TIMEOUT_MS = 18e4;
|
|
88294
|
+
/** The account report is a local lookup, so it should return in seconds, not minutes. */
|
|
88295
|
+
const USAGE_REPORT_TIMEOUT_MS = 3e4;
|
|
88296
|
+
const encodeJsonString = Schema$1.encodeEffect(Schema$1.UnknownFromJsonString);
|
|
88297
|
+
/**
|
|
88298
|
+
* Build a Codex text-generation closure bound to a specific `CodexSettings`
|
|
88299
|
+
* payload. See `makeCodexAdapter` for the overall per-instance rationale.
|
|
88300
|
+
*/
|
|
88301
|
+
const makeCodexTextGeneration = Effect.fn("makeCodexTextGeneration")(function* (codexConfig, environment) {
|
|
88302
|
+
const fileSystem = yield* FileSystem.FileSystem;
|
|
88303
|
+
const path = yield* Path.Path;
|
|
88304
|
+
const commandSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
|
|
88305
|
+
const serverConfig = yield* Effect.service(ServerConfig$1);
|
|
88306
|
+
const resolvedEnvironment = environment ?? process.env;
|
|
88307
|
+
const readStreamAsString = (operation, stream) => stream.pipe(Stream.decodeText(), Stream.runFold(() => "", (acc, chunk) => acc + chunk), Effect.mapError((cause) => normalizeCliError("codex", operation, cause, "Failed to collect process output")));
|
|
88308
|
+
const writeTempFile = (operation, prefix, content) => fileSystem.makeTempFileScoped({ prefix: `p4code-${prefix}-${process.pid}-` }).pipe(Effect.tap((filePath) => fileSystem.writeFileString(filePath, content)), Effect.mapError((cause) => new TextGenerationError({
|
|
88309
|
+
operation,
|
|
88310
|
+
detail: `Failed to write temp file`,
|
|
88311
|
+
cause
|
|
88312
|
+
})));
|
|
88313
|
+
const safeUnlink = (filePath) => fileSystem.remove(filePath).pipe(Effect.catch(() => Effect.void));
|
|
88314
|
+
const encodeJsonForOperation = (operation, value) => encodeJsonString(value).pipe(Effect.mapError((cause) => new TextGenerationError({
|
|
88315
|
+
operation,
|
|
88316
|
+
detail: "Failed to encode structured output schema.",
|
|
88317
|
+
cause
|
|
88318
|
+
})));
|
|
88319
|
+
const materializeImageAttachments = Effect.fn("materializeImageAttachments")(function* (_operation, attachments) {
|
|
88320
|
+
if (!attachments || attachments.length === 0) return { imagePaths: [] };
|
|
88321
|
+
const imagePaths = [];
|
|
88322
|
+
for (const attachment of attachments) {
|
|
88323
|
+
if (attachment.type !== "image") continue;
|
|
88324
|
+
const resolvedPath = resolveAttachmentPath({
|
|
88325
|
+
attachmentsDir: serverConfig.attachmentsDir,
|
|
88326
|
+
attachment
|
|
88327
|
+
});
|
|
88328
|
+
if (!resolvedPath || !path.isAbsolute(resolvedPath)) continue;
|
|
88329
|
+
const fileInfo = yield* fileSystem.stat(resolvedPath).pipe(Effect.orElseSucceed(() => null));
|
|
88330
|
+
if (!fileInfo || fileInfo.type !== "File") continue;
|
|
88331
|
+
imagePaths.push(resolvedPath);
|
|
88332
|
+
}
|
|
88333
|
+
return { imagePaths };
|
|
88334
|
+
});
|
|
88335
|
+
const runCodexJson = Effect.fn("runCodexJson")(function* ({ operation, cwd, prompt, outputSchemaJson, imagePaths = [], cleanupPaths = [], modelSelection }) {
|
|
88336
|
+
const schemaJson = yield* encodeJsonForOperation(operation, toJsonSchemaObject(outputSchemaJson));
|
|
88337
|
+
const schemaPath = yield* writeTempFile(operation, "codex-schema", schemaJson);
|
|
88338
|
+
const outputPath = yield* writeTempFile(operation, "codex-output", "");
|
|
88339
|
+
const runCodexCommand = Effect.fn("runCodexJson.runCodexCommand")(function* () {
|
|
88340
|
+
const launchArgs = resolveCodexLaunchArgs(codexConfig.launchArgs, resolvedEnvironment);
|
|
88341
|
+
const reasoningEffort = getModelSelectionStringOptionValue(modelSelection, "reasoningEffort") ?? CODEX_GIT_TEXT_GENERATION_REASONING_EFFORT;
|
|
88342
|
+
const serviceTier = getCodexServiceTierOptionValue(modelSelection);
|
|
88343
|
+
const spawnCommand = yield* resolveSpawnCommand(codexConfig.binaryPath || "codex", [
|
|
88344
|
+
"exec",
|
|
88345
|
+
...codexExecLaunchArgs(launchArgs),
|
|
88346
|
+
"--ephemeral",
|
|
88347
|
+
"--skip-git-repo-check",
|
|
88348
|
+
"-s",
|
|
88349
|
+
"read-only",
|
|
88350
|
+
"--model",
|
|
88351
|
+
modelSelection.model,
|
|
88352
|
+
"--config",
|
|
88353
|
+
`model_reasoning_effort="${reasoningEffort}"`,
|
|
88354
|
+
...serviceTier ? ["--config", `service_tier="${serviceTier}"`] : [],
|
|
88355
|
+
"--output-schema",
|
|
88356
|
+
schemaPath,
|
|
88357
|
+
"--output-last-message",
|
|
88358
|
+
outputPath,
|
|
88359
|
+
...imagePaths.flatMap((imagePath) => ["--image", imagePath]),
|
|
88360
|
+
"-"
|
|
88361
|
+
], { env: resolvedEnvironment });
|
|
88362
|
+
const command = ChildProcess.make(spawnCommand.command, spawnCommand.args, {
|
|
88363
|
+
env: {
|
|
88364
|
+
...resolvedEnvironment,
|
|
88365
|
+
...codexConfig.homePath ? { CODEX_HOME: expandHomePath$3(codexConfig.homePath) } : {}
|
|
88366
|
+
},
|
|
88367
|
+
cwd,
|
|
88368
|
+
shell: spawnCommand.shell,
|
|
88369
|
+
stdin: { stream: Stream.encodeText(Stream.make(prompt)) }
|
|
88370
|
+
});
|
|
88371
|
+
const child = yield* commandSpawner.spawn(command).pipe(Effect.mapError((cause) => normalizeCliError("codex", operation, cause, "Failed to spawn Codex CLI process")));
|
|
88372
|
+
const [stdout, stderr, exitCode] = yield* Effect.all([
|
|
88373
|
+
readStreamAsString(operation, child.stdout),
|
|
88374
|
+
readStreamAsString(operation, child.stderr),
|
|
88375
|
+
child.exitCode.pipe(Effect.mapError((cause) => normalizeCliError("codex", operation, cause, "Failed to read Codex CLI exit code")))
|
|
88376
|
+
], { concurrency: "unbounded" });
|
|
88377
|
+
if (exitCode !== 0) {
|
|
88378
|
+
const stderrDetail = stderr.trim();
|
|
88379
|
+
const stdoutDetail = stdout.trim();
|
|
88380
|
+
const detail = stderrDetail.length > 0 ? stderrDetail : stdoutDetail;
|
|
88381
|
+
return yield* new TextGenerationError({
|
|
88382
|
+
operation,
|
|
88383
|
+
detail: detail.length > 0 ? `Codex CLI command failed: ${detail}` : `Codex CLI command failed with code ${exitCode}.`
|
|
88384
|
+
});
|
|
88385
|
+
}
|
|
88386
|
+
});
|
|
88387
|
+
const cleanup = Effect.all([
|
|
88388
|
+
schemaPath,
|
|
88389
|
+
outputPath,
|
|
88390
|
+
...cleanupPaths
|
|
88391
|
+
].map((filePath) => safeUnlink(filePath)), { concurrency: "unbounded" }).pipe(Effect.asVoid);
|
|
88392
|
+
return yield* Effect.gen(function* () {
|
|
88393
|
+
yield* runCodexCommand().pipe(Effect.scoped, Effect.timeoutOption(CODEX_TIMEOUT_MS), Effect.flatMap(Option.match({
|
|
88394
|
+
onNone: () => Effect.fail(new TextGenerationError({
|
|
88395
|
+
operation,
|
|
88396
|
+
detail: "Codex CLI request timed out."
|
|
88397
|
+
})),
|
|
88398
|
+
onSome: () => Effect.void
|
|
88399
|
+
})));
|
|
88400
|
+
const decodeOutput = Schema$1.decodeEffect(Schema$1.fromJsonString(outputSchemaJson));
|
|
88401
|
+
return yield* fileSystem.readFileString(outputPath).pipe(Effect.mapError((cause) => new TextGenerationError({
|
|
88402
|
+
operation,
|
|
88403
|
+
detail: "Failed to read Codex output file.",
|
|
88404
|
+
cause
|
|
88405
|
+
})), Effect.flatMap(decodeOutput), Effect.catchTags({ SchemaError: (cause) => Effect.fail(new TextGenerationError({
|
|
88406
|
+
operation,
|
|
88407
|
+
detail: "Codex returned invalid structured output.",
|
|
88408
|
+
cause
|
|
88409
|
+
})) }));
|
|
88410
|
+
}).pipe(Effect.ensuring(cleanup));
|
|
88411
|
+
});
|
|
88412
|
+
return {
|
|
88413
|
+
generateCommitMessage: Effect.fn("CodexTextGeneration.generateCommitMessage")(function* (input) {
|
|
88414
|
+
const { prompt, outputSchema } = buildCommitMessagePrompt({
|
|
88415
|
+
branch: input.branch,
|
|
88416
|
+
stagedSummary: input.stagedSummary,
|
|
88417
|
+
stagedPatch: input.stagedPatch,
|
|
88418
|
+
includeBranch: input.includeBranch === true,
|
|
88419
|
+
policy: input.policy
|
|
88420
|
+
});
|
|
88421
|
+
const generated = yield* runCodexJson({
|
|
88422
|
+
operation: "generateCommitMessage",
|
|
88423
|
+
cwd: input.cwd,
|
|
88424
|
+
prompt,
|
|
88425
|
+
outputSchemaJson: outputSchema,
|
|
88426
|
+
modelSelection: input.modelSelection
|
|
88427
|
+
});
|
|
88428
|
+
return {
|
|
88429
|
+
subject: sanitizeCommitSubject(generated.subject),
|
|
88430
|
+
body: generated.body.trim(),
|
|
88431
|
+
..."branch" in generated && typeof generated.branch === "string" ? { branch: sanitizeFeatureBranchName(generated.branch) } : {}
|
|
88432
|
+
};
|
|
88433
|
+
}),
|
|
88434
|
+
generatePrContent: Effect.fn("CodexTextGeneration.generatePrContent")(function* (input) {
|
|
88435
|
+
const { prompt, outputSchema } = buildPrContentPrompt({
|
|
88436
|
+
baseBranch: input.baseBranch,
|
|
88437
|
+
headBranch: input.headBranch,
|
|
88438
|
+
commitSummary: input.commitSummary,
|
|
88439
|
+
diffSummary: input.diffSummary,
|
|
88440
|
+
diffPatch: input.diffPatch,
|
|
88441
|
+
policy: input.policy,
|
|
88442
|
+
changeRequestTemplate: input.changeRequestTemplate
|
|
88443
|
+
});
|
|
88444
|
+
const generated = yield* runCodexJson({
|
|
88445
|
+
operation: "generatePrContent",
|
|
88446
|
+
cwd: input.cwd,
|
|
88447
|
+
prompt,
|
|
88448
|
+
outputSchemaJson: outputSchema,
|
|
88449
|
+
modelSelection: input.modelSelection
|
|
88450
|
+
});
|
|
88451
|
+
return {
|
|
88452
|
+
title: sanitizePrTitle(generated.title),
|
|
88453
|
+
body: generated.body.trim()
|
|
88454
|
+
};
|
|
88455
|
+
}),
|
|
88456
|
+
generateBranchName: Effect.fn("CodexTextGeneration.generateBranchName")(function* (input) {
|
|
88457
|
+
const { imagePaths } = yield* materializeImageAttachments("generateBranchName", input.attachments);
|
|
88458
|
+
const { prompt, outputSchema } = buildBranchNamePrompt({
|
|
88459
|
+
message: input.message,
|
|
88460
|
+
attachments: input.attachments
|
|
88461
|
+
});
|
|
88462
|
+
return { branch: sanitizeBranchFragment((yield* runCodexJson({
|
|
88463
|
+
operation: "generateBranchName",
|
|
88464
|
+
cwd: input.cwd,
|
|
88465
|
+
prompt,
|
|
88466
|
+
outputSchemaJson: outputSchema,
|
|
88467
|
+
imagePaths,
|
|
88468
|
+
modelSelection: input.modelSelection
|
|
88469
|
+
})).branch) };
|
|
88470
|
+
}),
|
|
88471
|
+
generateThreadTitle: Effect.fn("CodexTextGeneration.generateThreadTitle")(function* (input) {
|
|
88472
|
+
const { imagePaths } = yield* materializeImageAttachments("generateThreadTitle", input.attachments);
|
|
88473
|
+
const { prompt, outputSchema } = buildThreadTitlePrompt({
|
|
88474
|
+
message: input.message,
|
|
88475
|
+
attachments: input.attachments
|
|
88476
|
+
});
|
|
88477
|
+
return { title: sanitizeThreadTitle((yield* runCodexJson({
|
|
88478
|
+
operation: "generateThreadTitle",
|
|
88479
|
+
cwd: input.cwd,
|
|
88480
|
+
prompt,
|
|
88481
|
+
outputSchemaJson: outputSchema,
|
|
88482
|
+
imagePaths,
|
|
88483
|
+
modelSelection: input.modelSelection
|
|
88484
|
+
})).title) };
|
|
88485
|
+
}),
|
|
88486
|
+
getUsageReport: Effect.fn("CodexTextGeneration.getUsageReport")(function* () {
|
|
88487
|
+
const operation = "getUsageReport";
|
|
88488
|
+
const snapshot = yield* readCodexAccountUsage({
|
|
88489
|
+
binaryPath: codexConfig.binaryPath || "codex",
|
|
88490
|
+
...codexConfig.homePath ? { homePath: codexConfig.homePath } : {},
|
|
88491
|
+
launchArgs: resolveCodexLaunchArgs(codexConfig.launchArgs, resolvedEnvironment),
|
|
88492
|
+
cwd: serverConfig.cwd,
|
|
88493
|
+
environment: resolvedEnvironment
|
|
88494
|
+
}).pipe(Effect.mapError((cause) => new TextGenerationError({
|
|
88495
|
+
operation,
|
|
88496
|
+
detail: "Codex CLI could not read this account's usage.",
|
|
88497
|
+
cause
|
|
88498
|
+
})), Effect.scoped, Effect.timeoutOption(USAGE_REPORT_TIMEOUT_MS), Effect.flatMap(Option.match({
|
|
88499
|
+
onNone: () => Effect.fail(new TextGenerationError({
|
|
88500
|
+
operation,
|
|
88501
|
+
detail: "Codex CLI request timed out."
|
|
88502
|
+
})),
|
|
88503
|
+
onSome: (value) => Effect.succeed(value)
|
|
88504
|
+
})), Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, commandSpawner));
|
|
88505
|
+
return { report: formatCodexUsageReport({
|
|
88506
|
+
rateLimits: snapshot.rateLimits,
|
|
88507
|
+
usage: snapshot.usage,
|
|
88508
|
+
timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
88509
|
+
}) };
|
|
88510
|
+
})
|
|
88511
|
+
};
|
|
88512
|
+
});
|
|
88513
|
+
//#endregion
|
|
88514
|
+
//#region src/provider/Layers/codexMcpArgs.ts
|
|
88515
|
+
/** Codex's own name for the token variable of p4code's built-in server. */
|
|
88516
|
+
const CODEX_P4CODE_BEARER_TOKEN_ENV_VAR = "P4_MCP_BEARER_TOKEN";
|
|
88517
|
+
/** Prefix for the per-server variables the registered servers get. */
|
|
88518
|
+
const BEARER_TOKEN_ENV_VAR_PREFIX = "P4_MCP_BEARER_TOKEN_";
|
|
88519
|
+
/** TOML bare keys; anything else has to be quoted inside the dotted path. */
|
|
88520
|
+
const BARE_KEY = /^[A-Za-z0-9_-]+$/;
|
|
88521
|
+
const AUTHORIZATION_HEADER = "authorization";
|
|
88522
|
+
const BEARER_PREFIX = /^Bearer\s+/;
|
|
88523
|
+
const configKey = (name, field) => `mcp_servers.${BARE_KEY.test(name) ? name : JSON.stringify(name)}.${field}`;
|
|
88524
|
+
/**
|
|
88525
|
+
* A variable name derived from the server's, uniquely.
|
|
88526
|
+
*
|
|
88527
|
+
* Uppercased with every character a shell would not accept replaced, which can
|
|
88528
|
+
* collide (`a.b` and `a-b`), so the sanitized name is the prefix and the index
|
|
88529
|
+
* keeps it unique. The index is stable within one call, which is all that is
|
|
88530
|
+
* needed: the variable and the reference to it are emitted together.
|
|
88531
|
+
*/
|
|
88532
|
+
const bearerTokenEnvVar = (name, index) => `${BEARER_TOKEN_ENV_VAR_PREFIX}${name.toUpperCase().replace(/[^A-Z0-9]/g, "_")}_${index}`;
|
|
88533
|
+
/**
|
|
88534
|
+
* @param resolved - Servers keyed by name, as the registry resolved them.
|
|
88535
|
+
* @param exclude - Names p4code declares itself. A registration cannot displace
|
|
88536
|
+
* the built-in `p4-code` server, whose per-thread credential is the only
|
|
88537
|
+
* thing that makes `task_current` and the thread tools work.
|
|
88538
|
+
*/
|
|
88539
|
+
const toCodexMcpConfig = (resolved, exclude = /* @__PURE__ */ new Set()) => {
|
|
88540
|
+
const args = [];
|
|
88541
|
+
const env = {};
|
|
88542
|
+
const skipped = [];
|
|
88543
|
+
const push = (name, field, value) => {
|
|
88544
|
+
args.push("-c", `${configKey(name, field)}=${value}`);
|
|
88545
|
+
};
|
|
88546
|
+
let index = 0;
|
|
88547
|
+
for (const [name, server] of Object.entries(resolved)) {
|
|
88548
|
+
if (exclude.has(name)) continue;
|
|
88549
|
+
if (server.type === "stdio") {
|
|
88550
|
+
push(name, "command", JSON.stringify(server.command));
|
|
88551
|
+
push(name, "args", JSON.stringify(server.args));
|
|
88552
|
+
if (Object.keys(server.env).length > 0) push(name, "env", `{ ${Object.entries(server.env).map(([key, value]) => `${JSON.stringify(key)} = ${JSON.stringify(value)}`).join(", ")} }`);
|
|
88553
|
+
index += 1;
|
|
88554
|
+
continue;
|
|
88555
|
+
}
|
|
88556
|
+
if (server.type === "sse") {
|
|
88557
|
+
skipped.push({
|
|
88558
|
+
name,
|
|
88559
|
+
reason: "Codex speaks streamable HTTP, not SSE."
|
|
88560
|
+
});
|
|
88561
|
+
continue;
|
|
88562
|
+
}
|
|
88563
|
+
const headerNames = Object.keys(server.headers);
|
|
88564
|
+
const authorization = headerNames.find((key) => key.toLowerCase() === AUTHORIZATION_HEADER);
|
|
88565
|
+
const otherHeaders = headerNames.filter((key) => key !== authorization);
|
|
88566
|
+
if (otherHeaders.length > 0) {
|
|
88567
|
+
skipped.push({
|
|
88568
|
+
name,
|
|
88569
|
+
reason: `Codex sends no custom headers, and this server needs ${otherHeaders.join(", ")}.`
|
|
88570
|
+
});
|
|
88571
|
+
continue;
|
|
88572
|
+
}
|
|
88573
|
+
push(name, "url", JSON.stringify(server.url));
|
|
88574
|
+
if (authorization !== void 0) {
|
|
88575
|
+
const token = server.headers[authorization]?.replace(BEARER_PREFIX, "") ?? "";
|
|
88576
|
+
const variable = bearerTokenEnvVar(name, index);
|
|
88577
|
+
env[variable] = token;
|
|
88578
|
+
push(name, "bearer_token_env_var", JSON.stringify(variable));
|
|
88579
|
+
}
|
|
88580
|
+
index += 1;
|
|
88581
|
+
}
|
|
88582
|
+
return {
|
|
88583
|
+
args,
|
|
88584
|
+
env,
|
|
88585
|
+
skipped
|
|
88586
|
+
};
|
|
88587
|
+
};
|
|
88588
|
+
//#endregion
|
|
87881
88589
|
//#region src/provider/CodexDeveloperInstructions.ts
|
|
87882
88590
|
const P4_CODE_BROWSER_TOOL_INSTRUCTIONS = `
|
|
87883
88591
|
|
|
@@ -103874,6 +104582,7 @@ const make$4 = Effect.gen(function* () {
|
|
|
103874
104582
|
const projectionSnapshotQuery = yield* ProjectionSnapshotQuery;
|
|
103875
104583
|
const providerService = yield* ProviderService;
|
|
103876
104584
|
const projectionTurnRepository = yield* ProjectionTurnRepository;
|
|
104585
|
+
const threadBackgroundLiveness = yield* ThreadBackgroundLivenessService;
|
|
103877
104586
|
const serverSettingsService = yield* ServerSettingsService;
|
|
103878
104587
|
const taskRepositories = yield* TaskRepositoryRegistry;
|
|
103879
104588
|
const providerCommandId = (event, tag) => crypto.randomUUIDv4.pipe(Effect.map((uuid) => CommandId.make(`provider:${event.eventId}:${tag}:${uuid}`)));
|
|
@@ -104160,6 +104869,26 @@ const make$4 = Effect.gen(function* () {
|
|
|
104160
104869
|
const processRuntimeEvent = (event) => Effect.gen(function* () {
|
|
104161
104870
|
const thread = yield* resolveThreadShell(event.threadId);
|
|
104162
104871
|
if (!thread) return;
|
|
104872
|
+
switch (event.type) {
|
|
104873
|
+
case "task.started":
|
|
104874
|
+
case "task.progress":
|
|
104875
|
+
case "task.completed": {
|
|
104876
|
+
const payload = event.payload;
|
|
104877
|
+
threadBackgroundLiveness.recordTaskLiveness({
|
|
104878
|
+
threadId: thread.id,
|
|
104879
|
+
taskId: payload.taskId,
|
|
104880
|
+
taskType: payload.taskType,
|
|
104881
|
+
status: payload.status,
|
|
104882
|
+
agentId: payload.agentId,
|
|
104883
|
+
kind: event.type === "task.started" ? "started" : event.type === "task.progress" ? "progress" : "completed"
|
|
104884
|
+
});
|
|
104885
|
+
break;
|
|
104886
|
+
}
|
|
104887
|
+
case "session.exited":
|
|
104888
|
+
threadBackgroundLiveness.clearThreadLiveness(thread.id);
|
|
104889
|
+
break;
|
|
104890
|
+
default: break;
|
|
104891
|
+
}
|
|
104163
104892
|
let loadedThreadDetail;
|
|
104164
104893
|
const getLoadedThreadDetail = () => Effect.gen(function* () {
|
|
104165
104894
|
if (loadedThreadDetail !== void 0) return loadedThreadDetail;
|
|
@@ -104477,7 +105206,7 @@ const make$4 = Effect.gen(function* () {
|
|
|
104477
105206
|
drain: worker.drain
|
|
104478
105207
|
};
|
|
104479
105208
|
});
|
|
104480
|
-
const ProviderRuntimeIngestionLive = Layer.effect(ProviderRuntimeIngestionService, make$4).pipe(Layer.provide(ProjectionTurnRepositoryLive));
|
|
105209
|
+
const ProviderRuntimeIngestionLive = Layer.effect(ProviderRuntimeIngestionService, make$4).pipe(Layer.provide(ProjectionTurnRepositoryLive), Layer.provide(layer$63));
|
|
104481
105210
|
//#endregion
|
|
104482
105211
|
//#region src/provider/userInvokedSkills.ts
|
|
104483
105212
|
/**
|
|
@@ -107229,11 +107958,11 @@ const WorkspaceEntriesLayerLive = layer$32.pipe(Layer.provide(layer$52));
|
|
|
107229
107958
|
const WorkspaceFileSystemLayerLive = layer$31.pipe(Layer.provide(layer$52), Layer.provide(WorkspaceEntriesLayerLive));
|
|
107230
107959
|
const WorkspaceLayerLive = Layer.mergeAll(layer$52, WorkspaceEntriesLayerLive, WorkspaceFileSystemLayerLive);
|
|
107231
107960
|
const ProjectFaviconResolverLayerLive = layer$50.pipe(Layer.provide(layer$52), Layer.provide(layer$51));
|
|
107232
|
-
const AuthLayerLive = layer$
|
|
107961
|
+
const AuthLayerLive = layer$73.pipe(Layer.provideMerge(PersistenceLayerLive), Layer.provide(layer$77));
|
|
107233
107962
|
const ProviderRuntimeLayerLive = ProviderSessionReaperLive.pipe(Layer.provideMerge(ProviderLayerLive), Layer.provideMerge(OrchestrationLayerLive));
|
|
107234
|
-
const RuntimeCoreDependenciesLive = ReactorLayerLive.pipe(Layer.provideMerge(CheckpointingLayerLive), Layer.provideMerge(SourceControlProviderRegistryLayerLive), Layer.provideMerge(GitLayerLive), Layer.provideMerge(VcsLayerLive), Layer.provideMerge(ProviderRuntimeLayerLive), Layer.provideMerge(Layer.mergeAll(TerminalLayerLive, PreviewLayerLive, RoutedTaskRepositoryLive)), Layer.provideMerge(Layer.mergeAll(PersistenceLayerLive, layer$
|
|
107235
|
-
const UsageLayerLive = layer$40.pipe(Layer.provide(layer$
|
|
107236
|
-
const RuntimeDependenciesLive = layer$39.pipe(Layer.provideMerge(RuntimeCoreDependenciesLive)).pipe(Layer.provideMerge(UsageLayerLive), Layer.provideMerge(layer$15), Layer.provideMerge(layer$14), Layer.provideMerge(layer$13), Layer.provideMerge(layer$57), Layer.provideMerge(layer$59), Layer.provideMerge(layer$58), Layer.provide(layer$
|
|
107963
|
+
const RuntimeCoreDependenciesLive = ReactorLayerLive.pipe(Layer.provideMerge(CheckpointingLayerLive), Layer.provideMerge(SourceControlProviderRegistryLayerLive), Layer.provideMerge(GitLayerLive), Layer.provideMerge(VcsLayerLive), Layer.provideMerge(ProviderRuntimeLayerLive), Layer.provideMerge(Layer.mergeAll(TerminalLayerLive, PreviewLayerLive, RoutedTaskRepositoryLive)), Layer.provideMerge(Layer.mergeAll(PersistenceLayerLive, layer$66)), Layer.provideMerge(layer$60), Layer.provideMerge(ProviderRegistryLive), Layer.provideMerge(ProviderInstanceRegistryHydrationLive), Layer.provideMerge(ProviderEventLoggersLive), Layer.provideMerge(OpenCodeRuntimeLive), Layer.provideMerge(layer$70.pipe(Layer.provide(layer$77))), Layer.provideMerge(WorkspaceLayerLive), Layer.provideMerge(ProjectFaviconResolverLayerLive), Layer.provideMerge(layer$61), Layer.provideMerge(layer$54), Layer.provideMerge(AuthLayerLive), Layer.provideMerge(layer$1.pipe(Layer.provideMerge(LinearClientLive), Layer.provideMerge(Layer.mergeAll(LinearMcpClientLive, TrackerSecretsLive)), Layer.provideMerge(Layer.mergeAll(layer$67, layer$38).pipe(Layer.provideMerge(layer$68), Layer.provideMerge(layer$69))))), Layer.provideMerge(layer$77));
|
|
107964
|
+
const UsageLayerLive = layer$40.pipe(Layer.provide(layer$70.pipe(Layer.provide(layer$77))));
|
|
107965
|
+
const RuntimeDependenciesLive = layer$39.pipe(Layer.provideMerge(RuntimeCoreDependenciesLive)).pipe(Layer.provideMerge(UsageLayerLive), Layer.provideMerge(layer$15), Layer.provideMerge(layer$14), Layer.provideMerge(layer$13), Layer.provideMerge(layer$57), Layer.provideMerge(layer$59), Layer.provideMerge(layer$58), Layer.provide(layer$81));
|
|
107237
107966
|
/**
|
|
107238
107967
|
* Hub asset sync.
|
|
107239
107968
|
*
|
|
@@ -107241,7 +107970,7 @@ const RuntimeDependenciesLive = layer$39.pipe(Layer.provideMerge(RuntimeCoreDepe
|
|
|
107241
107970
|
* not-configured shape, and every call reports that rather than failing — so
|
|
107242
107971
|
* this costs a server with no hub nothing but a layer.
|
|
107243
107972
|
*/
|
|
107244
|
-
const AssetSyncLive = layer$
|
|
107973
|
+
const AssetSyncLive = layer$64.pipe(Layer.provideMerge(layer$65), Layer.provideMerge(layer$66));
|
|
107245
107974
|
const RuntimeServicesLive = layer$53.pipe(Layer.provideMerge(AssetSyncLive), Layer.provideMerge(RuntimeDependenciesLive));
|
|
107246
107975
|
const PullRequestServiceLive = layer$7.pipe(Layer.provide(layer$8), Layer.provide(SourceControlProviderRegistryLayerLive), Layer.provide(layer$48));
|
|
107247
107976
|
const makeRoutesLayer = Layer.mergeAll(Layer.mergeAll(HttpApiBuilder.layer(EnvironmentHttpApi).pipe(Layer.provide(authHttpApiLayer), Layer.provide(orchestrationHttpApiLayer), Layer.provide(pullRequestHttpApiLayer), Layer.provide(serverEnvironmentHttpApiLayer), Layer.provide(environmentAuthenticatedAuthLayer)), otlpTracesProxyRouteLayer, assetRouteLayer, mcpOAuthCallbackRouteLayer, staticAndDevRouteLayer, websocketRpcRouteLayer), layer.pipe(Layer.provide(layer$3))).pipe(Layer.provide(ProjectionProjectRepositoryLive.pipe(Layer.provide(PersistenceLayerLive))), Layer.provide(layer$51), Layer.provide(PullRequestServiceLive), Layer.provide(layer$35), Layer.provide(layer$55), Layer.provide(browserApiCorsLayer), Layer.provide(httpCompressionLayer));
|
|
@@ -107882,7 +108611,7 @@ const serviceCommand = Command.make("service").pipe(Command.withDescription("Man
|
|
|
107882
108611
|
]));
|
|
107883
108612
|
//#endregion
|
|
107884
108613
|
//#region src/bin.ts
|
|
107885
|
-
const CliRuntimeLayer = Layer.mergeAll(NodeServices.layer, layer$
|
|
108614
|
+
const CliRuntimeLayer = Layer.mergeAll(NodeServices.layer, layer$81, FetchHttpClient.layer);
|
|
107886
108615
|
/**
|
|
107887
108616
|
* Prints an update reminder before dispatching, at most once a day.
|
|
107888
108617
|
*
|