@alan-ai-hq/agent-manager-linux-x64 0.1.178 → 0.1.180
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/alan-agent.cjs +119369 -50098
- package/alan-holder.cjs +82460 -17646
- package/alan-lease.cjs +1571 -318
- package/package.json +2 -2
package/alan-lease.cjs
CHANGED
|
@@ -13267,9 +13267,9 @@ function codePointLengthVar(doc, ctx, accessor, inDoubt) {
|
|
|
13267
13267
|
doc.write(`const ${v} = typeof ${accessor} === "string" && ${inDoubt} ? ${cpLen}(${accessor}) : ${accessor}.length;`);
|
|
13268
13268
|
return v;
|
|
13269
13269
|
}
|
|
13270
|
-
function numericOperand(value,
|
|
13270
|
+
function numericOperand(value, label3) {
|
|
13271
13271
|
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
13272
|
-
throw new ZodCompileUnsupportedError(`${
|
|
13272
|
+
throw new ZodCompileUnsupportedError(`${label3} bound of type ${typeof value}`);
|
|
13273
13273
|
}
|
|
13274
13274
|
return `${value}`;
|
|
13275
13275
|
}
|
|
@@ -15589,12 +15589,12 @@ function _check(fn, params) {
|
|
|
15589
15589
|
return ch;
|
|
15590
15590
|
}
|
|
15591
15591
|
// @__NO_SIDE_EFFECTS__
|
|
15592
|
-
function describe(
|
|
15592
|
+
function describe(description2) {
|
|
15593
15593
|
const ch = new $ZodCheck({ check: "describe" });
|
|
15594
15594
|
ch._zod.onattach = [
|
|
15595
15595
|
(inst) => {
|
|
15596
15596
|
const existing = globalRegistry.get(inst) ?? {};
|
|
15597
|
-
globalRegistry.add(inst, { ...existing, description });
|
|
15597
|
+
globalRegistry.add(inst, { ...existing, description: description2 });
|
|
15598
15598
|
}
|
|
15599
15599
|
];
|
|
15600
15600
|
ch._zod.check = () => {
|
|
@@ -16322,8 +16322,8 @@ function rewriteKeyNames(ctx) {
|
|
|
16322
16322
|
bySchema.set(entry.schema, entry);
|
|
16323
16323
|
}
|
|
16324
16324
|
const rewrites = /* @__PURE__ */ new Map();
|
|
16325
|
-
for (const
|
|
16326
|
-
const seen = ctx.seen.get(
|
|
16325
|
+
for (const record3 of pendingRecords.get(ctx) ?? []) {
|
|
16326
|
+
const seen = ctx.seen.get(record3);
|
|
16327
16327
|
const names = (seen?.def ?? seen?.schema)?.propertyNames;
|
|
16328
16328
|
if (!names || names === true || rewrites.has(names))
|
|
16329
16329
|
continue;
|
|
@@ -16778,8 +16778,8 @@ var init_json_schema_processors = __esm({
|
|
|
16778
16778
|
let minItems = def.items.length;
|
|
16779
16779
|
while (minItems > 0) {
|
|
16780
16780
|
const item = def.items[minItems - 1];
|
|
16781
|
-
const
|
|
16782
|
-
if (!
|
|
16781
|
+
const optional3 = ctx.io === "input" ? inputOptin(item) !== void 0 : item._zod.optout === "optional";
|
|
16782
|
+
if (!optional3)
|
|
16783
16783
|
break;
|
|
16784
16784
|
minItems--;
|
|
16785
16785
|
}
|
|
@@ -18316,9 +18316,9 @@ var init_schemas2 = __esm({
|
|
|
18316
18316
|
readonly() {
|
|
18317
18317
|
return readonly(this);
|
|
18318
18318
|
},
|
|
18319
|
-
describe(
|
|
18319
|
+
describe(description2) {
|
|
18320
18320
|
const cl = this.clone();
|
|
18321
|
-
globalRegistry.add(cl, { description });
|
|
18321
|
+
globalRegistry.add(cl, { description: description2 });
|
|
18322
18322
|
return cl;
|
|
18323
18323
|
},
|
|
18324
18324
|
meta(...args) {
|
|
@@ -20997,7 +20997,9 @@ var init_agent_context = __esm({
|
|
|
20997
20997
|
]);
|
|
20998
20998
|
agentContextParticipantSchema = external_exports.object({
|
|
20999
20999
|
name: external_exports.string().min(1).max(200),
|
|
21000
|
-
slackUserId: external_exports.string().min(1).max(64),
|
|
21000
|
+
slackUserId: external_exports.string().min(1).max(64).optional(),
|
|
21001
|
+
teamsUserId: external_exports.string().min(1).max(200).optional(),
|
|
21002
|
+
email: external_exports.string().max(320).optional(),
|
|
21001
21003
|
handle: external_exports.string().max(200).optional(),
|
|
21002
21004
|
standing: agentParticipantStandingSchema.optional()
|
|
21003
21005
|
});
|
|
@@ -21039,7 +21041,7 @@ var init_agent_context = __esm({
|
|
|
21039
21041
|
external_exports.object({ status: external_exports.literal("none") })
|
|
21040
21042
|
]);
|
|
21041
21043
|
agentContextSurfaceSchema = external_exports.object({
|
|
21042
|
-
provider: external_exports.enum(["slack"]),
|
|
21044
|
+
provider: external_exports.enum(["slack", "microsoft_teams"]),
|
|
21043
21045
|
workspace: external_exports.string().min(1).max(200),
|
|
21044
21046
|
channel: external_exports.string().min(1).max(200),
|
|
21045
21047
|
kind: external_exports.enum(["thread", "dm"]),
|
|
@@ -21049,7 +21051,14 @@ var init_agent_context = __esm({
|
|
|
21049
21051
|
/** The person whose message started the session, with the Alan account it runs for. */
|
|
21050
21052
|
startedBy: agentContextParticipantSchema.extend({ alanUserId: external_exports.guid() }).optional(),
|
|
21051
21053
|
repo: agentRepoResolutionSchema.optional(),
|
|
21052
|
-
participants: external_exports.array(agentContextParticipantSchema)
|
|
21054
|
+
participants: external_exports.array(agentContextParticipantSchema)
|
|
21055
|
+
}).superRefine((surface, context) => {
|
|
21056
|
+
if (surface.provider === "slack" && surface.participants.length > 100)
|
|
21057
|
+
context.addIssue({
|
|
21058
|
+
code: "custom",
|
|
21059
|
+
path: ["participants"],
|
|
21060
|
+
message: "Slack participants exceed 100"
|
|
21061
|
+
});
|
|
21053
21062
|
});
|
|
21054
21063
|
agentContextSchema = external_exports.object({
|
|
21055
21064
|
kind: agentSessionKindSchema,
|
|
@@ -21420,6 +21429,33 @@ var init_commit_attribution = __esm({
|
|
|
21420
21429
|
}
|
|
21421
21430
|
});
|
|
21422
21431
|
|
|
21432
|
+
// ../shared/src/runtime-v2/delegation.ts
|
|
21433
|
+
var BOUNDED_DELEGATION_FEATURE, boundedDelegationRequestSchema, boundedDelegationLimitsSchema, delegationResultSchema, boundedDelegationSchema;
|
|
21434
|
+
var init_delegation = __esm({
|
|
21435
|
+
"../shared/src/runtime-v2/delegation.ts"() {
|
|
21436
|
+
"use strict";
|
|
21437
|
+
init_zod();
|
|
21438
|
+
BOUNDED_DELEGATION_FEATURE = "bounded_delegation_v1";
|
|
21439
|
+
boundedDelegationRequestSchema = external_exports.object({
|
|
21440
|
+
maxTurns: external_exports.number().int().min(1).max(100).default(20),
|
|
21441
|
+
timeoutSeconds: external_exports.number().int().min(10).max(3600).default(600)
|
|
21442
|
+
});
|
|
21443
|
+
boundedDelegationLimitsSchema = external_exports.object({
|
|
21444
|
+
maxTurns: external_exports.number().int().min(1).max(100),
|
|
21445
|
+
deadline: external_exports.iso.datetime()
|
|
21446
|
+
});
|
|
21447
|
+
delegationResultSchema = external_exports.object({
|
|
21448
|
+
status: external_exports.enum(["completed", "blocked", "failed", "cancelled"]),
|
|
21449
|
+
summary: external_exports.string().trim().min(1).max(1e4),
|
|
21450
|
+
evidence: external_exports.array(external_exports.string().trim().min(1).max(2e3)).max(20).default([])
|
|
21451
|
+
});
|
|
21452
|
+
boundedDelegationSchema = boundedDelegationLimitsSchema.extend({
|
|
21453
|
+
result: delegationResultSchema.optional(),
|
|
21454
|
+
finishedAt: external_exports.iso.datetime().optional()
|
|
21455
|
+
});
|
|
21456
|
+
}
|
|
21457
|
+
});
|
|
21458
|
+
|
|
21423
21459
|
// ../shared/src/runtime-v2/run-context.ts
|
|
21424
21460
|
function wire() {
|
|
21425
21461
|
return (schema) => schema;
|
|
@@ -21483,6 +21519,7 @@ var init_run_context = __esm({
|
|
|
21483
21519
|
pdfType: external_exports.string().optional(),
|
|
21484
21520
|
pagesNeedingOcr: external_exports.array(external_exports.number().int()).optional(),
|
|
21485
21521
|
hasEncodingIssues: external_exports.boolean().optional(),
|
|
21522
|
+
omissionReason: external_exports.literal("attachment_limit").optional(),
|
|
21486
21523
|
errorCode: external_exports.enum([
|
|
21487
21524
|
"invalid_pdf",
|
|
21488
21525
|
"encrypted_pdf",
|
|
@@ -21572,6 +21609,65 @@ var init_run_context = __esm({
|
|
|
21572
21609
|
}
|
|
21573
21610
|
});
|
|
21574
21611
|
|
|
21612
|
+
// ../shared/src/runtime-v2/session-interaction.ts
|
|
21613
|
+
var SESSION_INTERACTION_FEATURE, RUNTIME_FEATURE_HEADER, runtimeFeaturesSchema, runtimeFeatureHeaderSchema, sessionInteractionSchema, sessionPermissionReplySchema, sessionQuestionAnswersSchema, SESSION_SELECTION_FEATURE, sessionSelectionSchema;
|
|
21614
|
+
var init_session_interaction = __esm({
|
|
21615
|
+
"../shared/src/runtime-v2/session-interaction.ts"() {
|
|
21616
|
+
"use strict";
|
|
21617
|
+
init_zod();
|
|
21618
|
+
SESSION_INTERACTION_FEATURE = "session_interaction_v1";
|
|
21619
|
+
RUNTIME_FEATURE_HEADER = "x-alan-runtime-features";
|
|
21620
|
+
runtimeFeaturesSchema = external_exports.array(external_exports.string().regex(/^[a-z0-9_]{1,64}$/)).max(32);
|
|
21621
|
+
runtimeFeatureHeaderSchema = external_exports.string().max(2079).transform((value) => value === "" ? [] : value.split(",")).pipe(runtimeFeaturesSchema);
|
|
21622
|
+
sessionInteractionSchema = external_exports.strictObject({
|
|
21623
|
+
permissions: external_exports.enum(["ask", "auto"]),
|
|
21624
|
+
questions: external_exports.literal(true)
|
|
21625
|
+
});
|
|
21626
|
+
sessionPermissionReplySchema = external_exports.enum(["once", "always", "reject"]);
|
|
21627
|
+
sessionQuestionAnswersSchema = external_exports.array(external_exports.array(external_exports.string()));
|
|
21628
|
+
SESSION_SELECTION_FEATURE = "session_selection_v1";
|
|
21629
|
+
sessionSelectionSchema = external_exports.strictObject({
|
|
21630
|
+
model: external_exports.string().min(1).max(500),
|
|
21631
|
+
mode: external_exports.enum(["agent", "plan", "ask", "review"]),
|
|
21632
|
+
effort: external_exports.string().min(1).max(256).refine(
|
|
21633
|
+
(value) => [...value].every(
|
|
21634
|
+
(character) => character.charCodeAt(0) > 31 && character.charCodeAt(0) !== 127
|
|
21635
|
+
)
|
|
21636
|
+
).nullable()
|
|
21637
|
+
});
|
|
21638
|
+
}
|
|
21639
|
+
});
|
|
21640
|
+
|
|
21641
|
+
// ../shared/src/runtime-v2/session-operation.ts
|
|
21642
|
+
var SESSION_OPERATIONS_FEATURE, selector, sessionOperationSchema;
|
|
21643
|
+
var init_session_operation = __esm({
|
|
21644
|
+
"../shared/src/runtime-v2/session-operation.ts"() {
|
|
21645
|
+
"use strict";
|
|
21646
|
+
init_zod();
|
|
21647
|
+
SESSION_OPERATIONS_FEATURE = "session_operations_v1";
|
|
21648
|
+
selector = external_exports.string().min(1).max(256).refine(
|
|
21649
|
+
(value) => [...value].every(
|
|
21650
|
+
(character) => character.charCodeAt(0) > 31 && character.charCodeAt(0) !== 127
|
|
21651
|
+
)
|
|
21652
|
+
);
|
|
21653
|
+
sessionOperationSchema = external_exports.discriminatedUnion("kind", [
|
|
21654
|
+
external_exports.strictObject({
|
|
21655
|
+
kind: external_exports.literal("shell"),
|
|
21656
|
+
command: external_exports.string().min(1).max(1048576),
|
|
21657
|
+
agent: selector.optional()
|
|
21658
|
+
}),
|
|
21659
|
+
external_exports.strictObject({
|
|
21660
|
+
kind: external_exports.literal("command"),
|
|
21661
|
+
command: selector,
|
|
21662
|
+
arguments: external_exports.string().max(1048576),
|
|
21663
|
+
agent: selector.optional(),
|
|
21664
|
+
variant: selector.optional()
|
|
21665
|
+
}),
|
|
21666
|
+
external_exports.strictObject({ kind: external_exports.literal("compact") })
|
|
21667
|
+
]);
|
|
21668
|
+
}
|
|
21669
|
+
});
|
|
21670
|
+
|
|
21575
21671
|
// ../shared/src/runtime-v2/desired-state.ts
|
|
21576
21672
|
var repoLocalPathSchema, requestedCheckoutSchema, runSpecSchema, desiredRunSchema, pendingUploadSchema, STOP_RUN_IDS_LIMIT, desiredStateSchema;
|
|
21577
21673
|
var init_desired_state = __esm({
|
|
@@ -21582,8 +21678,11 @@ var init_desired_state = __esm({
|
|
|
21582
21678
|
init_contracts();
|
|
21583
21679
|
init_agent_context();
|
|
21584
21680
|
init_commit_attribution();
|
|
21681
|
+
init_delegation();
|
|
21585
21682
|
init_ids();
|
|
21586
21683
|
init_run_context();
|
|
21684
|
+
init_session_interaction();
|
|
21685
|
+
init_session_operation();
|
|
21587
21686
|
init_workspace();
|
|
21588
21687
|
repoLocalPathSchema = external_exports.object({
|
|
21589
21688
|
repoId: external_exports.string().min(1).optional(),
|
|
@@ -21608,6 +21707,9 @@ var init_desired_state = __esm({
|
|
|
21608
21707
|
selectedContextWindow: external_exports.string().min(1).optional(),
|
|
21609
21708
|
selectedEffortLevel: external_exports.string().min(1).optional(),
|
|
21610
21709
|
mode: external_exports.string().min(1).optional(),
|
|
21710
|
+
interaction: sessionInteractionSchema.optional(),
|
|
21711
|
+
selection: sessionSelectionSchema.optional(),
|
|
21712
|
+
operation: sessionOperationSchema.optional(),
|
|
21611
21713
|
providerSessionId: external_exports.string().min(1).optional(),
|
|
21612
21714
|
resumeFallbackContext: external_exports.string().optional(),
|
|
21613
21715
|
projectPath: external_exports.string().min(1).optional(),
|
|
@@ -21622,6 +21724,7 @@ var init_desired_state = __esm({
|
|
|
21622
21724
|
agentId: external_exports.string().min(1).optional(),
|
|
21623
21725
|
agentPrompt: external_exports.string().optional(),
|
|
21624
21726
|
maxIterations: external_exports.number().int().positive().optional(),
|
|
21727
|
+
delegation: boundedDelegationLimitsSchema.optional(),
|
|
21625
21728
|
/** The transcript rows this turn writes to; the assistant message id keys the run log upload. */
|
|
21626
21729
|
userMessage: canonicalUserMessageSchema.optional(),
|
|
21627
21730
|
assistantMessage: canonicalAssistantMessageSchema.optional(),
|
|
@@ -21655,6 +21758,18 @@ var init_desired_state = __esm({
|
|
|
21655
21758
|
STOP_RUN_IDS_LIMIT = 200;
|
|
21656
21759
|
desiredStateSchema = external_exports.object({
|
|
21657
21760
|
runs: external_exports.array(desiredRunSchema),
|
|
21761
|
+
blockedRuns: external_exports.array(
|
|
21762
|
+
external_exports.object({
|
|
21763
|
+
runId: runIdSchema,
|
|
21764
|
+
feature: external_exports.enum([
|
|
21765
|
+
"session_interaction_v1",
|
|
21766
|
+
"session_operations_v1",
|
|
21767
|
+
"session_selection_v1",
|
|
21768
|
+
"bounded_delegation_v1"
|
|
21769
|
+
]),
|
|
21770
|
+
reason: external_exports.enum(["runtime_feature_unsupported", "runtime_link_not_ready"])
|
|
21771
|
+
})
|
|
21772
|
+
).optional(),
|
|
21658
21773
|
/** The machine's saved workspaces; replaces the previous server list on every read. */
|
|
21659
21774
|
approvedWorkspacePaths: external_exports.array(machinePathSchema).max(2e3).optional(),
|
|
21660
21775
|
/** Absent from an older server: the runtime then uploads only on its own doorbell. */
|
|
@@ -21819,6 +21934,7 @@ var init_link = __esm({
|
|
|
21819
21934
|
init_desired_state();
|
|
21820
21935
|
init_ids();
|
|
21821
21936
|
init_machine_identity();
|
|
21937
|
+
init_session_interaction();
|
|
21822
21938
|
init_workspace();
|
|
21823
21939
|
LINK_PROTOCOL = 2;
|
|
21824
21940
|
linkHandshakeSchema = external_exports.object({
|
|
@@ -21836,7 +21952,8 @@ var init_link = __esm({
|
|
|
21836
21952
|
});
|
|
21837
21953
|
helloSchema = external_exports.object({
|
|
21838
21954
|
epoch: external_exports.number().int().positive(),
|
|
21839
|
-
runs: external_exports.array(heldRunSchema)
|
|
21955
|
+
runs: external_exports.array(heldRunSchema),
|
|
21956
|
+
features: runtimeFeaturesSchema.optional()
|
|
21840
21957
|
});
|
|
21841
21958
|
helloAckSchema = external_exports.object({
|
|
21842
21959
|
desired: desiredStateSchema,
|
|
@@ -22007,56 +22124,27 @@ var init_capabilities = __esm({
|
|
|
22007
22124
|
}
|
|
22008
22125
|
});
|
|
22009
22126
|
|
|
22010
|
-
// ../shared/src/
|
|
22011
|
-
var
|
|
22012
|
-
var
|
|
22013
|
-
"../shared/src/
|
|
22127
|
+
// ../shared/src/validators/attachments.ts
|
|
22128
|
+
var MAX_COMMENT_ATTACHMENTS, requestPresignedUploadSchema, linkAttachmentSchema, renameAttachmentSchema;
|
|
22129
|
+
var init_attachments = __esm({
|
|
22130
|
+
"../shared/src/validators/attachments.ts"() {
|
|
22014
22131
|
"use strict";
|
|
22015
22132
|
init_zod();
|
|
22016
|
-
|
|
22017
|
-
|
|
22018
|
-
|
|
22019
|
-
|
|
22020
|
-
|
|
22021
|
-
|
|
22022
|
-
|
|
22023
|
-
|
|
22024
|
-
machineGitCapabilitySchema = external_exports.object({
|
|
22025
|
-
capability: external_exports.string().min(1),
|
|
22026
|
-
expiresInSeconds: external_exports.number().int().positive(),
|
|
22027
|
-
repoUrl: external_exports.url(),
|
|
22028
|
-
warnings: external_exports.array(machineGitCapabilityWarningSchema)
|
|
22133
|
+
MAX_COMMENT_ATTACHMENTS = 10;
|
|
22134
|
+
requestPresignedUploadSchema = external_exports.object({
|
|
22135
|
+
filename: external_exports.string().min(1).max(500),
|
|
22136
|
+
mimeType: external_exports.string().min(1).max(200),
|
|
22137
|
+
size: external_exports.number().int().positive().max(50 * 1024 * 1024),
|
|
22138
|
+
// 50MB max
|
|
22139
|
+
entityType: external_exports.string().min(1).max(50),
|
|
22140
|
+
entityId: external_exports.uuid().optional()
|
|
22029
22141
|
});
|
|
22030
|
-
|
|
22031
|
-
|
|
22032
|
-
|
|
22142
|
+
linkAttachmentSchema = external_exports.object({
|
|
22143
|
+
entityType: external_exports.string().min(1).max(50),
|
|
22144
|
+
entityId: external_exports.uuid()
|
|
22033
22145
|
});
|
|
22034
|
-
|
|
22035
|
-
|
|
22036
|
-
|
|
22037
|
-
// ../shared/src/runtime-v2/github-proxy.ts
|
|
22038
|
-
var GITHUB_PROXY_UPSTREAMS, gitHubProxyUpstreamSchema, GITHUB_PROXY_REFUSAL_CODES, gitHubProxyErrorSchema;
|
|
22039
|
-
var init_github_proxy = __esm({
|
|
22040
|
-
"../shared/src/runtime-v2/github-proxy.ts"() {
|
|
22041
|
-
"use strict";
|
|
22042
|
-
init_zod();
|
|
22043
|
-
GITHUB_PROXY_UPSTREAMS = [
|
|
22044
|
-
"api.github.com",
|
|
22045
|
-
"uploads.github.com",
|
|
22046
|
-
"github.com"
|
|
22047
|
-
];
|
|
22048
|
-
gitHubProxyUpstreamSchema = external_exports.enum(GITHUB_PROXY_UPSTREAMS);
|
|
22049
|
-
GITHUB_PROXY_REFUSAL_CODES = [
|
|
22050
|
-
"host_not_proxied",
|
|
22051
|
-
"machine_not_allowed",
|
|
22052
|
-
"github_not_connected",
|
|
22053
|
-
"github_installation_unavailable"
|
|
22054
|
-
];
|
|
22055
|
-
gitHubProxyErrorSchema = external_exports.object({
|
|
22056
|
-
message: external_exports.string().min(1),
|
|
22057
|
-
documentation_url: external_exports.string(),
|
|
22058
|
-
status: external_exports.string(),
|
|
22059
|
-
alan_code: external_exports.enum(GITHUB_PROXY_REFUSAL_CODES)
|
|
22146
|
+
renameAttachmentSchema = external_exports.object({
|
|
22147
|
+
displayName: external_exports.string().trim().min(1).max(500)
|
|
22060
22148
|
});
|
|
22061
22149
|
}
|
|
22062
22150
|
});
|
|
@@ -22393,136 +22481,994 @@ var init_run_log = __esm({
|
|
|
22393
22481
|
}
|
|
22394
22482
|
});
|
|
22395
22483
|
|
|
22396
|
-
// ../shared/src/runtime-v2/
|
|
22397
|
-
|
|
22398
|
-
|
|
22399
|
-
|
|
22484
|
+
// ../shared/src/runtime-v2/session-presentation.ts
|
|
22485
|
+
function record2(value) {
|
|
22486
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
22487
|
+
}
|
|
22488
|
+
function optional2(schema, value) {
|
|
22489
|
+
const result = schema.safeParse(value);
|
|
22490
|
+
return result.success ? result.data : void 0;
|
|
22491
|
+
}
|
|
22492
|
+
function withSessionPresentation(value) {
|
|
22493
|
+
const update = record2(value);
|
|
22494
|
+
if (!update) return value;
|
|
22495
|
+
const existing = optional2(sessionPresentationSchema, update.presentation);
|
|
22496
|
+
const meta3 = record2(update._meta);
|
|
22497
|
+
const presentation = { ...existing };
|
|
22498
|
+
const parent = optional2(external_exports.string().min(1), meta3?.["alan.dev/parentToolCallId"]);
|
|
22499
|
+
if (parent !== void 0) presentation.parentToolCallId = parent;
|
|
22500
|
+
if (update.sessionUpdate === "tool_call_update") {
|
|
22501
|
+
const input2 = record2(update.rawInput);
|
|
22502
|
+
const display = input2 && optional2(sessionToolDisplayInputSchema, {
|
|
22503
|
+
...input2,
|
|
22504
|
+
subagentType: input2.subagent_type
|
|
22505
|
+
});
|
|
22506
|
+
if (display && Object.values(display).some((field) => field !== void 0))
|
|
22507
|
+
presentation.toolInput = display;
|
|
22508
|
+
const questions = optional2(
|
|
22509
|
+
external_exports.array(sessionQuestionSchema),
|
|
22510
|
+
meta3?.["alan.dev/askUserQuestions"] ?? input2?.questions
|
|
22511
|
+
);
|
|
22512
|
+
if (questions?.length) presentation.questions = questions;
|
|
22513
|
+
const answer = optional2(external_exports.string(), meta3?.["alan.dev/userAnswer"]);
|
|
22514
|
+
if (answer !== void 0) presentation.answer = answer;
|
|
22515
|
+
if (meta3?.["alan.dev/subagentLauncher"] === true) presentation.subagentLauncher = true;
|
|
22516
|
+
const permission = optional2(sessionPermissionSchema, meta3?.["alan.dev/permission"]);
|
|
22517
|
+
if (permission !== void 0) presentation.permission = permission;
|
|
22518
|
+
}
|
|
22519
|
+
if (update.sessionUpdate === "state_update") {
|
|
22520
|
+
const waiting = optional2(external_exports.array(external_exports.string().min(1)), meta3?.["alan.dev/awaitingToolCallIds"]);
|
|
22521
|
+
if (waiting !== void 0) presentation.awaitingToolCallIds = waiting;
|
|
22522
|
+
}
|
|
22523
|
+
return Object.keys(presentation).length ? { ...update, presentation } : update;
|
|
22524
|
+
}
|
|
22525
|
+
var sessionToolDisplayInputSchema, sessionQuestionSchema, sessionPermissionSchema, sessionPresentationSchema;
|
|
22526
|
+
var init_session_presentation = __esm({
|
|
22527
|
+
"../shared/src/runtime-v2/session-presentation.ts"() {
|
|
22400
22528
|
"use strict";
|
|
22401
22529
|
init_zod();
|
|
22402
|
-
|
|
22530
|
+
sessionToolDisplayInputSchema = external_exports.object({
|
|
22531
|
+
command: external_exports.string().optional(),
|
|
22532
|
+
cwd: external_exports.string().optional(),
|
|
22533
|
+
filePath: external_exports.string().optional(),
|
|
22534
|
+
path: external_exports.string().optional(),
|
|
22535
|
+
pattern: external_exports.string().optional(),
|
|
22536
|
+
url: external_exports.string().optional(),
|
|
22537
|
+
query: external_exports.string().optional(),
|
|
22538
|
+
description: external_exports.string().optional(),
|
|
22539
|
+
prompt: external_exports.string().optional(),
|
|
22540
|
+
subagentType: external_exports.string().optional(),
|
|
22541
|
+
name: external_exports.string().optional()
|
|
22542
|
+
});
|
|
22543
|
+
sessionQuestionSchema = external_exports.object({
|
|
22544
|
+
question: external_exports.string(),
|
|
22545
|
+
header: external_exports.string().optional(),
|
|
22546
|
+
options: external_exports.array(external_exports.object({ label: external_exports.string(), description: external_exports.string().optional() })),
|
|
22547
|
+
multiSelect: external_exports.boolean()
|
|
22548
|
+
});
|
|
22549
|
+
sessionPermissionSchema = external_exports.object({
|
|
22550
|
+
permission: external_exports.string().min(1),
|
|
22551
|
+
patterns: external_exports.array(external_exports.string()),
|
|
22552
|
+
always: external_exports.array(external_exports.string()),
|
|
22553
|
+
filePath: external_exports.string().optional(),
|
|
22554
|
+
diff: external_exports.string().optional(),
|
|
22555
|
+
toolCallId: external_exports.string().optional()
|
|
22556
|
+
});
|
|
22557
|
+
sessionPresentationSchema = external_exports.object({
|
|
22558
|
+
parentToolCallId: external_exports.string().min(1).optional(),
|
|
22559
|
+
subagentLauncher: external_exports.boolean().optional(),
|
|
22560
|
+
toolInput: sessionToolDisplayInputSchema.optional(),
|
|
22561
|
+
questions: external_exports.array(sessionQuestionSchema).optional(),
|
|
22562
|
+
answer: external_exports.string().optional(),
|
|
22563
|
+
awaitingToolCallIds: external_exports.array(external_exports.string().min(1)).optional(),
|
|
22564
|
+
permission: sessionPermissionSchema.optional()
|
|
22565
|
+
});
|
|
22566
|
+
}
|
|
22567
|
+
});
|
|
22568
|
+
|
|
22569
|
+
// ../shared/src/runtime-v2/local-sessions.ts
|
|
22570
|
+
var MAX_SESSION_SUBMISSION_BYTES, localSessionIdSchema, sessionRequestIdSchema, sessionCursorSchema, label, workspaceSchema, sessionQueueStateSchema, sessionCommandNameSchema, localSessionCapabilitiesSchema, localSessionSchema, createSessionRequestSchema, createSessionResponseSchema, sessionAttachmentReferenceSchema, stageSessionAttachmentRequestSchema, submitSessionRequestSchema, sessionRequestBindingSchema, sessionRequestReceiptSchema, sessionSnapshotSchema, sessionFeedQuerySchema, listSessionsResponseSchema, withdrawSessionRequestSchema, respondToSessionRequestSchema, sessionCommandRequestSchema, sessionControlResponseSchema, textContentSchema, contentSchema, toolContentSchema, publicSessionUpdateSchema, localSessionUpdateSchema, localSessionRecordSchema, sessionFollowFrameSchema, localSessionRouteActionSchema;
|
|
22571
|
+
var init_local_sessions = __esm({
|
|
22572
|
+
"../shared/src/runtime-v2/local-sessions.ts"() {
|
|
22573
|
+
"use strict";
|
|
22574
|
+
init_zod();
|
|
22575
|
+
init_attachments();
|
|
22403
22576
|
init_ids();
|
|
22404
22577
|
init_link();
|
|
22405
22578
|
init_run_log();
|
|
22406
|
-
|
|
22407
|
-
|
|
22408
|
-
|
|
22409
|
-
|
|
22410
|
-
|
|
22579
|
+
init_session_interaction();
|
|
22580
|
+
init_session_operation();
|
|
22581
|
+
init_session_presentation();
|
|
22582
|
+
MAX_SESSION_SUBMISSION_BYTES = 1024 * 1024;
|
|
22583
|
+
localSessionIdSchema = external_exports.uuid().brand();
|
|
22584
|
+
sessionRequestIdSchema = external_exports.uuid().brand();
|
|
22585
|
+
sessionCursorSchema = external_exports.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
|
|
22586
|
+
label = external_exports.string().min(1).max(500);
|
|
22587
|
+
workspaceSchema = external_exports.string().min(1).max(4096).refine(
|
|
22588
|
+
(value) => /^(\/|[A-Za-z]:[\\/])/.test(value) && !value.includes("\0") && !value.split(/[\\/]/).includes(".."),
|
|
22589
|
+
"Use an absolute workspace path without traversal"
|
|
22590
|
+
);
|
|
22591
|
+
sessionQueueStateSchema = external_exports.enum([
|
|
22592
|
+
"accepted",
|
|
22593
|
+
"waiting_authorization",
|
|
22594
|
+
"queued",
|
|
22595
|
+
"running",
|
|
22596
|
+
"withdrawn",
|
|
22597
|
+
"ended",
|
|
22598
|
+
"blocked"
|
|
22599
|
+
]);
|
|
22600
|
+
sessionCommandNameSchema = external_exports.enum(["stop", "compact", "undo", "redo"]);
|
|
22601
|
+
localSessionCapabilitiesSchema = external_exports.object({
|
|
22602
|
+
commands: external_exports.array(sessionCommandNameSchema),
|
|
22603
|
+
responses: external_exports.array(external_exports.enum(["permission", "question"]))
|
|
22604
|
+
});
|
|
22605
|
+
localSessionSchema = external_exports.object({
|
|
22606
|
+
localSessionId: localSessionIdSchema,
|
|
22607
|
+
workspace: workspaceSchema,
|
|
22608
|
+
profile: label,
|
|
22609
|
+
accountId: external_exports.guid(),
|
|
22610
|
+
teamId: external_exports.guid(),
|
|
22611
|
+
conversationId: conversationIdSchema.nullable(),
|
|
22612
|
+
registration: external_exports.enum(["pending", "registered", "blocked"]),
|
|
22613
|
+
synchronization: external_exports.enum(["pending", "synced", "offline", "failed"]),
|
|
22614
|
+
capabilities: localSessionCapabilitiesSchema
|
|
22615
|
+
});
|
|
22616
|
+
createSessionRequestSchema = external_exports.strictObject({
|
|
22617
|
+
localSessionId: localSessionIdSchema,
|
|
22618
|
+
workspace: workspaceSchema,
|
|
22619
|
+
conversationId: conversationIdSchema.optional(),
|
|
22620
|
+
team: external_exports.discriminatedUnion("kind", [
|
|
22621
|
+
external_exports.strictObject({ kind: external_exports.literal("explicit"), teamId: external_exports.guid() }),
|
|
22622
|
+
external_exports.strictObject({ kind: external_exports.literal("resolve") })
|
|
22623
|
+
])
|
|
22624
|
+
});
|
|
22625
|
+
createSessionResponseSchema = external_exports.discriminatedUnion(
|
|
22626
|
+
"kind",
|
|
22627
|
+
[
|
|
22628
|
+
external_exports.object({ kind: external_exports.literal("created"), session: localSessionSchema }),
|
|
22629
|
+
external_exports.object({
|
|
22630
|
+
kind: external_exports.literal("team_required"),
|
|
22631
|
+
choices: external_exports.array(external_exports.object({ teamId: external_exports.guid(), name: label }))
|
|
22632
|
+
})
|
|
22633
|
+
]
|
|
22634
|
+
);
|
|
22635
|
+
sessionAttachmentReferenceSchema = external_exports.strictObject({
|
|
22636
|
+
attachmentId: external_exports.uuid(),
|
|
22637
|
+
name: requestPresignedUploadSchema.shape.filename.refine(
|
|
22638
|
+
(value) => !/[\\/\0]/.test(value) && value !== "." && value !== ".."
|
|
22639
|
+
),
|
|
22640
|
+
mediaType: requestPresignedUploadSchema.shape.mimeType,
|
|
22641
|
+
sizeBytes: requestPresignedUploadSchema.shape.size,
|
|
22642
|
+
sha256: external_exports.string().regex(/^[a-f0-9]{64}$/)
|
|
22643
|
+
});
|
|
22644
|
+
stageSessionAttachmentRequestSchema = external_exports.strictObject({
|
|
22645
|
+
attachmentId: external_exports.uuid(),
|
|
22646
|
+
sourcePath: workspaceSchema,
|
|
22647
|
+
name: requestPresignedUploadSchema.shape.filename.refine(
|
|
22648
|
+
(value) => !/[\\/\0]/.test(value) && value !== "." && value !== ".."
|
|
22649
|
+
),
|
|
22650
|
+
mediaType: requestPresignedUploadSchema.shape.mimeType
|
|
22651
|
+
});
|
|
22652
|
+
submitSessionRequestSchema = external_exports.strictObject({
|
|
22653
|
+
requestId: sessionRequestIdSchema,
|
|
22654
|
+
text: external_exports.string().max(MAX_SESSION_SUBMISSION_BYTES),
|
|
22655
|
+
model: label,
|
|
22656
|
+
mode: label,
|
|
22657
|
+
intent: external_exports.enum(["followUp", "steer"]),
|
|
22658
|
+
attachments: external_exports.array(sessionAttachmentReferenceSchema).max(MAX_COMMENT_ATTACHMENTS),
|
|
22659
|
+
interaction: sessionInteractionSchema.optional(),
|
|
22660
|
+
operation: sessionOperationSchema.optional(),
|
|
22661
|
+
selection: sessionSelectionSchema.optional()
|
|
22662
|
+
}).refine(
|
|
22663
|
+
(value) => !value.selection || !value.operation && value.selection.model === value.model && value.selection.mode === value.mode,
|
|
22664
|
+
"Captured selection must match ordinary request model and mode"
|
|
22665
|
+
).refine(
|
|
22666
|
+
(value) => value.operation !== void 0 || value.text.trim().length > 0 || value.attachments.length > 0,
|
|
22667
|
+
"A submission needs text, attachments or an operation"
|
|
22668
|
+
).refine(
|
|
22669
|
+
(value) => !value.operation || value.attachments.length === 0,
|
|
22670
|
+
"Operations do not accept attachments"
|
|
22671
|
+
).refine(
|
|
22672
|
+
(value) => new Set(value.attachments.map((item) => item.attachmentId)).size === value.attachments.length,
|
|
22673
|
+
"Duplicate attachment IDs"
|
|
22674
|
+
);
|
|
22675
|
+
sessionRequestBindingSchema = external_exports.object({
|
|
22676
|
+
runId: runIdSchema,
|
|
22677
|
+
userMessageId: external_exports.guid(),
|
|
22678
|
+
assistantMessageId: external_exports.guid()
|
|
22679
|
+
});
|
|
22680
|
+
sessionRequestReceiptSchema = external_exports.object({
|
|
22681
|
+
requestId: sessionRequestIdSchema,
|
|
22682
|
+
localSessionId: localSessionIdSchema,
|
|
22683
|
+
queue: sessionQueueStateSchema,
|
|
22684
|
+
binding: sessionRequestBindingSchema.nullable(),
|
|
22685
|
+
outcome: runOutcomeSchema.optional()
|
|
22686
|
+
}).refine(
|
|
22687
|
+
(value) => value.outcome === void 0 || value.queue === "ended",
|
|
22688
|
+
"Only ended requests have an outcome"
|
|
22689
|
+
);
|
|
22690
|
+
sessionSnapshotSchema = external_exports.object({
|
|
22691
|
+
session: localSessionSchema,
|
|
22692
|
+
cursor: sessionCursorSchema,
|
|
22693
|
+
requests: external_exports.array(sessionRequestReceiptSchema).max(1e3)
|
|
22694
|
+
}).refine(
|
|
22695
|
+
(value) => new Set(value.requests.map((item) => item.requestId)).size === value.requests.length,
|
|
22696
|
+
"Duplicate request IDs"
|
|
22697
|
+
).refine(
|
|
22698
|
+
(value) => value.requests.every((item) => item.localSessionId === value.session.localSessionId),
|
|
22699
|
+
"Request belongs to another session"
|
|
22700
|
+
);
|
|
22701
|
+
sessionFeedQuerySchema = external_exports.strictObject({
|
|
22702
|
+
cursor: external_exports.coerce.number().pipe(sessionCursorSchema).default(0),
|
|
22703
|
+
limit: external_exports.coerce.number().int().min(1).max(1e3).default(100)
|
|
22704
|
+
});
|
|
22705
|
+
listSessionsResponseSchema = external_exports.object({
|
|
22706
|
+
sessions: external_exports.array(localSessionSchema).max(1e3),
|
|
22707
|
+
nextCursor: sessionCursorSchema.nullable()
|
|
22708
|
+
});
|
|
22709
|
+
withdrawSessionRequestSchema = external_exports.strictObject({
|
|
22710
|
+
requestId: sessionRequestIdSchema
|
|
22711
|
+
});
|
|
22712
|
+
respondToSessionRequestSchema = external_exports.strictObject({
|
|
22713
|
+
requestId: sessionRequestIdSchema,
|
|
22714
|
+
runId: runIdSchema,
|
|
22715
|
+
toolCallId: toolCallIdSchema,
|
|
22716
|
+
answer: runAnswerSchema
|
|
22717
|
+
});
|
|
22718
|
+
sessionCommandRequestSchema = external_exports.discriminatedUnion(
|
|
22719
|
+
"command",
|
|
22720
|
+
[
|
|
22721
|
+
external_exports.strictObject({
|
|
22722
|
+
requestId: sessionRequestIdSchema,
|
|
22723
|
+
command: external_exports.literal("stop"),
|
|
22724
|
+
target: external_exports.strictObject({ requestId: sessionRequestIdSchema, runId: runIdSchema }).optional()
|
|
22725
|
+
}),
|
|
22726
|
+
external_exports.strictObject({
|
|
22727
|
+
requestId: sessionRequestIdSchema,
|
|
22728
|
+
command: external_exports.enum(["compact", "undo", "redo"])
|
|
22729
|
+
})
|
|
22730
|
+
]
|
|
22731
|
+
);
|
|
22732
|
+
sessionControlResponseSchema = external_exports.object({
|
|
22733
|
+
requestId: sessionRequestIdSchema,
|
|
22734
|
+
accepted: external_exports.literal(true)
|
|
22735
|
+
});
|
|
22736
|
+
textContentSchema = external_exports.object({ type: external_exports.literal("text"), text: external_exports.string() });
|
|
22737
|
+
contentSchema = external_exports.discriminatedUnion("type", [
|
|
22738
|
+
textContentSchema,
|
|
22411
22739
|
external_exports.object({
|
|
22412
|
-
type: external_exports.literal("
|
|
22413
|
-
|
|
22414
|
-
|
|
22415
|
-
|
|
22740
|
+
type: external_exports.literal("image"),
|
|
22741
|
+
mimeType: external_exports.string(),
|
|
22742
|
+
data: external_exports.string(),
|
|
22743
|
+
uri: external_exports.string().nullable().optional()
|
|
22416
22744
|
}),
|
|
22417
|
-
external_exports.object({ type: external_exports.literal("
|
|
22418
|
-
external_exports.object({ type: external_exports.literal("suspend"), id: external_exports.string().min(1) }),
|
|
22419
|
-
/** The user's answer to a tool call the running turn is blocked on; replied to with `responded`. */
|
|
22745
|
+
external_exports.object({ type: external_exports.literal("audio"), mimeType: external_exports.string(), data: external_exports.string() }),
|
|
22420
22746
|
external_exports.object({
|
|
22421
|
-
type: external_exports.literal("
|
|
22422
|
-
|
|
22423
|
-
|
|
22424
|
-
|
|
22425
|
-
|
|
22747
|
+
type: external_exports.literal("resource_link"),
|
|
22748
|
+
uri: external_exports.string(),
|
|
22749
|
+
name: external_exports.string(),
|
|
22750
|
+
title: external_exports.string().nullable().optional(),
|
|
22751
|
+
description: external_exports.string().nullable().optional(),
|
|
22752
|
+
mimeType: external_exports.string().nullable().optional(),
|
|
22753
|
+
size: external_exports.number().nullable().optional()
|
|
22426
22754
|
}),
|
|
22427
|
-
/** A message for the running turn to read at its next step; replied to with `steered`. */
|
|
22428
|
-
runSteerRequestSchema.extend({ type: external_exports.literal("steer"), id: external_exports.string().min(1) }),
|
|
22429
|
-
/** Stops one background task of the conversation's CLI; replied to with `task_stopped`. */
|
|
22430
22755
|
external_exports.object({
|
|
22431
|
-
type: external_exports.literal("
|
|
22432
|
-
|
|
22433
|
-
|
|
22434
|
-
|
|
22756
|
+
type: external_exports.literal("resource"),
|
|
22757
|
+
resource: external_exports.union([
|
|
22758
|
+
external_exports.object({ uri: external_exports.string(), text: external_exports.string(), mimeType: external_exports.string().nullable().optional() }),
|
|
22759
|
+
external_exports.object({ uri: external_exports.string(), blob: external_exports.string(), mimeType: external_exports.string().nullable().optional() })
|
|
22760
|
+
])
|
|
22435
22761
|
})
|
|
22436
22762
|
]);
|
|
22437
|
-
|
|
22438
|
-
|
|
22439
|
-
|
|
22440
|
-
startedAtMs: external_exports.number().int().nonnegative(),
|
|
22441
|
-
/** Wall clock, epoch ms; null while a turn runs. */
|
|
22442
|
-
idleSinceMs: external_exports.number().int().nonnegative().nullable(),
|
|
22443
|
-
hasBackgroundWork: external_exports.boolean().default(false),
|
|
22444
|
-
holderRssBytes: external_exports.number().int().nonnegative(),
|
|
22445
|
-
/** The live provider CLI; null when none is running. */
|
|
22446
|
-
cliPid: external_exports.number().int().positive().nullable(),
|
|
22447
|
-
cliRssBytes: external_exports.number().int().nonnegative().nullable(),
|
|
22448
|
-
/** The CLI's executable on PATH is not the file the live CLI was started from. */
|
|
22449
|
-
cliBinaryChanged: external_exports.boolean(),
|
|
22450
|
-
/** The last turn ended with a provider login error. */
|
|
22451
|
-
loginFailed: external_exports.boolean()
|
|
22452
|
-
});
|
|
22453
|
-
holderMessageSchema = external_exports.discriminatedUnion("type", [
|
|
22763
|
+
toolContentSchema = external_exports.discriminatedUnion("type", [
|
|
22764
|
+
external_exports.object({ type: external_exports.literal("content"), content: contentSchema }),
|
|
22765
|
+
external_exports.object({ type: external_exports.literal("terminal"), terminalId: label }),
|
|
22454
22766
|
external_exports.object({
|
|
22455
|
-
type: external_exports.literal("
|
|
22456
|
-
|
|
22457
|
-
|
|
22458
|
-
|
|
22767
|
+
type: external_exports.literal("diff"),
|
|
22768
|
+
diff: external_exports.object({
|
|
22769
|
+
changes: external_exports.array(
|
|
22770
|
+
external_exports.object({
|
|
22771
|
+
operation: external_exports.enum(["add", "delete", "modify", "move", "copy"]),
|
|
22772
|
+
path: external_exports.string(),
|
|
22773
|
+
oldPath: external_exports.string().optional(),
|
|
22774
|
+
fileType: external_exports.enum(["text", "binary", "directory", "symlink"]).nullable().optional()
|
|
22775
|
+
})
|
|
22776
|
+
),
|
|
22777
|
+
patch: external_exports.object({ format: external_exports.string(), text: external_exports.string() }).nullable().optional()
|
|
22778
|
+
})
|
|
22779
|
+
})
|
|
22780
|
+
]);
|
|
22781
|
+
publicSessionUpdateSchema = external_exports.union([
|
|
22782
|
+
external_exports.object({
|
|
22783
|
+
sessionUpdate: external_exports.enum(["user_message", "agent_message", "agent_thought"]),
|
|
22784
|
+
messageId: label,
|
|
22785
|
+
content: external_exports.array(contentSchema).nullable().optional()
|
|
22459
22786
|
}),
|
|
22460
|
-
external_exports.object({ type: external_exports.literal("ack"), id: external_exports.string().min(1) }),
|
|
22461
22787
|
external_exports.object({
|
|
22462
|
-
|
|
22463
|
-
|
|
22464
|
-
|
|
22465
|
-
message: external_exports.string()
|
|
22788
|
+
sessionUpdate: external_exports.enum(["user_message_chunk", "agent_message_chunk", "agent_thought_chunk"]),
|
|
22789
|
+
messageId: label,
|
|
22790
|
+
content: contentSchema
|
|
22466
22791
|
}),
|
|
22467
22792
|
external_exports.object({
|
|
22468
|
-
|
|
22469
|
-
|
|
22470
|
-
|
|
22471
|
-
|
|
22472
|
-
|
|
22793
|
+
sessionUpdate: external_exports.literal("tool_call_update"),
|
|
22794
|
+
toolCallId: label,
|
|
22795
|
+
name: external_exports.string().nullable().optional(),
|
|
22796
|
+
title: external_exports.string().nullable().optional(),
|
|
22797
|
+
kind: external_exports.enum([
|
|
22798
|
+
"read",
|
|
22799
|
+
"edit",
|
|
22800
|
+
"delete",
|
|
22801
|
+
"move",
|
|
22802
|
+
"search",
|
|
22803
|
+
"execute",
|
|
22804
|
+
"think",
|
|
22805
|
+
"fetch",
|
|
22806
|
+
"switch_mode",
|
|
22807
|
+
"other"
|
|
22808
|
+
]).nullable().optional(),
|
|
22809
|
+
status: external_exports.enum(["pending", "in_progress", "completed", "failed", "cancelled"]).nullable().optional(),
|
|
22810
|
+
content: external_exports.array(toolContentSchema).nullable().optional(),
|
|
22811
|
+
locations: external_exports.array(external_exports.object({ path: external_exports.string(), line: external_exports.number().nullable().optional() })).nullable().optional()
|
|
22473
22812
|
}),
|
|
22474
|
-
external_exports.object({ type: external_exports.literal("responded"), id: external_exports.string().min(1), status: runRespondStatusSchema }),
|
|
22475
|
-
external_exports.object({ type: external_exports.literal("steered"), id: external_exports.string().min(1), status: runSteerStatusSchema }),
|
|
22476
22813
|
external_exports.object({
|
|
22477
|
-
|
|
22478
|
-
|
|
22479
|
-
|
|
22814
|
+
sessionUpdate: external_exports.literal("tool_call_content_chunk"),
|
|
22815
|
+
toolCallId: label,
|
|
22816
|
+
content: toolContentSchema
|
|
22480
22817
|
}),
|
|
22481
|
-
external_exports.object({
|
|
22482
|
-
|
|
22818
|
+
external_exports.object({
|
|
22819
|
+
sessionUpdate: external_exports.literal("state_update"),
|
|
22820
|
+
state: external_exports.enum(["running", "idle", "requires_action"]),
|
|
22821
|
+
stopReason: external_exports.enum(["end_turn", "max_tokens", "max_turn_requests", "refusal", "cancelled"]).nullable().optional()
|
|
22822
|
+
}),
|
|
22823
|
+
external_exports.object({
|
|
22824
|
+
sessionUpdate: external_exports.literal("plan_update"),
|
|
22825
|
+
planId: label,
|
|
22826
|
+
entries: external_exports.array(
|
|
22827
|
+
external_exports.object({
|
|
22828
|
+
content: external_exports.string(),
|
|
22829
|
+
priority: external_exports.enum(["high", "medium", "low"]),
|
|
22830
|
+
status: external_exports.enum(["pending", "in_progress", "completed", "cancelled"])
|
|
22831
|
+
})
|
|
22832
|
+
)
|
|
22833
|
+
}),
|
|
22834
|
+
external_exports.object({
|
|
22835
|
+
sessionUpdate: external_exports.literal("usage_update"),
|
|
22836
|
+
used: external_exports.number(),
|
|
22837
|
+
size: external_exports.number(),
|
|
22838
|
+
cost: external_exports.object({ amount: external_exports.number(), currency: external_exports.string() }).nullable().optional()
|
|
22839
|
+
}),
|
|
22840
|
+
external_exports.object({
|
|
22841
|
+
sessionUpdate: external_exports.literal("notice"),
|
|
22842
|
+
severity: external_exports.enum(["info", "warning", "error"]),
|
|
22843
|
+
title: external_exports.string(),
|
|
22844
|
+
description: external_exports.string().nullable().optional()
|
|
22845
|
+
}),
|
|
22846
|
+
external_exports.object({
|
|
22847
|
+
sessionUpdate: external_exports.literal("session_info_update"),
|
|
22848
|
+
title: external_exports.string().nullable().optional(),
|
|
22849
|
+
updatedAt: external_exports.string().nullable().optional()
|
|
22850
|
+
}),
|
|
22851
|
+
external_exports.object({
|
|
22852
|
+
sessionUpdate: external_exports.literal("terminal_output_chunk"),
|
|
22853
|
+
terminalId: label,
|
|
22854
|
+
data: external_exports.string()
|
|
22855
|
+
}),
|
|
22856
|
+
external_exports.object({
|
|
22857
|
+
sessionUpdate: external_exports.literal("terminal_update"),
|
|
22858
|
+
terminalId: label,
|
|
22859
|
+
command: external_exports.string().nullable().optional(),
|
|
22860
|
+
cwd: external_exports.string().nullable().optional(),
|
|
22861
|
+
output: external_exports.object({ data: external_exports.string() }).nullable().optional(),
|
|
22862
|
+
exitStatus: external_exports.object({
|
|
22863
|
+
exitCode: external_exports.number().nullable().optional(),
|
|
22864
|
+
signal: external_exports.string().nullable().optional()
|
|
22865
|
+
}).nullable().optional()
|
|
22866
|
+
}),
|
|
22867
|
+
runAcceptedUpdateSchema,
|
|
22868
|
+
runStartedUpdateSchema,
|
|
22869
|
+
runEndedUpdateSchema
|
|
22483
22870
|
]);
|
|
22484
|
-
|
|
22485
|
-
|
|
22486
|
-
|
|
22487
|
-
|
|
22488
|
-
|
|
22489
|
-
|
|
22490
|
-
|
|
22491
|
-
|
|
22492
|
-
|
|
22493
|
-
holderStatusSchema = external_exports.object({
|
|
22494
|
-
protocol: external_exports.number().int().positive(),
|
|
22495
|
-
conversationId: conversationIdSchema,
|
|
22496
|
-
pid: external_exports.number().int().positive(),
|
|
22497
|
-
startedAt: external_exports.string().min(1),
|
|
22498
|
-
/** The holder's command line; with the start time it tells the holder from a pid reuse. */
|
|
22499
|
-
command: external_exports.string().min(1).optional(),
|
|
22500
|
-
endpoint: external_exports.string().min(1),
|
|
22501
|
-
tokenSha256: external_exports.string().regex(/^[a-f0-9]{64}$/),
|
|
22502
|
-
state: holderStateSchema,
|
|
22503
|
-
runId: runIdSchema.nullable(),
|
|
22504
|
-
updatedAt: external_exports.number().int().nonnegative()
|
|
22871
|
+
localSessionUpdateSchema = external_exports.preprocess(
|
|
22872
|
+
withSessionPresentation,
|
|
22873
|
+
publicSessionUpdateSchema.and(external_exports.object({ presentation: sessionPresentationSchema.optional() }))
|
|
22874
|
+
);
|
|
22875
|
+
localSessionRecordSchema = external_exports.object({
|
|
22876
|
+
runId: runIdSchema,
|
|
22877
|
+
seq: external_exports.number().int().positive(),
|
|
22878
|
+
at: external_exports.number().int().nonnegative(),
|
|
22879
|
+
update: localSessionUpdateSchema
|
|
22505
22880
|
});
|
|
22881
|
+
sessionFollowFrameSchema = external_exports.discriminatedUnion(
|
|
22882
|
+
"kind",
|
|
22883
|
+
[
|
|
22884
|
+
external_exports.object({
|
|
22885
|
+
kind: external_exports.literal("snapshot"),
|
|
22886
|
+
cursor: sessionCursorSchema,
|
|
22887
|
+
snapshot: sessionSnapshotSchema
|
|
22888
|
+
}),
|
|
22889
|
+
external_exports.object({
|
|
22890
|
+
kind: external_exports.literal("record"),
|
|
22891
|
+
cursor: sessionCursorSchema,
|
|
22892
|
+
record: localSessionRecordSchema
|
|
22893
|
+
}),
|
|
22894
|
+
external_exports.object({
|
|
22895
|
+
kind: external_exports.literal("status"),
|
|
22896
|
+
cursor: sessionCursorSchema,
|
|
22897
|
+
receipt: sessionRequestReceiptSchema,
|
|
22898
|
+
synchronization: external_exports.enum(["pending", "synced", "offline", "failed"])
|
|
22899
|
+
})
|
|
22900
|
+
]
|
|
22901
|
+
);
|
|
22902
|
+
localSessionRouteActionSchema = external_exports.enum([
|
|
22903
|
+
"snapshot",
|
|
22904
|
+
"submit",
|
|
22905
|
+
"stage",
|
|
22906
|
+
"withdraw",
|
|
22907
|
+
"respond",
|
|
22908
|
+
"command",
|
|
22909
|
+
"stream"
|
|
22910
|
+
]);
|
|
22506
22911
|
}
|
|
22507
22912
|
});
|
|
22508
22913
|
|
|
22509
|
-
// ../shared/src/runtime-v2/
|
|
22510
|
-
var
|
|
22511
|
-
|
|
22914
|
+
// ../shared/src/runtime-v2/cloud-sessions.ts
|
|
22915
|
+
var conversationRowSchema, listResponseSchema, teamsResponseSchema, liteAgentSettingsSchema, sendAckSchema;
|
|
22916
|
+
var init_cloud_sessions = __esm({
|
|
22917
|
+
"../shared/src/runtime-v2/cloud-sessions.ts"() {
|
|
22512
22918
|
"use strict";
|
|
22919
|
+
init_zod();
|
|
22920
|
+
init_ids();
|
|
22921
|
+
init_local_sessions();
|
|
22922
|
+
conversationRowSchema = external_exports.object({
|
|
22923
|
+
id: localSessionIdSchema,
|
|
22924
|
+
teamId: external_exports.string().nullable(),
|
|
22925
|
+
createdByUserId: external_exports.string(),
|
|
22926
|
+
agentId: external_exports.string().nullable().optional(),
|
|
22927
|
+
executionTarget: external_exports.string().nullable().optional()
|
|
22928
|
+
});
|
|
22929
|
+
listResponseSchema = external_exports.object({ data: external_exports.array(conversationRowSchema) });
|
|
22930
|
+
teamsResponseSchema = external_exports.object({
|
|
22931
|
+
data: external_exports.array(external_exports.object({ id: external_exports.string(), name: external_exports.string() }))
|
|
22932
|
+
});
|
|
22933
|
+
liteAgentSettingsSchema = external_exports.object({ defaultCloudEnvironmentId: external_exports.string().nullable() });
|
|
22934
|
+
sendAckSchema = external_exports.union([
|
|
22935
|
+
external_exports.object({
|
|
22936
|
+
ok: external_exports.literal(false),
|
|
22937
|
+
code: external_exports.string().optional(),
|
|
22938
|
+
message: external_exports.string().optional(),
|
|
22939
|
+
error: external_exports.string().optional()
|
|
22940
|
+
}),
|
|
22941
|
+
external_exports.object({
|
|
22942
|
+
ok: external_exports.literal(true).optional(),
|
|
22943
|
+
message: external_exports.object({ id: sessionRequestIdSchema }),
|
|
22944
|
+
runId: runIdSchema.nullable(),
|
|
22945
|
+
runStatus: external_exports.string().nullable().optional(),
|
|
22946
|
+
delivery: external_exports.enum(["steered", "queued"]).optional(),
|
|
22947
|
+
lifecycle: external_exports.union([
|
|
22948
|
+
external_exports.object({ ok: external_exports.literal(true) }),
|
|
22949
|
+
external_exports.object({ ok: external_exports.literal(false), error: external_exports.object({ message: external_exports.string() }) })
|
|
22950
|
+
]).optional()
|
|
22951
|
+
})
|
|
22952
|
+
]);
|
|
22513
22953
|
}
|
|
22514
22954
|
});
|
|
22515
22955
|
|
|
22516
|
-
// ../shared/src/runtime-v2/
|
|
22517
|
-
|
|
22518
|
-
|
|
22519
|
-
|
|
22520
|
-
var DESIRED_STATE_PATH, RUN_LOG_UPLOAD_HEADERS, offsetSchema, runLogUploadReceiptSchema, runLogUploadResponseSchema;
|
|
22521
|
-
var init_run_log_upload = __esm({
|
|
22522
|
-
"../shared/src/runtime-v2/run-log-upload.ts"() {
|
|
22956
|
+
// ../shared/src/runtime-v2/git-capability.ts
|
|
22957
|
+
var machineGitCapabilityRequestSchema, machineGitCapabilityWarningSchema, machineGitCapabilitySchema, machineGitCapabilityRefusalSchema;
|
|
22958
|
+
var init_git_capability = __esm({
|
|
22959
|
+
"../shared/src/runtime-v2/git-capability.ts"() {
|
|
22523
22960
|
"use strict";
|
|
22524
22961
|
init_zod();
|
|
22525
|
-
|
|
22962
|
+
machineGitCapabilityRequestSchema = external_exports.object({
|
|
22963
|
+
/** The URL git is talking to, as the credential helper received it. */
|
|
22964
|
+
gatewayUrl: external_exports.url()
|
|
22965
|
+
});
|
|
22966
|
+
machineGitCapabilityWarningSchema = external_exports.object({
|
|
22967
|
+
code: external_exports.literal("github_identity_fallback"),
|
|
22968
|
+
message: external_exports.string().min(1)
|
|
22969
|
+
});
|
|
22970
|
+
machineGitCapabilitySchema = external_exports.object({
|
|
22971
|
+
capability: external_exports.string().min(1),
|
|
22972
|
+
expiresInSeconds: external_exports.number().int().positive(),
|
|
22973
|
+
repoUrl: external_exports.url(),
|
|
22974
|
+
warnings: external_exports.array(machineGitCapabilityWarningSchema)
|
|
22975
|
+
});
|
|
22976
|
+
machineGitCapabilityRefusalSchema = external_exports.object({
|
|
22977
|
+
error: external_exports.string(),
|
|
22978
|
+
code: external_exports.string().optional()
|
|
22979
|
+
});
|
|
22980
|
+
}
|
|
22981
|
+
});
|
|
22982
|
+
|
|
22983
|
+
// ../shared/src/runtime-v2/github-proxy.ts
|
|
22984
|
+
var GITHUB_PROXY_UPSTREAMS, gitHubProxyUpstreamSchema, GITHUB_PROXY_REFUSAL_CODES, gitHubProxyErrorSchema;
|
|
22985
|
+
var init_github_proxy = __esm({
|
|
22986
|
+
"../shared/src/runtime-v2/github-proxy.ts"() {
|
|
22987
|
+
"use strict";
|
|
22988
|
+
init_zod();
|
|
22989
|
+
GITHUB_PROXY_UPSTREAMS = [
|
|
22990
|
+
"api.github.com",
|
|
22991
|
+
"uploads.github.com",
|
|
22992
|
+
"github.com"
|
|
22993
|
+
];
|
|
22994
|
+
gitHubProxyUpstreamSchema = external_exports.enum(GITHUB_PROXY_UPSTREAMS);
|
|
22995
|
+
GITHUB_PROXY_REFUSAL_CODES = [
|
|
22996
|
+
"host_not_proxied",
|
|
22997
|
+
"machine_not_allowed",
|
|
22998
|
+
"github_not_connected",
|
|
22999
|
+
"github_installation_unavailable"
|
|
23000
|
+
];
|
|
23001
|
+
gitHubProxyErrorSchema = external_exports.object({
|
|
23002
|
+
message: external_exports.string().min(1),
|
|
23003
|
+
documentation_url: external_exports.string(),
|
|
23004
|
+
status: external_exports.string(),
|
|
23005
|
+
alan_code: external_exports.enum(GITHUB_PROXY_REFUSAL_CODES)
|
|
23006
|
+
});
|
|
23007
|
+
}
|
|
23008
|
+
});
|
|
23009
|
+
|
|
23010
|
+
// ../shared/src/runtime-v2/session-preparation.ts
|
|
23011
|
+
var modalitySchema, modalitiesSchema, sessionModelDescriptorSchema, sessionModelCatalogSchema, sessionBindingReferenceSchema, sessionMcpDescriptorSchema, sessionPreparationSchema;
|
|
23012
|
+
var init_session_preparation = __esm({
|
|
23013
|
+
"../shared/src/runtime-v2/session-preparation.ts"() {
|
|
23014
|
+
"use strict";
|
|
23015
|
+
init_zod();
|
|
23016
|
+
init_ids();
|
|
23017
|
+
init_local_sessions();
|
|
23018
|
+
modalitySchema = external_exports.enum(["text", "image", "audio", "video", "pdf"]);
|
|
23019
|
+
modalitiesSchema = external_exports.strictObject({
|
|
23020
|
+
input: external_exports.array(modalitySchema).max(5),
|
|
23021
|
+
output: external_exports.array(modalitySchema).max(5)
|
|
23022
|
+
});
|
|
23023
|
+
sessionModelDescriptorSchema = external_exports.strictObject({
|
|
23024
|
+
id: external_exports.string().min(1).max(512),
|
|
23025
|
+
name: external_exports.string().min(1).max(512),
|
|
23026
|
+
description: external_exports.string().max(16384).nullable(),
|
|
23027
|
+
isDefault: external_exports.boolean(),
|
|
23028
|
+
recommended: external_exports.boolean().optional(),
|
|
23029
|
+
custom: external_exports.boolean().optional(),
|
|
23030
|
+
contextWindow: external_exports.number().int().nonnegative(),
|
|
23031
|
+
maxOutputTokens: external_exports.number().int().nonnegative(),
|
|
23032
|
+
modalities: modalitiesSchema
|
|
23033
|
+
});
|
|
23034
|
+
sessionModelCatalogSchema = external_exports.strictObject({
|
|
23035
|
+
models: external_exports.array(sessionModelDescriptorSchema).max(1e4),
|
|
23036
|
+
completeness: external_exports.enum(["complete", "partial"]),
|
|
23037
|
+
unavailableProviders: external_exports.array(external_exports.string().regex(/^[a-z][a-z0-9_]{0,63}$/)).max(100)
|
|
23038
|
+
});
|
|
23039
|
+
sessionBindingReferenceSchema = external_exports.strictObject({
|
|
23040
|
+
localSessionId: localSessionIdSchema,
|
|
23041
|
+
conversationId: conversationIdSchema,
|
|
23042
|
+
machineId: machineIdSchema,
|
|
23043
|
+
organizationId: external_exports.uuid(),
|
|
23044
|
+
ownerUserId: external_exports.uuid(),
|
|
23045
|
+
teamId: external_exports.uuid(),
|
|
23046
|
+
taskId: external_exports.uuid().nullable(),
|
|
23047
|
+
workspace: external_exports.string().min(1).max(4096)
|
|
23048
|
+
});
|
|
23049
|
+
sessionMcpDescriptorSchema = external_exports.strictObject({
|
|
23050
|
+
name: external_exports.string().min(1).max(512),
|
|
23051
|
+
owner: external_exports.enum(["alan_managed", "team_managed", "native_engine"]),
|
|
23052
|
+
setup: external_exports.enum(["run_required", "native_setup_required"])
|
|
23053
|
+
});
|
|
23054
|
+
sessionPreparationSchema = external_exports.strictObject({
|
|
23055
|
+
version: external_exports.literal(1),
|
|
23056
|
+
binding: sessionBindingReferenceSchema,
|
|
23057
|
+
backendKind: external_exports.literal("alan_code"),
|
|
23058
|
+
configurationRevision: external_exports.string().regex(/^[a-f0-9]{64}$/),
|
|
23059
|
+
authorizedAt: external_exports.iso.datetime(),
|
|
23060
|
+
hasCanonicalHistory: external_exports.boolean(),
|
|
23061
|
+
title: external_exports.string().max(16384),
|
|
23062
|
+
mode: external_exports.enum(["agent", "plan", "ask", "review"]),
|
|
23063
|
+
catalog: sessionModelCatalogSchema,
|
|
23064
|
+
mcp: external_exports.array(sessionMcpDescriptorSchema).max(1e3)
|
|
23065
|
+
});
|
|
23066
|
+
}
|
|
23067
|
+
});
|
|
23068
|
+
|
|
23069
|
+
// ../shared/src/runtime-v2/session-reads.ts
|
|
23070
|
+
var MAX_SESSION_READ_BYTES, MAX_SESSION_DIFF_PATCH_BYTES, label2, description, sessionRelativePathSchema, engineSessionReadQuerySchema, sessionReadQuerySchema, safeCommandSchema, safeSkillSchema, safeFileSchema, safeDiffSchema, safeLspStatusSchema, safeFormatterStatusSchema, safeVcsStatusSchema, sessionMcpControlsSchema, safeMcpStatusSchema, sessionStatusViewSchema, sessionCommandCatalogSchema, sessionReadCapabilitiesSchema, sessionBootstrapViewSchema, sessionReadValueSchema;
|
|
23071
|
+
var init_session_reads = __esm({
|
|
23072
|
+
"../shared/src/runtime-v2/session-reads.ts"() {
|
|
23073
|
+
"use strict";
|
|
23074
|
+
init_zod();
|
|
23075
|
+
init_session_preparation();
|
|
23076
|
+
MAX_SESSION_READ_BYTES = 4 * 1024 * 1024;
|
|
23077
|
+
MAX_SESSION_DIFF_PATCH_BYTES = 1024 * 1024;
|
|
23078
|
+
label2 = external_exports.string().min(1).max(512);
|
|
23079
|
+
description = external_exports.string().max(16384);
|
|
23080
|
+
sessionRelativePathSchema = external_exports.string().min(1).max(4096).refine(
|
|
23081
|
+
(value) => !value.includes("\0") && !/^(?:[/\\]|[a-z]:)/i.test(value) && !value.split(/[/\\]/).includes(".."),
|
|
23082
|
+
"Expected a workspace-relative path"
|
|
23083
|
+
);
|
|
23084
|
+
engineSessionReadQuerySchema = external_exports.discriminatedUnion("kind", [
|
|
23085
|
+
external_exports.strictObject({ kind: external_exports.literal("commands") }),
|
|
23086
|
+
external_exports.strictObject({ kind: external_exports.literal("skills") }),
|
|
23087
|
+
external_exports.strictObject({ kind: external_exports.literal("status") }),
|
|
23088
|
+
external_exports.strictObject({
|
|
23089
|
+
kind: external_exports.literal("find_files"),
|
|
23090
|
+
query: external_exports.string().max(1024),
|
|
23091
|
+
directory: sessionRelativePathSchema.optional(),
|
|
23092
|
+
type: external_exports.enum(["file", "directory"]).optional(),
|
|
23093
|
+
limit: external_exports.number().int().min(1).max(100).optional()
|
|
23094
|
+
}),
|
|
23095
|
+
external_exports.strictObject({ kind: external_exports.literal("diff"), scope: external_exports.enum(["session", "worktree"]) })
|
|
23096
|
+
]);
|
|
23097
|
+
sessionReadQuerySchema = external_exports.union([
|
|
23098
|
+
external_exports.strictObject({ kind: external_exports.literal("bootstrap") }),
|
|
23099
|
+
engineSessionReadQuerySchema
|
|
23100
|
+
]);
|
|
23101
|
+
safeCommandSchema = external_exports.strictObject({
|
|
23102
|
+
name: label2,
|
|
23103
|
+
description: description.optional(),
|
|
23104
|
+
source: external_exports.enum(["command", "skill", "mcp"]).optional(),
|
|
23105
|
+
argumentHints: external_exports.array(external_exports.string().max(4096)).max(100)
|
|
23106
|
+
});
|
|
23107
|
+
safeSkillSchema = external_exports.strictObject({ name: label2, description: description.optional() });
|
|
23108
|
+
safeFileSchema = external_exports.strictObject({
|
|
23109
|
+
path: sessionRelativePathSchema,
|
|
23110
|
+
type: external_exports.enum(["file", "directory"])
|
|
23111
|
+
});
|
|
23112
|
+
safeDiffSchema = external_exports.strictObject({
|
|
23113
|
+
path: sessionRelativePathSchema,
|
|
23114
|
+
patch: external_exports.string().max(MAX_SESSION_DIFF_PATCH_BYTES).optional(),
|
|
23115
|
+
additions: external_exports.number().int().nonnegative(),
|
|
23116
|
+
deletions: external_exports.number().int().nonnegative(),
|
|
23117
|
+
status: external_exports.enum(["added", "deleted", "modified"]).optional()
|
|
23118
|
+
});
|
|
23119
|
+
safeLspStatusSchema = external_exports.strictObject({
|
|
23120
|
+
name: label2,
|
|
23121
|
+
root: sessionRelativePathSchema,
|
|
23122
|
+
status: external_exports.enum(["connected", "error"])
|
|
23123
|
+
});
|
|
23124
|
+
safeFormatterStatusSchema = external_exports.strictObject({
|
|
23125
|
+
name: label2,
|
|
23126
|
+
extensions: external_exports.array(external_exports.string().max(128)).max(1e3),
|
|
23127
|
+
enabled: external_exports.boolean()
|
|
23128
|
+
});
|
|
23129
|
+
safeVcsStatusSchema = external_exports.strictObject({
|
|
23130
|
+
branch: label2.optional(),
|
|
23131
|
+
defaultBranch: label2.optional()
|
|
23132
|
+
});
|
|
23133
|
+
sessionMcpControlsSchema = external_exports.strictObject({
|
|
23134
|
+
connect: external_exports.literal(false),
|
|
23135
|
+
disconnect: external_exports.literal(false),
|
|
23136
|
+
authenticate: external_exports.literal(false),
|
|
23137
|
+
removeAuth: external_exports.literal(false),
|
|
23138
|
+
reason: external_exports.enum(["managed_by_alan", "native_setup_required", "owner_unverified"])
|
|
23139
|
+
});
|
|
23140
|
+
safeMcpStatusSchema = external_exports.strictObject({
|
|
23141
|
+
name: label2,
|
|
23142
|
+
owner: external_exports.enum(["alan_managed", "team_managed", "native_engine"]),
|
|
23143
|
+
state: external_exports.enum([
|
|
23144
|
+
"connected",
|
|
23145
|
+
"disabled",
|
|
23146
|
+
"failed",
|
|
23147
|
+
"needs_auth",
|
|
23148
|
+
"needs_client_registration",
|
|
23149
|
+
"waiting_for_run"
|
|
23150
|
+
]),
|
|
23151
|
+
controls: sessionMcpControlsSchema
|
|
23152
|
+
});
|
|
23153
|
+
sessionStatusViewSchema = external_exports.strictObject({
|
|
23154
|
+
lsp: external_exports.array(safeLspStatusSchema).max(1e3),
|
|
23155
|
+
formatters: external_exports.array(safeFormatterStatusSchema).max(1e3),
|
|
23156
|
+
vcs: safeVcsStatusSchema,
|
|
23157
|
+
mcp: external_exports.array(safeMcpStatusSchema).max(1e3)
|
|
23158
|
+
});
|
|
23159
|
+
sessionCommandCatalogSchema = external_exports.strictObject({
|
|
23160
|
+
commands: external_exports.array(safeCommandSchema).max(1e3),
|
|
23161
|
+
completeness: external_exports.enum(["complete", "partial"]),
|
|
23162
|
+
reasons: external_exports.array(external_exports.enum(["managed_mcp_waiting_for_run", "native_mcp_unavailable"])).max(2)
|
|
23163
|
+
});
|
|
23164
|
+
sessionReadCapabilitiesSchema = external_exports.strictObject({
|
|
23165
|
+
commands: external_exports.boolean(),
|
|
23166
|
+
skills: external_exports.boolean(),
|
|
23167
|
+
files: external_exports.boolean(),
|
|
23168
|
+
sessionDiff: external_exports.boolean(),
|
|
23169
|
+
worktreeDiff: external_exports.boolean(),
|
|
23170
|
+
status: external_exports.boolean(),
|
|
23171
|
+
mcpConnect: external_exports.literal(false),
|
|
23172
|
+
mcpDisconnect: external_exports.literal(false),
|
|
23173
|
+
mcpAuthenticate: external_exports.literal(false),
|
|
23174
|
+
mcpRemoveAuth: external_exports.literal(false)
|
|
23175
|
+
});
|
|
23176
|
+
sessionBootstrapViewSchema = external_exports.strictObject({
|
|
23177
|
+
models: sessionModelCatalogSchema,
|
|
23178
|
+
commands: sessionCommandCatalogSchema,
|
|
23179
|
+
skills: external_exports.array(safeSkillSchema).max(1e3),
|
|
23180
|
+
status: sessionStatusViewSchema,
|
|
23181
|
+
capabilities: sessionReadCapabilitiesSchema
|
|
23182
|
+
});
|
|
23183
|
+
sessionReadValueSchema = external_exports.discriminatedUnion("kind", [
|
|
23184
|
+
external_exports.strictObject({ kind: external_exports.literal("commands"), value: sessionCommandCatalogSchema }),
|
|
23185
|
+
external_exports.strictObject({ kind: external_exports.literal("skills"), value: external_exports.array(safeSkillSchema).max(1e3) }),
|
|
23186
|
+
external_exports.strictObject({
|
|
23187
|
+
kind: external_exports.literal("status"),
|
|
23188
|
+
value: sessionStatusViewSchema,
|
|
23189
|
+
completeness: external_exports.enum(["complete", "partial"])
|
|
23190
|
+
}),
|
|
23191
|
+
external_exports.strictObject({
|
|
23192
|
+
kind: external_exports.literal("find_files"),
|
|
23193
|
+
value: external_exports.array(safeFileSchema).max(100),
|
|
23194
|
+
truncated: external_exports.boolean(),
|
|
23195
|
+
completeness: external_exports.enum(["complete", "partial"])
|
|
23196
|
+
}),
|
|
23197
|
+
external_exports.strictObject({
|
|
23198
|
+
kind: external_exports.literal("diff"),
|
|
23199
|
+
scope: external_exports.enum(["session", "worktree"]),
|
|
23200
|
+
value: external_exports.array(safeDiffSchema).max(200),
|
|
23201
|
+
completeness: external_exports.enum(["complete", "partial", "unavailable"]),
|
|
23202
|
+
reason: external_exports.enum(["tracking_disabled", "history_unavailable", "unscopable_entries"]).optional()
|
|
23203
|
+
})
|
|
23204
|
+
]);
|
|
23205
|
+
}
|
|
23206
|
+
});
|
|
23207
|
+
|
|
23208
|
+
// ../shared/src/runtime-v2/holder-protocol.ts
|
|
23209
|
+
var HOLDER_PROTOCOL, sessionPreparationFailureSchema, observation, sessionPreparationStatusSchema, sessionReadResponseSchema, prepareSessionRequestSchema, holderAbortOutcomeSchema, holderRequestSchema, holderStateSchema, holderSessionFactsSchema, holderMessageSchema, holderLaunchSchema, holderStatusSchema;
|
|
23210
|
+
var init_holder_protocol = __esm({
|
|
23211
|
+
"../shared/src/runtime-v2/holder-protocol.ts"() {
|
|
23212
|
+
"use strict";
|
|
23213
|
+
init_zod();
|
|
23214
|
+
init_desired_state();
|
|
23215
|
+
init_ids();
|
|
23216
|
+
init_link();
|
|
23217
|
+
init_local_sessions();
|
|
23218
|
+
init_run_log();
|
|
23219
|
+
init_session_preparation();
|
|
23220
|
+
init_session_reads();
|
|
23221
|
+
HOLDER_PROTOCOL = 5;
|
|
23222
|
+
sessionPreparationFailureSchema = external_exports.enum([
|
|
23223
|
+
"unsupported",
|
|
23224
|
+
"upgrade_required",
|
|
23225
|
+
"engine_unavailable",
|
|
23226
|
+
"history_unavailable",
|
|
23227
|
+
"resource_busy",
|
|
23228
|
+
"busy",
|
|
23229
|
+
"online_required",
|
|
23230
|
+
"forbidden",
|
|
23231
|
+
"timeout",
|
|
23232
|
+
"aborted",
|
|
23233
|
+
"invalid_response",
|
|
23234
|
+
"invalid_path",
|
|
23235
|
+
"response_too_large",
|
|
23236
|
+
"not_prepared"
|
|
23237
|
+
]);
|
|
23238
|
+
observation = {
|
|
23239
|
+
localSessionId: localSessionIdSchema,
|
|
23240
|
+
conversationId: conversationIdSchema,
|
|
23241
|
+
generation: external_exports.uuid()
|
|
23242
|
+
};
|
|
23243
|
+
sessionPreparationStatusSchema = external_exports.discriminatedUnion("state", [
|
|
23244
|
+
external_exports.strictObject({ ...observation, state: external_exports.literal("preparing") }),
|
|
23245
|
+
external_exports.strictObject({ ...observation, state: external_exports.literal("ready") }),
|
|
23246
|
+
external_exports.strictObject({
|
|
23247
|
+
...observation,
|
|
23248
|
+
state: external_exports.literal("failed"),
|
|
23249
|
+
code: sessionPreparationFailureSchema
|
|
23250
|
+
}),
|
|
23251
|
+
external_exports.strictObject({
|
|
23252
|
+
...observation,
|
|
23253
|
+
state: external_exports.literal("unavailable"),
|
|
23254
|
+
reason: external_exports.enum(["not_prepared", "suspended", "disconnected"])
|
|
23255
|
+
})
|
|
23256
|
+
]);
|
|
23257
|
+
sessionReadResponseSchema = external_exports.strictObject({
|
|
23258
|
+
...observation,
|
|
23259
|
+
observedAt: external_exports.iso.datetime(),
|
|
23260
|
+
result: external_exports.union([
|
|
23261
|
+
sessionReadValueSchema,
|
|
23262
|
+
external_exports.strictObject({ kind: external_exports.literal("bootstrap"), value: sessionBootstrapViewSchema })
|
|
23263
|
+
])
|
|
23264
|
+
});
|
|
23265
|
+
prepareSessionRequestSchema = external_exports.strictObject({});
|
|
23266
|
+
holderAbortOutcomeSchema = external_exports.enum(["aborted", "interrupted"]);
|
|
23267
|
+
holderRequestSchema = external_exports.discriminatedUnion("type", [
|
|
23268
|
+
external_exports.strictObject({
|
|
23269
|
+
type: external_exports.literal("prepare_session"),
|
|
23270
|
+
id: external_exports.string().min(1),
|
|
23271
|
+
reference: sessionBindingReferenceSchema
|
|
23272
|
+
}),
|
|
23273
|
+
external_exports.strictObject({
|
|
23274
|
+
type: external_exports.literal("preparation_status"),
|
|
23275
|
+
id: external_exports.string().min(1),
|
|
23276
|
+
reference: sessionBindingReferenceSchema
|
|
23277
|
+
}),
|
|
23278
|
+
external_exports.strictObject({
|
|
23279
|
+
type: external_exports.literal("read_session"),
|
|
23280
|
+
id: external_exports.string().min(1),
|
|
23281
|
+
reference: sessionBindingReferenceSchema,
|
|
23282
|
+
query: sessionReadQuerySchema
|
|
23283
|
+
}),
|
|
23284
|
+
external_exports.strictObject({
|
|
23285
|
+
type: external_exports.literal("cancel_read"),
|
|
23286
|
+
id: external_exports.string().min(1),
|
|
23287
|
+
requestId: external_exports.string().min(1)
|
|
23288
|
+
}),
|
|
23289
|
+
external_exports.object({ type: external_exports.literal("auth"), token: external_exports.string().min(1) }),
|
|
23290
|
+
external_exports.object({ type: external_exports.literal("start_turn"), id: external_exports.string().min(1), spec: runSpecSchema }),
|
|
23291
|
+
external_exports.object({
|
|
23292
|
+
type: external_exports.literal("abort"),
|
|
23293
|
+
id: external_exports.string().min(1),
|
|
23294
|
+
runId: runIdSchema,
|
|
23295
|
+
outcome: holderAbortOutcomeSchema.optional()
|
|
23296
|
+
}),
|
|
23297
|
+
external_exports.object({ type: external_exports.literal("status"), id: external_exports.string().min(1) }),
|
|
23298
|
+
external_exports.object({ type: external_exports.literal("suspend"), id: external_exports.string().min(1) }),
|
|
23299
|
+
/** The user's answer to a tool call the running turn is blocked on; replied to with `responded`. */
|
|
23300
|
+
external_exports.object({
|
|
23301
|
+
type: external_exports.literal("respond"),
|
|
23302
|
+
id: external_exports.string().min(1),
|
|
23303
|
+
runId: runIdSchema,
|
|
23304
|
+
toolCallId: toolCallIdSchema,
|
|
23305
|
+
answer: runAnswerSchema
|
|
23306
|
+
}),
|
|
23307
|
+
/** A message for the running turn to read at its next step; replied to with `steered`. */
|
|
23308
|
+
runSteerRequestSchema.extend({ type: external_exports.literal("steer"), id: external_exports.string().min(1) }),
|
|
23309
|
+
/** Stops one background task of the conversation's CLI; replied to with `task_stopped`. */
|
|
23310
|
+
external_exports.object({
|
|
23311
|
+
type: external_exports.literal("stop_task"),
|
|
23312
|
+
id: external_exports.string().min(1),
|
|
23313
|
+
runId: runIdSchema,
|
|
23314
|
+
taskId: backgroundTaskIdSchema
|
|
23315
|
+
})
|
|
23316
|
+
]);
|
|
23317
|
+
holderStateSchema = external_exports.enum(["idle", "running", "suspending", "preparing", "reading"]);
|
|
23318
|
+
holderSessionFactsSchema = external_exports.object({
|
|
23319
|
+
/** Wall clock, epoch ms. */
|
|
23320
|
+
startedAtMs: external_exports.number().int().nonnegative(),
|
|
23321
|
+
/** Wall clock, epoch ms; null while a turn runs. */
|
|
23322
|
+
idleSinceMs: external_exports.number().int().nonnegative().nullable(),
|
|
23323
|
+
hasBackgroundWork: external_exports.boolean().default(false),
|
|
23324
|
+
holderRssBytes: external_exports.number().int().nonnegative(),
|
|
23325
|
+
/** The live provider CLI; null when none is running. */
|
|
23326
|
+
cliPid: external_exports.number().int().positive().nullable(),
|
|
23327
|
+
cliRssBytes: external_exports.number().int().nonnegative().nullable(),
|
|
23328
|
+
/** The CLI's executable on PATH is not the file the live CLI was started from. */
|
|
23329
|
+
cliBinaryChanged: external_exports.boolean(),
|
|
23330
|
+
/** The last turn ended with a provider login error. */
|
|
23331
|
+
loginFailed: external_exports.boolean()
|
|
23332
|
+
});
|
|
23333
|
+
holderMessageSchema = external_exports.discriminatedUnion("type", [
|
|
23334
|
+
external_exports.strictObject({
|
|
23335
|
+
type: external_exports.literal("preparation"),
|
|
23336
|
+
id: external_exports.string().min(1),
|
|
23337
|
+
value: sessionPreparationStatusSchema
|
|
23338
|
+
}),
|
|
23339
|
+
external_exports.strictObject({
|
|
23340
|
+
type: external_exports.literal("session_read"),
|
|
23341
|
+
id: external_exports.string().min(1),
|
|
23342
|
+
value: sessionReadResponseSchema
|
|
23343
|
+
}),
|
|
23344
|
+
external_exports.object({
|
|
23345
|
+
type: external_exports.literal("ready"),
|
|
23346
|
+
protocol: external_exports.literal(HOLDER_PROTOCOL),
|
|
23347
|
+
conversationId: conversationIdSchema,
|
|
23348
|
+
pid: external_exports.number().int().positive()
|
|
23349
|
+
}),
|
|
23350
|
+
external_exports.object({ type: external_exports.literal("ack"), id: external_exports.string().min(1) }),
|
|
23351
|
+
external_exports.object({
|
|
23352
|
+
type: external_exports.literal("error"),
|
|
23353
|
+
id: external_exports.string().min(1).nullable(),
|
|
23354
|
+
code: external_exports.string().min(1),
|
|
23355
|
+
message: external_exports.string()
|
|
23356
|
+
}),
|
|
23357
|
+
external_exports.object({
|
|
23358
|
+
type: external_exports.literal("status"),
|
|
23359
|
+
id: external_exports.string().min(1),
|
|
23360
|
+
state: holderStateSchema,
|
|
23361
|
+
runId: runIdSchema.nullable(),
|
|
23362
|
+
facts: holderSessionFactsSchema.optional()
|
|
23363
|
+
}),
|
|
23364
|
+
external_exports.object({ type: external_exports.literal("responded"), id: external_exports.string().min(1), status: runRespondStatusSchema }),
|
|
23365
|
+
external_exports.object({ type: external_exports.literal("steered"), id: external_exports.string().min(1), status: runSteerStatusSchema }),
|
|
23366
|
+
external_exports.object({
|
|
23367
|
+
type: external_exports.literal("task_stopped"),
|
|
23368
|
+
id: external_exports.string().min(1),
|
|
23369
|
+
result: backgroundTaskStopResultSchema
|
|
23370
|
+
}),
|
|
23371
|
+
external_exports.object({ type: external_exports.literal("appended"), runId: runIdSchema, offset: byteOffsetSchema }),
|
|
23372
|
+
external_exports.object({ type: external_exports.literal("turn_ended"), runId: runIdSchema, outcome: runOutcomeSchema })
|
|
23373
|
+
]);
|
|
23374
|
+
holderLaunchSchema = external_exports.object({
|
|
23375
|
+
protocol: external_exports.literal(HOLDER_PROTOCOL),
|
|
23376
|
+
conversationId: conversationIdSchema,
|
|
23377
|
+
machineId: machineIdSchema,
|
|
23378
|
+
endpoint: external_exports.string().min(1),
|
|
23379
|
+
token: external_exports.string().min(32),
|
|
23380
|
+
runsDir: external_exports.string().min(1),
|
|
23381
|
+
statusPath: external_exports.string().min(1)
|
|
23382
|
+
});
|
|
23383
|
+
holderStatusSchema = external_exports.object({
|
|
23384
|
+
protocol: external_exports.number().int().positive(),
|
|
23385
|
+
conversationId: conversationIdSchema,
|
|
23386
|
+
pid: external_exports.number().int().positive(),
|
|
23387
|
+
startedAt: external_exports.string().min(1),
|
|
23388
|
+
/** The holder's command line; with the start time it tells the holder from a pid reuse. */
|
|
23389
|
+
command: external_exports.string().min(1).optional(),
|
|
23390
|
+
endpoint: external_exports.string().min(1),
|
|
23391
|
+
tokenSha256: external_exports.string().regex(/^[a-f0-9]{64}$/),
|
|
23392
|
+
state: holderStateSchema,
|
|
23393
|
+
runId: runIdSchema.nullable(),
|
|
23394
|
+
updatedAt: external_exports.number().int().nonnegative()
|
|
23395
|
+
});
|
|
23396
|
+
}
|
|
23397
|
+
});
|
|
23398
|
+
|
|
23399
|
+
// ../shared/src/runtime-v2/machine-local-sessions.ts
|
|
23400
|
+
var machineSessionRegistrationResponseSchema, machineSessionSubmitSchema, machineSessionAttachmentUploadSchema, machineSessionAttachmentUploadResponseSchema, machineSessionBindingChoiceSchema, machineSessionBindingSchema;
|
|
23401
|
+
var init_machine_local_sessions = __esm({
|
|
23402
|
+
"../shared/src/runtime-v2/machine-local-sessions.ts"() {
|
|
23403
|
+
"use strict";
|
|
23404
|
+
init_zod();
|
|
23405
|
+
init_ids();
|
|
23406
|
+
init_local_sessions();
|
|
23407
|
+
machineSessionRegistrationResponseSchema = external_exports.discriminatedUnion("kind", [
|
|
23408
|
+
external_exports.object({
|
|
23409
|
+
kind: external_exports.literal("registered"),
|
|
23410
|
+
localSessionId: localSessionIdSchema,
|
|
23411
|
+
conversationId: conversationIdSchema,
|
|
23412
|
+
organizationId: external_exports.uuid(),
|
|
23413
|
+
ownerUserId: external_exports.uuid(),
|
|
23414
|
+
teamId: external_exports.uuid(),
|
|
23415
|
+
workspace: external_exports.string()
|
|
23416
|
+
}),
|
|
23417
|
+
external_exports.object({
|
|
23418
|
+
kind: external_exports.literal("team_required"),
|
|
23419
|
+
choices: external_exports.array(external_exports.object({ teamId: external_exports.uuid(), name: external_exports.string() }))
|
|
23420
|
+
})
|
|
23421
|
+
]);
|
|
23422
|
+
machineSessionSubmitSchema = external_exports.strictObject({
|
|
23423
|
+
request: submitSessionRequestSchema,
|
|
23424
|
+
canonicalAttachments: external_exports.array(external_exports.strictObject({ stagedAttachmentId: external_exports.uuid(), canonicalAttachmentId: external_exports.uuid() })).max(10)
|
|
23425
|
+
}).refine(
|
|
23426
|
+
(value) => value.request.attachments.length === value.canonicalAttachments.length && new Set(value.canonicalAttachments.map((item) => item.stagedAttachmentId)).size === value.canonicalAttachments.length && new Set(value.canonicalAttachments.map((item) => item.canonicalAttachmentId)).size === value.canonicalAttachments.length && value.request.attachments.every(
|
|
23427
|
+
(item) => value.canonicalAttachments.some(
|
|
23428
|
+
(mapping) => mapping.stagedAttachmentId === item.attachmentId
|
|
23429
|
+
)
|
|
23430
|
+
),
|
|
23431
|
+
"Each staged attachment needs a unique canonical upload mapping"
|
|
23432
|
+
);
|
|
23433
|
+
machineSessionAttachmentUploadSchema = external_exports.strictObject({ attachment: sessionAttachmentReferenceSchema });
|
|
23434
|
+
machineSessionAttachmentUploadResponseSchema = external_exports.object({
|
|
23435
|
+
canonicalAttachmentId: external_exports.uuid(),
|
|
23436
|
+
uploadUrl: external_exports.url(),
|
|
23437
|
+
headers: external_exports.object({
|
|
23438
|
+
"content-type": external_exports.string().min(1),
|
|
23439
|
+
"x-amz-checksum-sha256": external_exports.string().regex(/^[A-Za-z0-9+/]{43}=$/)
|
|
23440
|
+
})
|
|
23441
|
+
});
|
|
23442
|
+
machineSessionBindingChoiceSchema = external_exports.strictObject({
|
|
23443
|
+
teamId: external_exports.uuid(),
|
|
23444
|
+
organizationId: external_exports.uuid(),
|
|
23445
|
+
name: external_exports.string().min(1).max(1024)
|
|
23446
|
+
});
|
|
23447
|
+
machineSessionBindingSchema = external_exports.strictObject({
|
|
23448
|
+
machineId: machineIdSchema,
|
|
23449
|
+
accountId: external_exports.uuid(),
|
|
23450
|
+
choices: external_exports.array(machineSessionBindingChoiceSchema)
|
|
23451
|
+
});
|
|
23452
|
+
}
|
|
23453
|
+
});
|
|
23454
|
+
|
|
23455
|
+
// ../shared/src/runtime-v2/mcp.ts
|
|
23456
|
+
var init_mcp = __esm({
|
|
23457
|
+
"../shared/src/runtime-v2/mcp.ts"() {
|
|
23458
|
+
"use strict";
|
|
23459
|
+
}
|
|
23460
|
+
});
|
|
23461
|
+
|
|
23462
|
+
// ../shared/src/runtime-v2/run-log-upload.ts
|
|
23463
|
+
function runLogUploadPath(conversationId) {
|
|
23464
|
+
return `/public/conversations/${encodeURIComponent(conversationId)}/transcript`;
|
|
23465
|
+
}
|
|
23466
|
+
var DESIRED_STATE_PATH, RUN_LOG_UPLOAD_HEADERS, offsetSchema, runLogUploadReceiptSchema, runLogUploadResponseSchema;
|
|
23467
|
+
var init_run_log_upload = __esm({
|
|
23468
|
+
"../shared/src/runtime-v2/run-log-upload.ts"() {
|
|
23469
|
+
"use strict";
|
|
23470
|
+
init_zod();
|
|
23471
|
+
DESIRED_STATE_PATH = "/public/machines/me/desired";
|
|
22526
23472
|
RUN_LOG_UPLOAD_HEADERS = {
|
|
22527
23473
|
runId: "x-alan-run-id",
|
|
22528
23474
|
offset: "x-alan-offset",
|
|
@@ -22587,6 +23533,211 @@ var init_run_media = __esm({
|
|
|
22587
23533
|
}
|
|
22588
23534
|
});
|
|
22589
23535
|
|
|
23536
|
+
// ../shared/src/runtime-v2/session-lineage.ts
|
|
23537
|
+
var sessionHistoryVersionSchema, sessionHistoryCutoffSchema, sessionHistoryMemberSchema, canonicalSessionHistoryQuerySchema, managedSessionHistorySchema, sessionHistoryViewSchema;
|
|
23538
|
+
var init_session_lineage = __esm({
|
|
23539
|
+
"../shared/src/runtime-v2/session-lineage.ts"() {
|
|
23540
|
+
"use strict";
|
|
23541
|
+
init_zod();
|
|
23542
|
+
sessionHistoryVersionSchema = external_exports.strictObject({
|
|
23543
|
+
revision: external_exports.number().int().min(0).max(2147483647),
|
|
23544
|
+
membershipDigest: external_exports.string().regex(/^[0-9a-f]{64}$/)
|
|
23545
|
+
});
|
|
23546
|
+
sessionHistoryCutoffSchema = external_exports.strictObject({
|
|
23547
|
+
userMessageId: external_exports.uuid(),
|
|
23548
|
+
ordinal: external_exports.number().int().min(0).max(2147483647)
|
|
23549
|
+
});
|
|
23550
|
+
sessionHistoryMemberSchema = external_exports.strictObject({
|
|
23551
|
+
messageId: external_exports.uuid(),
|
|
23552
|
+
ordinal: external_exports.number().int().min(0).max(2147483647),
|
|
23553
|
+
role: external_exports.enum(["user", "assistant"])
|
|
23554
|
+
});
|
|
23555
|
+
canonicalSessionHistoryQuerySchema = external_exports.strictObject({
|
|
23556
|
+
conversationId: external_exports.uuid(),
|
|
23557
|
+
view: external_exports.enum(["visible", "retained"]),
|
|
23558
|
+
limit: external_exports.number().int().min(1).max(256),
|
|
23559
|
+
afterOrdinal: external_exports.number().int().min(0).max(2147483647).optional(),
|
|
23560
|
+
expected: sessionHistoryVersionSchema.optional()
|
|
23561
|
+
}).refine((query) => query.afterOrdinal === void 0 || query.expected !== void 0, {
|
|
23562
|
+
message: "Continuation requires a canonical version"
|
|
23563
|
+
});
|
|
23564
|
+
managedSessionHistorySchema = external_exports.strictObject({
|
|
23565
|
+
kind: external_exports.literal("managed"),
|
|
23566
|
+
conversationId: external_exports.uuid(),
|
|
23567
|
+
version: sessionHistoryVersionSchema,
|
|
23568
|
+
cutoff: sessionHistoryCutoffSchema.nullable(),
|
|
23569
|
+
view: external_exports.enum(["visible", "retained"]),
|
|
23570
|
+
members: external_exports.array(sessionHistoryMemberSchema).max(256),
|
|
23571
|
+
nextAfterOrdinal: external_exports.number().int().min(0).max(2147483647).nullable()
|
|
23572
|
+
}).superRefine((page, ctx) => {
|
|
23573
|
+
const ids = /* @__PURE__ */ new Set();
|
|
23574
|
+
let previous = -1;
|
|
23575
|
+
for (const member of page.members) {
|
|
23576
|
+
if (ids.has(member.messageId) || member.ordinal <= previous || page.view === "visible" && page.cutoff !== null && member.ordinal >= page.cutoff.ordinal) {
|
|
23577
|
+
ctx.addIssue({ code: "custom", message: "Invalid canonical member order or cutoff" });
|
|
23578
|
+
}
|
|
23579
|
+
ids.add(member.messageId);
|
|
23580
|
+
previous = member.ordinal;
|
|
23581
|
+
}
|
|
23582
|
+
if (page.nextAfterOrdinal !== null && page.nextAfterOrdinal !== page.members.at(-1)?.ordinal) {
|
|
23583
|
+
ctx.addIssue({
|
|
23584
|
+
code: "custom",
|
|
23585
|
+
message: "Continuation must identify the last returned member"
|
|
23586
|
+
});
|
|
23587
|
+
}
|
|
23588
|
+
});
|
|
23589
|
+
sessionHistoryViewSchema = external_exports.discriminatedUnion("kind", [
|
|
23590
|
+
external_exports.strictObject({ kind: external_exports.literal("legacy"), conversationId: external_exports.uuid() }),
|
|
23591
|
+
managedSessionHistorySchema
|
|
23592
|
+
]);
|
|
23593
|
+
}
|
|
23594
|
+
});
|
|
23595
|
+
|
|
23596
|
+
// ../shared/src/runtime-v2/session-management.ts
|
|
23597
|
+
var sessionMetadataSchema, sessionCatalogQuerySchema, sessionCatalogSchema, sessionMetadataMutationSchema, sessionMetadataReceiptSchema, sessionHistoryQuerySchema, sessionHistoryCoverageSchema, sessionHistoryContributionSchema, sessionHistoryContributionsSchema, sessionHistorySchema;
|
|
23598
|
+
var init_session_management = __esm({
|
|
23599
|
+
"../shared/src/runtime-v2/session-management.ts"() {
|
|
23600
|
+
"use strict";
|
|
23601
|
+
init_zod();
|
|
23602
|
+
init_ids();
|
|
23603
|
+
init_local_sessions();
|
|
23604
|
+
sessionMetadataSchema = external_exports.object({
|
|
23605
|
+
localSessionId: localSessionIdSchema,
|
|
23606
|
+
conversationId: conversationIdSchema,
|
|
23607
|
+
teamId: external_exports.uuid(),
|
|
23608
|
+
workspace: external_exports.string(),
|
|
23609
|
+
title: external_exports.string(),
|
|
23610
|
+
archived: external_exports.boolean(),
|
|
23611
|
+
busy: external_exports.boolean(),
|
|
23612
|
+
updatedAt: external_exports.iso.datetime(),
|
|
23613
|
+
currentSelection: external_exports.object({ model: external_exports.string().nullable(), mode: external_exports.string(), effort: external_exports.string().nullable() }).optional()
|
|
23614
|
+
});
|
|
23615
|
+
sessionCatalogQuerySchema = external_exports.strictObject({
|
|
23616
|
+
workspace: external_exports.string().min(1).max(4096),
|
|
23617
|
+
after: external_exports.uuid().optional(),
|
|
23618
|
+
limit: external_exports.coerce.number().int().min(1).max(100).default(50),
|
|
23619
|
+
includeArchived: external_exports.boolean().default(false)
|
|
23620
|
+
});
|
|
23621
|
+
sessionCatalogSchema = external_exports.object({
|
|
23622
|
+
sessions: external_exports.array(sessionMetadataSchema),
|
|
23623
|
+
nextCursor: external_exports.uuid().nullable()
|
|
23624
|
+
});
|
|
23625
|
+
sessionMetadataMutationSchema = external_exports.discriminatedUnion("kind", [
|
|
23626
|
+
external_exports.strictObject({
|
|
23627
|
+
requestId: sessionRequestIdSchema,
|
|
23628
|
+
kind: external_exports.literal("rename"),
|
|
23629
|
+
title: external_exports.string().trim().min(1).max(500)
|
|
23630
|
+
}),
|
|
23631
|
+
external_exports.strictObject({ requestId: sessionRequestIdSchema, kind: external_exports.literal("archive") })
|
|
23632
|
+
]);
|
|
23633
|
+
sessionMetadataReceiptSchema = external_exports.object({
|
|
23634
|
+
requestId: sessionRequestIdSchema,
|
|
23635
|
+
session: sessionMetadataSchema
|
|
23636
|
+
});
|
|
23637
|
+
sessionHistoryQuerySchema = external_exports.strictObject({
|
|
23638
|
+
before: external_exports.coerce.number().int().nonnegative().max(2147483647).optional(),
|
|
23639
|
+
limit: external_exports.coerce.number().int().min(1).max(10).default(10)
|
|
23640
|
+
});
|
|
23641
|
+
sessionHistoryCoverageSchema = external_exports.discriminatedUnion("kind", [
|
|
23642
|
+
external_exports.object({
|
|
23643
|
+
kind: external_exports.literal("runtime_run_log"),
|
|
23644
|
+
runId: runIdSchema,
|
|
23645
|
+
lastCompleteSequence: external_exports.number().int().positive().max(Number.MAX_SAFE_INTEGER).nullable()
|
|
23646
|
+
}),
|
|
23647
|
+
external_exports.object({
|
|
23648
|
+
kind: external_exports.literal("historical_only"),
|
|
23649
|
+
reason: external_exports.enum([
|
|
23650
|
+
"unverified_source",
|
|
23651
|
+
"association_changed",
|
|
23652
|
+
"invalid_record_sequence",
|
|
23653
|
+
"unsupported_lineage"
|
|
23654
|
+
])
|
|
23655
|
+
})
|
|
23656
|
+
]);
|
|
23657
|
+
sessionHistoryContributionSchema = external_exports.object({
|
|
23658
|
+
assistantMessageId: external_exports.uuid(),
|
|
23659
|
+
ordinal: external_exports.number().int().nonnegative(),
|
|
23660
|
+
sourceRevision: external_exports.string(),
|
|
23661
|
+
updates: external_exports.array(localSessionUpdateSchema),
|
|
23662
|
+
coverage: sessionHistoryCoverageSchema
|
|
23663
|
+
});
|
|
23664
|
+
sessionHistoryContributionsSchema = external_exports.object({
|
|
23665
|
+
version: external_exports.literal(1),
|
|
23666
|
+
users: external_exports.array(
|
|
23667
|
+
external_exports.object({
|
|
23668
|
+
userMessageId: external_exports.uuid(),
|
|
23669
|
+
ordinal: external_exports.number().int().nonnegative(),
|
|
23670
|
+
updates: external_exports.array(localSessionUpdateSchema)
|
|
23671
|
+
})
|
|
23672
|
+
),
|
|
23673
|
+
assistants: external_exports.array(sessionHistoryContributionSchema)
|
|
23674
|
+
});
|
|
23675
|
+
sessionHistorySchema = external_exports.object({
|
|
23676
|
+
contributions: sessionHistoryContributionsSchema.optional(),
|
|
23677
|
+
conversationId: conversationIdSchema,
|
|
23678
|
+
revision: external_exports.string(),
|
|
23679
|
+
before: external_exports.number().int().nonnegative().nullable(),
|
|
23680
|
+
messages: external_exports.array(
|
|
23681
|
+
external_exports.object({ id: external_exports.uuid(), role: external_exports.string(), ordinal: external_exports.number().int().nonnegative().nullable() })
|
|
23682
|
+
),
|
|
23683
|
+
runs: external_exports.array(external_exports.object({ runId: runIdSchema, assistantMessageId: external_exports.uuid() })),
|
|
23684
|
+
turns: external_exports.array(
|
|
23685
|
+
external_exports.object({
|
|
23686
|
+
ordinal: external_exports.number().int().nonnegative(),
|
|
23687
|
+
updates: external_exports.array(localSessionUpdateSchema)
|
|
23688
|
+
})
|
|
23689
|
+
)
|
|
23690
|
+
});
|
|
23691
|
+
}
|
|
23692
|
+
});
|
|
23693
|
+
|
|
23694
|
+
// ../shared/src/runtime-v2/session-request-display.ts
|
|
23695
|
+
var canonicalRequestId, sessionRequestDisplayQuerySchema, sessionRequestDisplaySchema, sessionRequestDisplayResponseSchema;
|
|
23696
|
+
var init_session_request_display = __esm({
|
|
23697
|
+
"../shared/src/runtime-v2/session-request-display.ts"() {
|
|
23698
|
+
"use strict";
|
|
23699
|
+
init_zod();
|
|
23700
|
+
init_attachments();
|
|
23701
|
+
init_local_sessions();
|
|
23702
|
+
init_session_operation();
|
|
23703
|
+
canonicalRequestId = sessionRequestIdSchema.refine((id) => id === id.toLowerCase());
|
|
23704
|
+
sessionRequestDisplayQuerySchema = external_exports.strictObject({
|
|
23705
|
+
requestIds: external_exports.array(canonicalRequestId).min(1).max(64).refine((ids) => new Set(ids).size === ids.length)
|
|
23706
|
+
});
|
|
23707
|
+
sessionRequestDisplaySchema = external_exports.strictObject({
|
|
23708
|
+
requestId: canonicalRequestId,
|
|
23709
|
+
admissionOrder: external_exports.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
|
|
23710
|
+
text: external_exports.string(),
|
|
23711
|
+
intent: external_exports.enum(["followUp", "steer"]),
|
|
23712
|
+
operation: sessionOperationSchema.optional(),
|
|
23713
|
+
attachments: external_exports.array(
|
|
23714
|
+
external_exports.strictObject({
|
|
23715
|
+
name: requestPresignedUploadSchema.shape.filename.refine(
|
|
23716
|
+
(value) => !/[\\/\0]/.test(value) && value !== "." && value !== ".."
|
|
23717
|
+
),
|
|
23718
|
+
mediaType: requestPresignedUploadSchema.shape.mimeType,
|
|
23719
|
+
sizeBytes: requestPresignedUploadSchema.shape.size
|
|
23720
|
+
})
|
|
23721
|
+
).max(MAX_COMMENT_ATTACHMENTS)
|
|
23722
|
+
});
|
|
23723
|
+
sessionRequestDisplayResponseSchema = external_exports.strictObject({
|
|
23724
|
+
localSessionId: localSessionIdSchema,
|
|
23725
|
+
items: external_exports.array(sessionRequestDisplaySchema).max(64),
|
|
23726
|
+
missingRequestIds: external_exports.array(canonicalRequestId).max(64),
|
|
23727
|
+
remainingRequestIds: external_exports.array(canonicalRequestId).max(64)
|
|
23728
|
+
}).refine((value) => {
|
|
23729
|
+
const ids = [
|
|
23730
|
+
...value.items.map((item) => item.requestId),
|
|
23731
|
+
...value.missingRequestIds,
|
|
23732
|
+
...value.remainingRequestIds
|
|
23733
|
+
];
|
|
23734
|
+
return ids.length <= 64 && new Set(ids).size === ids.length && value.items.every(
|
|
23735
|
+
(item, index) => index === 0 || item.admissionOrder > (value.items[index - 1]?.admissionOrder ?? -1)
|
|
23736
|
+
) && (value.remainingRequestIds.length === 0 || value.items.length > 0);
|
|
23737
|
+
}, "Display response must be unique, ordered and make progress");
|
|
23738
|
+
}
|
|
23739
|
+
});
|
|
23740
|
+
|
|
22590
23741
|
// ../shared/src/runtime-v2/skills.ts
|
|
22591
23742
|
var MAX_MACHINE_SKILLS, installedMachineSkillSchema, MAX_SKILL_UPLOADS, machineSkillScanRepositorySchema, machineSkillScanContextSchema, machineLocalSkillsReportSchema, machineSkillUploadSchema, machineSkillsSyncRequestSchema, desiredMachineSkillSchema, machineSkillDownloadSchema, machineSkillsSyncResponseSchema;
|
|
22592
23743
|
var init_skills = __esm({
|
|
@@ -22700,7 +23851,9 @@ var init_runtime_v2 = __esm({
|
|
|
22700
23851
|
init_activity_lease();
|
|
22701
23852
|
init_agent_context();
|
|
22702
23853
|
init_capabilities();
|
|
23854
|
+
init_cloud_sessions();
|
|
22703
23855
|
init_commit_attribution();
|
|
23856
|
+
init_delegation();
|
|
22704
23857
|
init_desired_state();
|
|
22705
23858
|
init_files();
|
|
22706
23859
|
init_git_capability();
|
|
@@ -22708,56 +23861,70 @@ var init_runtime_v2 = __esm({
|
|
|
22708
23861
|
init_holder_protocol();
|
|
22709
23862
|
init_ids();
|
|
22710
23863
|
init_link();
|
|
23864
|
+
init_local_sessions();
|
|
22711
23865
|
init_machine_identity();
|
|
23866
|
+
init_machine_local_sessions();
|
|
22712
23867
|
init_mcp();
|
|
22713
23868
|
init_run_log();
|
|
22714
23869
|
init_run_log_upload();
|
|
22715
23870
|
init_run_media();
|
|
23871
|
+
init_session_interaction();
|
|
23872
|
+
init_session_lineage();
|
|
23873
|
+
init_session_management();
|
|
23874
|
+
init_session_operation();
|
|
23875
|
+
init_session_preparation();
|
|
23876
|
+
init_session_presentation();
|
|
23877
|
+
init_session_reads();
|
|
23878
|
+
init_session_request_display();
|
|
22716
23879
|
init_skills();
|
|
22717
23880
|
init_workspace();
|
|
22718
23881
|
}
|
|
22719
23882
|
});
|
|
22720
23883
|
|
|
22721
|
-
// src/lease-entry.ts
|
|
22722
|
-
var import_node_worker_threads = require("worker_threads");
|
|
22723
|
-
|
|
22724
|
-
// src/cli/commands/activity-lease-worker.ts
|
|
22725
|
-
var import_node_fs3 = require("fs");
|
|
22726
|
-
|
|
22727
|
-
// src/api-client/index.ts
|
|
22728
|
-
var import_node_crypto2 = require("crypto");
|
|
22729
|
-
init_runtime_v2();
|
|
22730
|
-
|
|
22731
23884
|
// src/kernel/fault.ts
|
|
22732
|
-
var RuntimeFault = class extends Error {
|
|
22733
|
-
code;
|
|
22734
|
-
constructor(code, message, options) {
|
|
22735
|
-
super(message, options);
|
|
22736
|
-
this.name = "RuntimeFault";
|
|
22737
|
-
this.code = code;
|
|
22738
|
-
}
|
|
22739
|
-
};
|
|
22740
23885
|
function errnoCode(error62) {
|
|
22741
23886
|
return error62 instanceof Error && "code" in error62 && typeof error62.code === "string" ? error62.code : void 0;
|
|
22742
23887
|
}
|
|
23888
|
+
var RuntimeFault;
|
|
23889
|
+
var init_fault = __esm({
|
|
23890
|
+
"src/kernel/fault.ts"() {
|
|
23891
|
+
"use strict";
|
|
23892
|
+
RuntimeFault = class extends Error {
|
|
23893
|
+
code;
|
|
23894
|
+
constructor(code, message, options) {
|
|
23895
|
+
super(message, options);
|
|
23896
|
+
this.name = "RuntimeFault";
|
|
23897
|
+
this.code = code;
|
|
23898
|
+
}
|
|
23899
|
+
};
|
|
23900
|
+
}
|
|
23901
|
+
});
|
|
22743
23902
|
|
|
22744
23903
|
// src/kernel/clock.ts
|
|
22745
|
-
var import_node_perf_hooks
|
|
22746
|
-
var
|
|
22747
|
-
|
|
22748
|
-
|
|
22749
|
-
|
|
22750
|
-
|
|
22751
|
-
|
|
23904
|
+
var import_node_perf_hooks, import_promises, systemClock;
|
|
23905
|
+
var init_clock = __esm({
|
|
23906
|
+
"src/kernel/clock.ts"() {
|
|
23907
|
+
"use strict";
|
|
23908
|
+
import_node_perf_hooks = require("node:perf_hooks");
|
|
23909
|
+
import_promises = require("node:timers/promises");
|
|
23910
|
+
systemClock = {
|
|
23911
|
+
now: () => Date.now(),
|
|
23912
|
+
monotonic: () => import_node_perf_hooks.performance.now(),
|
|
23913
|
+
sleep: async (ms, signal) => {
|
|
23914
|
+
try {
|
|
23915
|
+
await (0, import_promises.setTimeout)(ms, void 0, { signal });
|
|
23916
|
+
} catch (error62) {
|
|
23917
|
+
if (signal.aborted && error62 instanceof Error && error62.name === "AbortError" && "code" in error62 && error62.code === "ABORT_ERR" && Object.is(error62.cause, signal.reason)) {
|
|
23918
|
+
throw signal.reason;
|
|
23919
|
+
}
|
|
23920
|
+
throw error62;
|
|
23921
|
+
}
|
|
23922
|
+
}
|
|
23923
|
+
};
|
|
22752
23924
|
}
|
|
22753
|
-
};
|
|
23925
|
+
});
|
|
22754
23926
|
|
|
22755
23927
|
// src/kernel/json-file.ts
|
|
22756
|
-
var import_node_crypto = require("crypto");
|
|
22757
|
-
var import_node_fs = require("fs");
|
|
22758
|
-
var import_promises2 = require("fs/promises");
|
|
22759
|
-
var import_node_path = require("path");
|
|
22760
|
-
var import_promises3 = require("timers/promises");
|
|
22761
23928
|
async function readJsonFile(path, schema) {
|
|
22762
23929
|
let text;
|
|
22763
23930
|
try {
|
|
@@ -22776,21 +23943,16 @@ async function readJsonFile(path, schema) {
|
|
|
22776
23943
|
if (!parsed.success) return { kind: "invalid", reason: parsed.error.message };
|
|
22777
23944
|
return { kind: "ok", value: parsed.data };
|
|
22778
23945
|
}
|
|
23946
|
+
var import_promises2;
|
|
23947
|
+
var init_json_file = __esm({
|
|
23948
|
+
"src/kernel/json-file.ts"() {
|
|
23949
|
+
"use strict";
|
|
23950
|
+
import_promises2 = require("node:fs/promises");
|
|
23951
|
+
init_fault();
|
|
23952
|
+
}
|
|
23953
|
+
});
|
|
22779
23954
|
|
|
22780
23955
|
// src/kernel/log.ts
|
|
22781
|
-
var import_node_fs2 = require("fs");
|
|
22782
|
-
var import_node_path2 = require("path");
|
|
22783
|
-
var LEVEL_RANK = /* @__PURE__ */ new Map([
|
|
22784
|
-
["debug", 10],
|
|
22785
|
-
["info", 20],
|
|
22786
|
-
["warn", 30],
|
|
22787
|
-
["error", 40]
|
|
22788
|
-
]);
|
|
22789
|
-
var REDACTED = "[REDACTED]";
|
|
22790
|
-
var MAX_DEPTH = 6;
|
|
22791
|
-
var SENSITIVE_KEY = /(^authorization$|^cookie$|^setcookie$|password$|secret$|token$|apikey$|privatekey$|credentials?$)/;
|
|
22792
|
-
var BEARER_IN_STRING = /Bearer\s+[A-Za-z0-9._~+/-]+=*/g;
|
|
22793
|
-
var TOKEN_IN_STRING = /\b(?:eyJ[A-Za-z0-9_-]{20,}(?:\.[A-Za-z0-9_-]+){1,2}|(?:alan|aiden)_[A-Za-z0-9_]{16,}|sk-ant-[A-Za-z0-9_-]{16,})\b/g;
|
|
22794
23956
|
function isSensitiveKey(key) {
|
|
22795
23957
|
return SENSITIVE_KEY.test(key.toLowerCase().replace(/[^a-z0-9]/g, ""));
|
|
22796
23958
|
}
|
|
@@ -22823,8 +23985,8 @@ function createLog(level, clock, sink) {
|
|
|
22823
23985
|
const emit = (entryLevel, event, fields) => {
|
|
22824
23986
|
if ((LEVEL_RANK.get(entryLevel) ?? 0) < threshold) return;
|
|
22825
23987
|
const safe = redact(fields ?? {});
|
|
22826
|
-
const
|
|
22827
|
-
sink({ at: clock.now(), level: entryLevel, event, fields: { ...
|
|
23988
|
+
const record3 = safe !== null && typeof safe === "object" && !Array.isArray(safe) ? safe : {};
|
|
23989
|
+
sink({ at: clock.now(), level: entryLevel, event, fields: { ...record3 } });
|
|
22828
23990
|
};
|
|
22829
23991
|
return {
|
|
22830
23992
|
debug: (event, fields) => emit("debug", event, fields),
|
|
@@ -22834,12 +23996,12 @@ function createLog(level, clock, sink) {
|
|
|
22834
23996
|
};
|
|
22835
23997
|
}
|
|
22836
23998
|
function openFileLog(path, level, clock) {
|
|
22837
|
-
(0,
|
|
22838
|
-
const fd = (0,
|
|
23999
|
+
(0, import_node_fs.mkdirSync)((0, import_node_path.dirname)(path), { recursive: true, mode: 448 });
|
|
24000
|
+
const fd = (0, import_node_fs.openSync)(path, "a", 384);
|
|
22839
24001
|
let closed = false;
|
|
22840
24002
|
const log = createLog(level, clock, (entry) => {
|
|
22841
24003
|
if (closed) return;
|
|
22842
|
-
(0,
|
|
24004
|
+
(0, import_node_fs.writeSync)(fd, `${JSON.stringify(entry)}
|
|
22843
24005
|
`);
|
|
22844
24006
|
});
|
|
22845
24007
|
return {
|
|
@@ -22847,10 +24009,29 @@ function openFileLog(path, level, clock) {
|
|
|
22847
24009
|
[Symbol.dispose]: () => {
|
|
22848
24010
|
if (closed) return;
|
|
22849
24011
|
closed = true;
|
|
22850
|
-
(0,
|
|
24012
|
+
(0, import_node_fs.closeSync)(fd);
|
|
22851
24013
|
}
|
|
22852
24014
|
};
|
|
22853
24015
|
}
|
|
24016
|
+
var import_node_fs, import_node_path, LEVEL_RANK, REDACTED, MAX_DEPTH, SENSITIVE_KEY, BEARER_IN_STRING, TOKEN_IN_STRING;
|
|
24017
|
+
var init_log = __esm({
|
|
24018
|
+
"src/kernel/log.ts"() {
|
|
24019
|
+
"use strict";
|
|
24020
|
+
import_node_fs = require("node:fs");
|
|
24021
|
+
import_node_path = require("node:path");
|
|
24022
|
+
LEVEL_RANK = /* @__PURE__ */ new Map([
|
|
24023
|
+
["debug", 10],
|
|
24024
|
+
["info", 20],
|
|
24025
|
+
["warn", 30],
|
|
24026
|
+
["error", 40]
|
|
24027
|
+
]);
|
|
24028
|
+
REDACTED = "[REDACTED]";
|
|
24029
|
+
MAX_DEPTH = 6;
|
|
24030
|
+
SENSITIVE_KEY = /(^authorization$|^cookie$|^setcookie$|password$|secret$|token$|apikey$|privatekey$|credentials?$)/;
|
|
24031
|
+
BEARER_IN_STRING = /Bearer\s+[A-Za-z0-9._~+/-]+=*/g;
|
|
24032
|
+
TOKEN_IN_STRING = /\b(?:eyJ[A-Za-z0-9_-]{20,}(?:\.[A-Za-z0-9_-]+){1,2}|(?:alan|aiden)_[A-Za-z0-9_]{16,}|sk-ant-[A-Za-z0-9_-]{16,})\b/g;
|
|
24033
|
+
}
|
|
24034
|
+
});
|
|
22854
24035
|
|
|
22855
24036
|
// src/kernel/maintenance.ts
|
|
22856
24037
|
function startMaintenance({ everyMs, jobs, clock, log }) {
|
|
@@ -22891,10 +24072,150 @@ function startMaintenance({ everyMs, jobs, clock, log }) {
|
|
|
22891
24072
|
}
|
|
22892
24073
|
};
|
|
22893
24074
|
}
|
|
24075
|
+
var init_maintenance = __esm({
|
|
24076
|
+
"src/kernel/maintenance.ts"() {
|
|
24077
|
+
"use strict";
|
|
24078
|
+
}
|
|
24079
|
+
});
|
|
24080
|
+
|
|
24081
|
+
// src/kernel/index.ts
|
|
24082
|
+
var init_kernel = __esm({
|
|
24083
|
+
"src/kernel/index.ts"() {
|
|
24084
|
+
"use strict";
|
|
24085
|
+
init_clock();
|
|
24086
|
+
init_fault();
|
|
24087
|
+
init_json_file();
|
|
24088
|
+
init_log();
|
|
24089
|
+
init_maintenance();
|
|
24090
|
+
}
|
|
24091
|
+
});
|
|
24092
|
+
|
|
24093
|
+
// src/platform/process-identity.ts
|
|
24094
|
+
function isProcessAlive(pid) {
|
|
24095
|
+
try {
|
|
24096
|
+
process.kill(pid, 0);
|
|
24097
|
+
return true;
|
|
24098
|
+
} catch (error62) {
|
|
24099
|
+
return errnoCode(error62) === "EPERM";
|
|
24100
|
+
}
|
|
24101
|
+
}
|
|
24102
|
+
var import_node_child_process, import_node_util, execFileAsync;
|
|
24103
|
+
var init_process_identity = __esm({
|
|
24104
|
+
"src/platform/process-identity.ts"() {
|
|
24105
|
+
"use strict";
|
|
24106
|
+
import_node_child_process = require("node:child_process");
|
|
24107
|
+
import_node_util = require("node:util");
|
|
24108
|
+
init_kernel();
|
|
24109
|
+
execFileAsync = (0, import_node_util.promisify)(import_node_child_process.execFile);
|
|
24110
|
+
}
|
|
24111
|
+
});
|
|
24112
|
+
|
|
24113
|
+
// src/platform/vm-stats.ts
|
|
24114
|
+
function fieldOf(text, name) {
|
|
24115
|
+
const match = new RegExp(`^${name}[:\\s]+(\\d+)`, "m").exec(text);
|
|
24116
|
+
return match?.[1] === void 0 ? null : Number(match[1]);
|
|
24117
|
+
}
|
|
24118
|
+
function parseVmCounters(meminfo, vmstat, loadavg) {
|
|
24119
|
+
const availableKb = fieldOf(meminfo, "MemAvailable");
|
|
24120
|
+
const totalKb = fieldOf(meminfo, "MemTotal");
|
|
24121
|
+
const load = Number(loadavg.trim().split(/\s+/)[0]);
|
|
24122
|
+
if (availableKb === null || totalKb === null || totalKb <= 0 || !Number.isFinite(load)) {
|
|
24123
|
+
return null;
|
|
24124
|
+
}
|
|
24125
|
+
return {
|
|
24126
|
+
memAvailableBytes: availableKb * 1024,
|
|
24127
|
+
memTotalBytes: totalKb * 1024,
|
|
24128
|
+
pgscanDirect: fieldOf(vmstat, "pgscan_direct") ?? 0,
|
|
24129
|
+
workingsetRefaultFile: fieldOf(vmstat, "workingset_refault_file") ?? fieldOf(vmstat, "workingset_refault") ?? 0,
|
|
24130
|
+
loadAverage1m: Math.max(0, load)
|
|
24131
|
+
};
|
|
24132
|
+
}
|
|
24133
|
+
async function readVmCounters(platform = process.platform) {
|
|
24134
|
+
if (platform !== "linux") return null;
|
|
24135
|
+
try {
|
|
24136
|
+
const [meminfo, vmstat, loadavg] = await Promise.all([
|
|
24137
|
+
(0, import_promises3.readFile)("/proc/meminfo", "utf8"),
|
|
24138
|
+
(0, import_promises3.readFile)("/proc/vmstat", "utf8"),
|
|
24139
|
+
(0, import_promises3.readFile)("/proc/loadavg", "utf8")
|
|
24140
|
+
]);
|
|
24141
|
+
return parseVmCounters(meminfo, vmstat, loadavg);
|
|
24142
|
+
} catch {
|
|
24143
|
+
return null;
|
|
24144
|
+
}
|
|
24145
|
+
}
|
|
24146
|
+
function parseProcStat(stat3) {
|
|
24147
|
+
const fields = stat3.slice(stat3.lastIndexOf(")") + 2).split(" ");
|
|
24148
|
+
const ppid = Number(fields[1]);
|
|
24149
|
+
const utime = Number(fields[11]);
|
|
24150
|
+
const stime = Number(fields[12]);
|
|
24151
|
+
if (![ppid, utime, stime].every(Number.isFinite)) return null;
|
|
24152
|
+
return { ppid, cpuMs: (utime + stime) * 1e3 / CLOCK_TICKS_PER_SECOND };
|
|
24153
|
+
}
|
|
24154
|
+
async function readProcessCpuTable(platform = process.platform) {
|
|
24155
|
+
const table = /* @__PURE__ */ new Map();
|
|
24156
|
+
if (platform !== "linux") return table;
|
|
24157
|
+
const entries = await (0, import_promises3.readdir)("/proc").catch(() => []);
|
|
24158
|
+
await Promise.all(
|
|
24159
|
+
entries.filter((entry) => /^\d+$/.test(entry)).map(async (entry) => {
|
|
24160
|
+
const stat3 = await (0, import_promises3.readFile)(`/proc/${entry}/stat`, "utf8").catch(() => null);
|
|
24161
|
+
const row = stat3 === null ? null : parseProcStat(stat3);
|
|
24162
|
+
if (row !== null) table.set(Number(entry), row);
|
|
24163
|
+
})
|
|
24164
|
+
);
|
|
24165
|
+
return table;
|
|
24166
|
+
}
|
|
24167
|
+
function processTreeCpuMs(table, pid) {
|
|
24168
|
+
if (!table.has(pid)) return null;
|
|
24169
|
+
const children = /* @__PURE__ */ new Map();
|
|
24170
|
+
for (const [child, row] of table) {
|
|
24171
|
+
const siblings = children.get(row.ppid) ?? [];
|
|
24172
|
+
siblings.push(child);
|
|
24173
|
+
children.set(row.ppid, siblings);
|
|
24174
|
+
}
|
|
24175
|
+
let total = 0;
|
|
24176
|
+
const seen = /* @__PURE__ */ new Set();
|
|
24177
|
+
const queue = [pid];
|
|
24178
|
+
for (const next of queue) {
|
|
24179
|
+
if (seen.has(next)) continue;
|
|
24180
|
+
seen.add(next);
|
|
24181
|
+
total += table.get(next)?.cpuMs ?? 0;
|
|
24182
|
+
queue.push(...children.get(next) ?? []);
|
|
24183
|
+
}
|
|
24184
|
+
return Math.round(total);
|
|
24185
|
+
}
|
|
24186
|
+
var import_promises3, CLOCK_TICKS_PER_SECOND;
|
|
24187
|
+
var init_vm_stats = __esm({
|
|
24188
|
+
"src/platform/vm-stats.ts"() {
|
|
24189
|
+
"use strict";
|
|
24190
|
+
import_promises3 = require("node:fs/promises");
|
|
24191
|
+
CLOCK_TICKS_PER_SECOND = 100;
|
|
24192
|
+
}
|
|
24193
|
+
});
|
|
24194
|
+
|
|
24195
|
+
// src/platform/index.ts
|
|
24196
|
+
var init_platform = __esm({
|
|
24197
|
+
"src/platform/index.ts"() {
|
|
24198
|
+
"use strict";
|
|
24199
|
+
init_process_identity();
|
|
24200
|
+
init_vm_stats();
|
|
24201
|
+
}
|
|
24202
|
+
});
|
|
24203
|
+
|
|
24204
|
+
// src/lease-entry.ts
|
|
24205
|
+
var import_node_worker_threads = require("node:worker_threads");
|
|
24206
|
+
|
|
24207
|
+
// src/cli/commands/activity-lease-worker.ts
|
|
24208
|
+
var import_node_fs2 = require("node:fs");
|
|
24209
|
+
|
|
24210
|
+
// src/api-client/index.ts
|
|
24211
|
+
var import_node_crypto = require("node:crypto");
|
|
24212
|
+
init_runtime_v2();
|
|
24213
|
+
init_kernel();
|
|
22894
24214
|
|
|
22895
24215
|
// src/api-client/http.ts
|
|
22896
|
-
var import_node_http = require("http");
|
|
22897
|
-
var import_node_https = require("https");
|
|
24216
|
+
var import_node_http = require("node:http");
|
|
24217
|
+
var import_node_https = require("node:https");
|
|
24218
|
+
init_kernel();
|
|
22898
24219
|
var IDLE_SOCKET_MS = 4e3;
|
|
22899
24220
|
var MAX_REDIRECTS = 20;
|
|
22900
24221
|
var STALE_SOCKET_RETRIES = 2;
|
|
@@ -23062,6 +24383,12 @@ function createHttpTransport() {
|
|
|
23062
24383
|
}
|
|
23063
24384
|
|
|
23064
24385
|
// src/api-client/index.ts
|
|
24386
|
+
var CENTRAL_SESSION_FEATURES = [
|
|
24387
|
+
SESSION_INTERACTION_FEATURE,
|
|
24388
|
+
SESSION_OPERATIONS_FEATURE,
|
|
24389
|
+
SESSION_SELECTION_FEATURE,
|
|
24390
|
+
BOUNDED_DELEGATION_FEATURE
|
|
24391
|
+
];
|
|
23065
24392
|
var REQUEST_TIMEOUT_MS = 3e4;
|
|
23066
24393
|
function isRetryableStatus(status) {
|
|
23067
24394
|
return status === 408 || status === 425 || status === 429 || status >= 500;
|
|
@@ -23158,14 +24485,26 @@ function createApiClient({
|
|
|
23158
24485
|
return { kind: "acked", ack: activityLeaseAckSchema.parse(jsonBody(response)) };
|
|
23159
24486
|
},
|
|
23160
24487
|
fetchDesired: async (signal) => {
|
|
23161
|
-
const response = await request(
|
|
24488
|
+
const response = await request(
|
|
24489
|
+
DESIRED_STATE_PATH,
|
|
24490
|
+
{
|
|
24491
|
+
method: "GET",
|
|
24492
|
+
headers: {
|
|
24493
|
+
[RUNTIME_FEATURE_HEADER]: CENTRAL_SESSION_FEATURES.join(",")
|
|
24494
|
+
}
|
|
24495
|
+
},
|
|
24496
|
+
signal
|
|
24497
|
+
);
|
|
23162
24498
|
if (!isOk(response)) {
|
|
23163
24499
|
throw new RuntimeFault("io_failed", `Desired state request failed: ${response.status}`);
|
|
23164
24500
|
}
|
|
23165
24501
|
return desiredStateSchema.parse(jsonBody(response));
|
|
23166
24502
|
},
|
|
23167
24503
|
fetchDesiredIfChanged: async (etag, signal) => {
|
|
23168
|
-
const headers =
|
|
24504
|
+
const headers = {
|
|
24505
|
+
[RUNTIME_FEATURE_HEADER]: CENTRAL_SESSION_FEATURES.join(","),
|
|
24506
|
+
...etag === null ? {} : { "if-none-match": etag }
|
|
24507
|
+
};
|
|
23169
24508
|
const response = await request(DESIRED_STATE_PATH, { method: "GET", headers }, signal);
|
|
23170
24509
|
if (response.status === 304) return { kind: "unchanged" };
|
|
23171
24510
|
if (!isOk(response)) {
|
|
@@ -23195,7 +24534,7 @@ function createApiClient({
|
|
|
23195
24534
|
headers: {
|
|
23196
24535
|
...uploadHeaders(target, offset),
|
|
23197
24536
|
"content-type": "application/octet-stream",
|
|
23198
|
-
[RUN_LOG_UPLOAD_HEADERS.sha256]: (0,
|
|
24537
|
+
[RUN_LOG_UPLOAD_HEADERS.sha256]: (0, import_node_crypto.createHash)("sha256").update(bytes).digest("hex")
|
|
23199
24538
|
},
|
|
23200
24539
|
body: bytes
|
|
23201
24540
|
},
|
|
@@ -23222,106 +24561,20 @@ function createApiClient({
|
|
|
23222
24561
|
};
|
|
23223
24562
|
}
|
|
23224
24563
|
|
|
23225
|
-
// src/
|
|
23226
|
-
|
|
23227
|
-
|
|
23228
|
-
var import_node_util = require("util");
|
|
23229
|
-
var execFileAsync = (0, import_node_util.promisify)(import_node_child_process.execFile);
|
|
23230
|
-
function isProcessAlive(pid) {
|
|
23231
|
-
try {
|
|
23232
|
-
process.kill(pid, 0);
|
|
23233
|
-
return true;
|
|
23234
|
-
} catch (error62) {
|
|
23235
|
-
return errnoCode(error62) === "EPERM";
|
|
23236
|
-
}
|
|
23237
|
-
}
|
|
23238
|
-
|
|
23239
|
-
// src/platform/vm-stats.ts
|
|
23240
|
-
var import_promises5 = require("fs/promises");
|
|
23241
|
-
var CLOCK_TICKS_PER_SECOND = 100;
|
|
23242
|
-
function fieldOf(text, name) {
|
|
23243
|
-
const match = new RegExp(`^${name}[:\\s]+(\\d+)`, "m").exec(text);
|
|
23244
|
-
return match?.[1] === void 0 ? null : Number(match[1]);
|
|
23245
|
-
}
|
|
23246
|
-
function parseVmCounters(meminfo, vmstat, loadavg) {
|
|
23247
|
-
const availableKb = fieldOf(meminfo, "MemAvailable");
|
|
23248
|
-
const totalKb = fieldOf(meminfo, "MemTotal");
|
|
23249
|
-
const load = Number(loadavg.trim().split(/\s+/)[0]);
|
|
23250
|
-
if (availableKb === null || totalKb === null || totalKb <= 0 || !Number.isFinite(load)) {
|
|
23251
|
-
return null;
|
|
23252
|
-
}
|
|
23253
|
-
return {
|
|
23254
|
-
memAvailableBytes: availableKb * 1024,
|
|
23255
|
-
memTotalBytes: totalKb * 1024,
|
|
23256
|
-
pgscanDirect: fieldOf(vmstat, "pgscan_direct") ?? 0,
|
|
23257
|
-
workingsetRefaultFile: fieldOf(vmstat, "workingset_refault_file") ?? fieldOf(vmstat, "workingset_refault") ?? 0,
|
|
23258
|
-
loadAverage1m: Math.max(0, load)
|
|
23259
|
-
};
|
|
23260
|
-
}
|
|
23261
|
-
async function readVmCounters(platform = process.platform) {
|
|
23262
|
-
if (platform !== "linux") return null;
|
|
23263
|
-
try {
|
|
23264
|
-
const [meminfo, vmstat, loadavg] = await Promise.all([
|
|
23265
|
-
(0, import_promises5.readFile)("/proc/meminfo", "utf8"),
|
|
23266
|
-
(0, import_promises5.readFile)("/proc/vmstat", "utf8"),
|
|
23267
|
-
(0, import_promises5.readFile)("/proc/loadavg", "utf8")
|
|
23268
|
-
]);
|
|
23269
|
-
return parseVmCounters(meminfo, vmstat, loadavg);
|
|
23270
|
-
} catch {
|
|
23271
|
-
return null;
|
|
23272
|
-
}
|
|
23273
|
-
}
|
|
23274
|
-
function parseProcStat(stat4) {
|
|
23275
|
-
const fields = stat4.slice(stat4.lastIndexOf(")") + 2).split(" ");
|
|
23276
|
-
const ppid = Number(fields[1]);
|
|
23277
|
-
const utime = Number(fields[11]);
|
|
23278
|
-
const stime = Number(fields[12]);
|
|
23279
|
-
if (![ppid, utime, stime].every(Number.isFinite)) return null;
|
|
23280
|
-
return { ppid, cpuMs: (utime + stime) * 1e3 / CLOCK_TICKS_PER_SECOND };
|
|
23281
|
-
}
|
|
23282
|
-
async function readProcessCpuTable(platform = process.platform) {
|
|
23283
|
-
const table = /* @__PURE__ */ new Map();
|
|
23284
|
-
if (platform !== "linux") return table;
|
|
23285
|
-
const entries = await (0, import_promises5.readdir)("/proc").catch(() => []);
|
|
23286
|
-
await Promise.all(
|
|
23287
|
-
entries.filter((entry) => /^\d+$/.test(entry)).map(async (entry) => {
|
|
23288
|
-
const stat4 = await (0, import_promises5.readFile)(`/proc/${entry}/stat`, "utf8").catch(() => null);
|
|
23289
|
-
const row = stat4 === null ? null : parseProcStat(stat4);
|
|
23290
|
-
if (row !== null) table.set(Number(entry), row);
|
|
23291
|
-
})
|
|
23292
|
-
);
|
|
23293
|
-
return table;
|
|
23294
|
-
}
|
|
23295
|
-
function processTreeCpuMs(table, pid) {
|
|
23296
|
-
if (!table.has(pid)) return null;
|
|
23297
|
-
const children = /* @__PURE__ */ new Map();
|
|
23298
|
-
for (const [child, row] of table) {
|
|
23299
|
-
const siblings = children.get(row.ppid) ?? [];
|
|
23300
|
-
siblings.push(child);
|
|
23301
|
-
children.set(row.ppid, siblings);
|
|
23302
|
-
}
|
|
23303
|
-
let total = 0;
|
|
23304
|
-
const seen = /* @__PURE__ */ new Set();
|
|
23305
|
-
const queue = [pid];
|
|
23306
|
-
for (const next of queue) {
|
|
23307
|
-
if (seen.has(next)) continue;
|
|
23308
|
-
seen.add(next);
|
|
23309
|
-
total += table.get(next)?.cpuMs ?? 0;
|
|
23310
|
-
queue.push(...children.get(next) ?? []);
|
|
23311
|
-
}
|
|
23312
|
-
return Math.round(total);
|
|
23313
|
-
}
|
|
24564
|
+
// src/cli/commands/activity-lease-worker.ts
|
|
24565
|
+
init_kernel();
|
|
24566
|
+
init_platform();
|
|
23314
24567
|
|
|
23315
24568
|
// src/cli/commands/activity-lease-producer.ts
|
|
23316
|
-
var
|
|
23317
|
-
var
|
|
24569
|
+
var import_promises4 = require("node:fs/promises");
|
|
24570
|
+
var import_node_path4 = require("node:path");
|
|
23318
24571
|
init_runtime_v2();
|
|
23319
24572
|
|
|
23320
24573
|
// src/holder/activity-file.ts
|
|
23321
|
-
var
|
|
23322
|
-
var import_node_path3 = require("path");
|
|
24574
|
+
var import_node_path2 = require("node:path");
|
|
23323
24575
|
init_runtime_v2();
|
|
23324
24576
|
init_zod();
|
|
24577
|
+
init_kernel();
|
|
23325
24578
|
var ACTIVITY_FILE = "activity.json";
|
|
23326
24579
|
var sessionActivitySchema = external_exports.object({
|
|
23327
24580
|
runId: runIdSchema.nullable(),
|
|
@@ -23330,7 +24583,7 @@ var sessionActivitySchema = external_exports.object({
|
|
|
23330
24583
|
backgroundTasks: external_exports.number().int().nonnegative()
|
|
23331
24584
|
});
|
|
23332
24585
|
function sessionActivityPath(sessionDir) {
|
|
23333
|
-
return (0,
|
|
24586
|
+
return (0, import_node_path2.join)(sessionDir, ACTIVITY_FILE);
|
|
23334
24587
|
}
|
|
23335
24588
|
async function readSessionActivity(path) {
|
|
23336
24589
|
const read = await readJsonFile(path, sessionActivitySchema).catch(() => null);
|
|
@@ -23338,8 +24591,7 @@ async function readSessionActivity(path) {
|
|
|
23338
24591
|
}
|
|
23339
24592
|
|
|
23340
24593
|
// src/run-log/directory.ts
|
|
23341
|
-
var
|
|
23342
|
-
var import_node_path4 = require("path");
|
|
24594
|
+
var import_node_path3 = require("node:path");
|
|
23343
24595
|
init_runtime_v2();
|
|
23344
24596
|
init_zod();
|
|
23345
24597
|
var runMetaSchema = external_exports.object({
|
|
@@ -23361,16 +24613,17 @@ var runMetaSchema = external_exports.object({
|
|
|
23361
24613
|
}).optional()
|
|
23362
24614
|
});
|
|
23363
24615
|
function runDirectory(runsDir, runId) {
|
|
23364
|
-
const dir = (0,
|
|
24616
|
+
const dir = (0, import_node_path3.join)(runsDir, runId);
|
|
23365
24617
|
return {
|
|
23366
24618
|
dir,
|
|
23367
|
-
log: (0,
|
|
23368
|
-
upload: (0,
|
|
23369
|
-
meta: (0,
|
|
24619
|
+
log: (0, import_node_path3.join)(dir, "log.jsonl"),
|
|
24620
|
+
upload: (0, import_node_path3.join)(dir, "upload.json"),
|
|
24621
|
+
meta: (0, import_node_path3.join)(dir, "run.json")
|
|
23370
24622
|
};
|
|
23371
24623
|
}
|
|
23372
24624
|
|
|
23373
24625
|
// src/cli/commands/activity-lease-producer.ts
|
|
24626
|
+
init_platform();
|
|
23374
24627
|
function snapshotKey(snapshot) {
|
|
23375
24628
|
const runs = snapshot.runs.map((run) => `${run.runId}:${run.state}`).sort();
|
|
23376
24629
|
return `${runs.join(",")}|${[...snapshot.busyRunIds].sort().join(",")}`;
|
|
@@ -23379,16 +24632,16 @@ function delta(current, previous) {
|
|
|
23379
24632
|
return previous === void 0 ? 0 : Math.max(0, Math.round(current - previous));
|
|
23380
24633
|
}
|
|
23381
24634
|
async function lastOutputAtMs(runsDir, run) {
|
|
23382
|
-
const info = await (0,
|
|
24635
|
+
const info = await (0, import_promises4.stat)(runDirectory(runsDir, run.runId).log).catch(() => null);
|
|
23383
24636
|
return info === null ? null : Math.floor(info.mtimeMs);
|
|
23384
24637
|
}
|
|
23385
24638
|
async function readHolderActivities(sessionsDir) {
|
|
23386
|
-
const names = await (0,
|
|
24639
|
+
const names = await (0, import_promises4.readdir)(sessionsDir).catch(() => []);
|
|
23387
24640
|
const found = [];
|
|
23388
24641
|
for (const name of names) {
|
|
23389
24642
|
const parsed = conversationIdSchema.safeParse(name);
|
|
23390
24643
|
if (!parsed.success) continue;
|
|
23391
|
-
const activity = await readSessionActivity(sessionActivityPath((0,
|
|
24644
|
+
const activity = await readSessionActivity(sessionActivityPath((0, import_node_path4.join)(sessionsDir, name)));
|
|
23392
24645
|
if (activity !== null) found.push({ conversationId: parsed.data, activity });
|
|
23393
24646
|
}
|
|
23394
24647
|
return found;
|
|
@@ -23581,7 +24834,7 @@ var SIGKILL_AFTER_MS = 5e3;
|
|
|
23581
24834
|
var STDERR_FD = 2;
|
|
23582
24835
|
async function endBlockedRuntime(lagMs, thresholdMs, clock, log) {
|
|
23583
24836
|
log.error("runtime.event_loop_blocked", { lagMs, thresholdMs, exitStatus: WATCHDOG_EXIT_STATUS });
|
|
23584
|
-
(0,
|
|
24837
|
+
(0, import_node_fs2.writeSync)(
|
|
23585
24838
|
STDERR_FD,
|
|
23586
24839
|
`alan-agent: main event loop blocked for ${lagMs} ms (limit ${thresholdMs} ms); exiting for a restart
|
|
23587
24840
|
`
|