@botiverse/raft-daemon 0.72.4 → 0.72.7-play.20260711140930
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-TPDIIRNC.js → chunk-FD5UWGOT.js} +1628 -600
- package/dist/cli/index.js +186 -38
- package/dist/core.js +11 -1
- package/dist/{dist-VNC64ECP.js → dist-6QZ4QRGY.js} +182 -38
- package/dist/index.js +1 -1
- package/package.json +3 -1
|
@@ -2,8 +2,11 @@
|
|
|
2
2
|
import path23 from "path";
|
|
3
3
|
import os8 from "os";
|
|
4
4
|
import { createRequire as createRequire3 } from "module";
|
|
5
|
-
import { accessSync } from "fs";
|
|
5
|
+
import { accessSync, createReadStream as createReadStream4, createWriteStream as createWriteStream2 } from "fs";
|
|
6
|
+
import { mkdtemp, rm as rm4, stat as stat4 } from "fs/promises";
|
|
6
7
|
import { fileURLToPath } from "url";
|
|
8
|
+
import { Readable as Readable3 } from "stream";
|
|
9
|
+
import { pipeline as pipeline2 } from "stream/promises";
|
|
7
10
|
|
|
8
11
|
// ../shared/src/typeGuards.ts
|
|
9
12
|
function makeIsMember(members) {
|
|
@@ -1362,6 +1365,7 @@ var PROMOTED_IDENTITY_ATTRS = [
|
|
|
1362
1365
|
"launch_id",
|
|
1363
1366
|
"session_id",
|
|
1364
1367
|
"request_id",
|
|
1368
|
+
"operation_id",
|
|
1365
1369
|
"route_pattern",
|
|
1366
1370
|
"caller_kind"
|
|
1367
1371
|
];
|
|
@@ -1448,6 +1452,7 @@ var TRACE_B0_FIELD_DEFINITIONS = defineTraceFields([
|
|
|
1448
1452
|
{ key: "advances_observed_clock", fieldClass: "query_axis", placement: "span_or_event", valueKind: "closed_enum", enumBinding: "pending_457" },
|
|
1449
1453
|
{ key: "duration_ms", fieldClass: "query_axis", placement: "span_or_event", valueKind: "numeric" },
|
|
1450
1454
|
{ key: "request_id", fieldClass: "query_axis", placement: "span", valueKind: "identity", highCardinality: true },
|
|
1455
|
+
{ key: "operation_id", fieldClass: "query_axis", placement: "span_or_event", valueKind: "identity", highCardinality: true },
|
|
1451
1456
|
{ key: "route_pattern", fieldClass: "query_axis", placement: "span", valueKind: "route" },
|
|
1452
1457
|
{ key: "caller_kind", fieldClass: "query_axis", placement: "span", valueKind: "closed_enum", enumBinding: "stable" },
|
|
1453
1458
|
{ key: "server_id", fieldClass: "query_axis", placement: "span", valueKind: "identity", highCardinality: true },
|
|
@@ -1472,10 +1477,14 @@ var TRACE_B0_FIELD_DEFINITIONS = defineTraceFields([
|
|
|
1472
1477
|
{ key: "phase", fieldClass: "query_axis", placement: "span_or_event", valueKind: "closed_enum", enumBinding: "pending_457" },
|
|
1473
1478
|
{ key: "eligibility_subcheck", fieldClass: "query_axis", placement: "event", valueKind: "closed_enum", enumBinding: "pending_457" },
|
|
1474
1479
|
{ key: "hint_source", fieldClass: "family_query_axis", placement: "event", valueKind: "closed_enum", scope: "family:activity" },
|
|
1480
|
+
{ key: "candidate_activity", fieldClass: "family_query_axis", placement: "span_or_event", valueKind: "closed_enum", scope: "family:activity" },
|
|
1481
|
+
{ key: "served_activity", fieldClass: "family_query_axis", placement: "span_or_event", valueKind: "closed_enum", scope: "family:activity" },
|
|
1482
|
+
{ key: "write_action", fieldClass: "family_query_axis", placement: "event", valueKind: "closed_enum", scope: "family:activity", enumBinding: "stable", enumValues: ["none"] },
|
|
1483
|
+
{ key: "arbitration_reason", fieldClass: "family_query_axis", placement: "event", valueKind: "closed_enum", scope: "family:activity", enumBinding: "stable", enumValues: ["trusted_snapshot", "owner_mirror_read_through"] },
|
|
1475
1484
|
{ key: "weak_source", fieldClass: "family_query_axis", placement: "event", valueKind: "closed_enum", scope: "family:activity" },
|
|
1476
1485
|
{ key: "competing_fact", fieldClass: "family_query_axis", placement: "event", valueKind: "closed_enum", scope: "family:activity" },
|
|
1477
1486
|
{ key: "resolved_activity", fieldClass: "family_query_axis", placement: "event", valueKind: "closed_enum", scope: "family:activity" },
|
|
1478
|
-
{ key: "previous_activity", fieldClass: "family_query_axis", placement: "
|
|
1487
|
+
{ key: "previous_activity", fieldClass: "family_query_axis", placement: "span_or_event", valueKind: "closed_enum", scope: "family:activity" },
|
|
1479
1488
|
{ key: "next_activity", fieldClass: "family_query_axis", placement: "event", valueKind: "closed_enum", scope: "family:activity" },
|
|
1480
1489
|
{ key: "repair_kind", fieldClass: "family_query_axis", placement: "event", valueKind: "closed_enum", scope: "family:activity" },
|
|
1481
1490
|
{ key: "activity_write_site", fieldClass: "family_query_axis", placement: "event", valueKind: "closed_enum", scope: "family:activity" },
|
|
@@ -2008,8 +2017,90 @@ var actionCardActionSchema = z.discriminatedUnion("type", [
|
|
|
2008
2017
|
integrationUpdateAppRegistrationOperationSchema
|
|
2009
2018
|
]);
|
|
2010
2019
|
|
|
2011
|
-
// ../shared/src/
|
|
2020
|
+
// ../shared/src/featureFlagRolloutGuardrail.ts
|
|
2012
2021
|
import { z as z2 } from "zod";
|
|
2022
|
+
var FEATURE_FLAG_ROLLOUT_GUARDRAIL_SCHEMA = "feature_flag_rollout_guardrail.v1";
|
|
2023
|
+
var FEATURE_FLAG_ROLLOUT_GUARDRAIL_ISSUER = "feature-flag-guardrail";
|
|
2024
|
+
var FEATURE_FLAG_ROLLOUT_GUARDRAIL_POLICY_VERSION = "v1";
|
|
2025
|
+
var FEATURE_FLAG_ROLLOUT_GUARDRAIL_MAX_RECEIPT_AGE_MS = 5 * 60 * 1e3;
|
|
2026
|
+
var FLAG_KEY_RE = /^[a-z0-9][a-z0-9_.-]{0,127}$/;
|
|
2027
|
+
var CONTROL_PLANE_ID_RE = /^[a-z0-9][a-z0-9_.:-]{0,127}$/;
|
|
2028
|
+
var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
|
|
2029
|
+
var flagKeySchema = z2.string().regex(FLAG_KEY_RE);
|
|
2030
|
+
var controlPlaneIdSchema = z2.string().regex(CONTROL_PLANE_ID_RE);
|
|
2031
|
+
var uuidSchema2 = z2.string().regex(UUID_RE);
|
|
2032
|
+
var configVersionSchema = z2.number().refine(Number.isSafeInteger).refine((value) => value >= 0);
|
|
2033
|
+
var basisPointsSchema = z2.number().int().min(0).max(1e4);
|
|
2034
|
+
var ruleSchema = z2.object({
|
|
2035
|
+
id: uuidSchema2,
|
|
2036
|
+
flagKey: flagKeySchema.optional(),
|
|
2037
|
+
stage: z2.enum(["user", "server", "plan", "percentage"]),
|
|
2038
|
+
priority: z2.number().int(),
|
|
2039
|
+
decision: z2.enum(["allow", "deny"]),
|
|
2040
|
+
values: z2.array(z2.string().min(1)).refine((values) => new Set(values).size === values.length),
|
|
2041
|
+
percentageBasisPoints: basisPointsSchema.nullable(),
|
|
2042
|
+
variant: z2.string().min(1).nullable()
|
|
2043
|
+
});
|
|
2044
|
+
var baseStateSchema = z2.strictObject({
|
|
2045
|
+
controlPlaneId: controlPlaneIdSchema,
|
|
2046
|
+
flagKey: flagKeySchema,
|
|
2047
|
+
configVersion: configVersionSchema,
|
|
2048
|
+
killSwitch: z2.boolean(),
|
|
2049
|
+
// Rules are parsed only when the requested operation depends on them. This
|
|
2050
|
+
// keeps emergency kill available even if unrelated rule payloads are bad.
|
|
2051
|
+
rules: z2.unknown().optional()
|
|
2052
|
+
});
|
|
2053
|
+
var intentSchema = z2.discriminatedUnion("kind", [
|
|
2054
|
+
z2.strictObject({
|
|
2055
|
+
kind: z2.literal("server_allowlist_set"),
|
|
2056
|
+
flagKey: flagKeySchema,
|
|
2057
|
+
expectedConfigVersion: configVersionSchema.optional(),
|
|
2058
|
+
serverId: uuidSchema2,
|
|
2059
|
+
desired: z2.enum(["present", "absent"])
|
|
2060
|
+
}),
|
|
2061
|
+
z2.strictObject({
|
|
2062
|
+
kind: z2.literal("percentage_set"),
|
|
2063
|
+
flagKey: flagKeySchema,
|
|
2064
|
+
expectedConfigVersion: configVersionSchema.optional(),
|
|
2065
|
+
desiredBasisPoints: basisPointsSchema
|
|
2066
|
+
}),
|
|
2067
|
+
z2.strictObject({
|
|
2068
|
+
kind: z2.literal("kill_switch_set"),
|
|
2069
|
+
flagKey: flagKeySchema,
|
|
2070
|
+
expectedConfigVersion: configVersionSchema.optional(),
|
|
2071
|
+
desired: z2.boolean()
|
|
2072
|
+
})
|
|
2073
|
+
]);
|
|
2074
|
+
var wideningOperationSchema = z2.discriminatedUnion("kind", [
|
|
2075
|
+
z2.strictObject({
|
|
2076
|
+
kind: z2.literal("server_allowlist_add"),
|
|
2077
|
+
ruleId: uuidSchema2.nullable(),
|
|
2078
|
+
serverId: uuidSchema2
|
|
2079
|
+
}),
|
|
2080
|
+
z2.strictObject({
|
|
2081
|
+
kind: z2.literal("percentage_increase"),
|
|
2082
|
+
ruleId: uuidSchema2.nullable(),
|
|
2083
|
+
fromBasisPoints: basisPointsSchema,
|
|
2084
|
+
toBasisPoints: basisPointsSchema
|
|
2085
|
+
}).refine((operation) => operation.toBasisPoints > operation.fromBasisPoints),
|
|
2086
|
+
z2.strictObject({ kind: z2.literal("kill_switch_disable") })
|
|
2087
|
+
]);
|
|
2088
|
+
var receiptSchema = z2.strictObject({
|
|
2089
|
+
schema: z2.literal(FEATURE_FLAG_ROLLOUT_GUARDRAIL_SCHEMA),
|
|
2090
|
+
id: uuidSchema2,
|
|
2091
|
+
verdict: z2.enum(["pass", "fail"]),
|
|
2092
|
+
issuer: z2.literal(FEATURE_FLAG_ROLLOUT_GUARDRAIL_ISSUER),
|
|
2093
|
+
controlPlaneId: controlPlaneIdSchema,
|
|
2094
|
+
flagKey: flagKeySchema,
|
|
2095
|
+
configVersion: configVersionSchema,
|
|
2096
|
+
operation: wideningOperationSchema,
|
|
2097
|
+
policyVersion: z2.literal(FEATURE_FLAG_ROLLOUT_GUARDRAIL_POLICY_VERSION),
|
|
2098
|
+
evaluatedAt: z2.string(),
|
|
2099
|
+
expiresAt: z2.string()
|
|
2100
|
+
});
|
|
2101
|
+
|
|
2102
|
+
// ../shared/src/agentApiContract.ts
|
|
2103
|
+
import { z as z3 } from "zod";
|
|
2013
2104
|
|
|
2014
2105
|
// ../shared/src/attentionDependencyOracle.ts
|
|
2015
2106
|
var ATTENTION_HINT_SCHEMA = "attention-dependency-hint.v1";
|
|
@@ -2017,78 +2108,78 @@ var ATTENTION_HINT_DEFAULT_WINDOW_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
|
2017
2108
|
|
|
2018
2109
|
// ../shared/src/agentApiContract.ts
|
|
2019
2110
|
var AGENT_API_BASE_PATH = "/internal/agent-api";
|
|
2020
|
-
var optionalStringSchema =
|
|
2021
|
-
var optionalStringArraySchema =
|
|
2022
|
-
var optionalBooleanSchema =
|
|
2023
|
-
var optionalNumberSchema =
|
|
2024
|
-
var nullableStringSchema =
|
|
2025
|
-
var nullableNumberSchema =
|
|
2026
|
-
var optionalIsoTimestampSchema =
|
|
2027
|
-
var agentStatusSchema =
|
|
2028
|
-
var reminderStatusSchema =
|
|
2029
|
-
var reminderEventTypeSchema =
|
|
2030
|
-
var reasoningEffortSchema =
|
|
2031
|
-
var profileVisibilityMembershipStatusSchema =
|
|
2032
|
-
var passthroughObject = (shape) =>
|
|
2033
|
-
var taskStatusSchema =
|
|
2111
|
+
var optionalStringSchema = z3.string().trim().optional();
|
|
2112
|
+
var optionalStringArraySchema = z3.array(z3.string().trim().min(1)).optional();
|
|
2113
|
+
var optionalBooleanSchema = z3.boolean().optional();
|
|
2114
|
+
var optionalNumberSchema = z3.number().finite().optional();
|
|
2115
|
+
var nullableStringSchema = z3.string().nullable();
|
|
2116
|
+
var nullableNumberSchema = z3.number().finite().nullable();
|
|
2117
|
+
var optionalIsoTimestampSchema = z3.string().datetime().optional();
|
|
2118
|
+
var agentStatusSchema = z3.enum(["active", "inactive", "stopped"]);
|
|
2119
|
+
var reminderStatusSchema = z3.enum(["scheduled", "fired", "canceled"]);
|
|
2120
|
+
var reminderEventTypeSchema = z3.enum(["scheduled", "fired", "snoozed", "updated", "canceled"]);
|
|
2121
|
+
var reasoningEffortSchema = z3.enum(["low", "medium", "high", "xhigh", "max", "ultra"]);
|
|
2122
|
+
var profileVisibilityMembershipStatusSchema = z3.enum(["active", "left", "removed"]);
|
|
2123
|
+
var passthroughObject = (shape) => z3.object(shape).passthrough();
|
|
2124
|
+
var taskStatusSchema = z3.enum(["todo", "in_progress", "in_review", "done", "closed"]);
|
|
2034
2125
|
var agentApiEventsQuerySchema = passthroughObject({
|
|
2035
2126
|
since: optionalStringSchema,
|
|
2036
2127
|
limit: optionalStringSchema
|
|
2037
2128
|
});
|
|
2038
2129
|
var agentApiHistoryQuerySchema = passthroughObject({
|
|
2039
|
-
channel:
|
|
2130
|
+
channel: z3.string().trim().min(1),
|
|
2040
2131
|
before: optionalStringSchema,
|
|
2041
2132
|
after: optionalStringSchema,
|
|
2042
2133
|
around: optionalStringSchema,
|
|
2043
2134
|
limit: optionalStringSchema
|
|
2044
2135
|
});
|
|
2045
2136
|
var agentApiKnowledgeGetQuerySchema = passthroughObject({
|
|
2046
|
-
topic:
|
|
2137
|
+
topic: z3.string().trim().min(1),
|
|
2047
2138
|
reason: optionalStringSchema,
|
|
2048
2139
|
turn_id: optionalStringSchema,
|
|
2049
2140
|
trace_id: optionalStringSchema
|
|
2050
2141
|
});
|
|
2051
2142
|
var agentApiKnowledgeGetResponseSchema = passthroughObject({
|
|
2052
|
-
ok:
|
|
2053
|
-
docId:
|
|
2054
|
-
topicOrPath:
|
|
2055
|
-
docVersion:
|
|
2056
|
-
docState:
|
|
2057
|
-
contentType:
|
|
2058
|
-
content:
|
|
2143
|
+
ok: z3.literal(true),
|
|
2144
|
+
docId: z3.string(),
|
|
2145
|
+
topicOrPath: z3.string(),
|
|
2146
|
+
docVersion: z3.string(),
|
|
2147
|
+
docState: z3.string(),
|
|
2148
|
+
contentType: z3.string(),
|
|
2149
|
+
content: z3.string()
|
|
2059
2150
|
});
|
|
2060
2151
|
var agentApiKnowledgeSearchQuerySchema = passthroughObject({
|
|
2061
|
-
query:
|
|
2152
|
+
query: z3.string().trim().min(1),
|
|
2062
2153
|
scope: optionalStringSchema,
|
|
2063
2154
|
reason: optionalStringSchema,
|
|
2064
2155
|
turn_id: optionalStringSchema,
|
|
2065
2156
|
trace_id: optionalStringSchema
|
|
2066
2157
|
});
|
|
2067
2158
|
var agentApiKnowledgeSearchResultSchema = passthroughObject({
|
|
2068
|
-
slug:
|
|
2069
|
-
title:
|
|
2070
|
-
firstScreen:
|
|
2159
|
+
slug: z3.string(),
|
|
2160
|
+
title: z3.string(),
|
|
2161
|
+
firstScreen: z3.string()
|
|
2071
2162
|
});
|
|
2072
2163
|
var agentApiKnowledgeSearchResponseSchema = passthroughObject({
|
|
2073
|
-
ok:
|
|
2074
|
-
query:
|
|
2075
|
-
scope:
|
|
2076
|
-
results:
|
|
2164
|
+
ok: z3.literal(true),
|
|
2165
|
+
query: z3.string(),
|
|
2166
|
+
scope: z3.string().nullable(),
|
|
2167
|
+
results: z3.array(agentApiKnowledgeSearchResultSchema)
|
|
2077
2168
|
});
|
|
2078
2169
|
var agentApiMessageSearchQuerySchema = passthroughObject({
|
|
2079
2170
|
q: optionalStringSchema,
|
|
2080
2171
|
channel: optionalStringSchema,
|
|
2081
2172
|
sender: optionalStringSchema,
|
|
2082
2173
|
senderId: optionalStringSchema,
|
|
2083
|
-
sort:
|
|
2174
|
+
sort: z3.enum(["relevance", "recent"]).optional(),
|
|
2084
2175
|
before: optionalStringSchema,
|
|
2085
2176
|
after: optionalStringSchema,
|
|
2086
2177
|
limit: optionalStringSchema,
|
|
2087
2178
|
offset: optionalStringSchema
|
|
2088
2179
|
});
|
|
2089
2180
|
var agentApiSendBodySchema = passthroughObject({
|
|
2090
|
-
target:
|
|
2091
|
-
content:
|
|
2181
|
+
target: z3.string().optional(),
|
|
2182
|
+
content: z3.string().optional(),
|
|
2092
2183
|
attachmentIds: optionalStringArraySchema,
|
|
2093
2184
|
idempotencyKey: optionalStringSchema,
|
|
2094
2185
|
continue: optionalBooleanSchema,
|
|
@@ -2098,107 +2189,111 @@ var agentApiSendBodySchema = passthroughObject({
|
|
|
2098
2189
|
draftReplacedExisting: optionalBooleanSchema,
|
|
2099
2190
|
seenUpToSeq: optionalNumberSchema
|
|
2100
2191
|
});
|
|
2192
|
+
var legacyAgentSendBodySchema = agentApiSendBodySchema.extend({
|
|
2193
|
+
channel: z3.string().optional(),
|
|
2194
|
+
dm_to: z3.string().optional()
|
|
2195
|
+
});
|
|
2101
2196
|
var agentApiMessageResolveParamsSchema = passthroughObject({
|
|
2102
|
-
msgId:
|
|
2197
|
+
msgId: z3.string().trim().min(1).transform(asMessageId)
|
|
2103
2198
|
});
|
|
2104
2199
|
var agentApiMessageReactionParamsSchema = passthroughObject({
|
|
2105
|
-
msgId:
|
|
2200
|
+
msgId: z3.string().trim().min(1).transform(asMessageId)
|
|
2106
2201
|
});
|
|
2107
2202
|
var agentApiMessageReactionBodySchema = passthroughObject({
|
|
2108
|
-
emoji:
|
|
2203
|
+
emoji: z3.string().trim().min(1).max(16).refine((value) => !/\s/.test(value), {
|
|
2109
2204
|
message: "A single reaction emoji is required"
|
|
2110
2205
|
})
|
|
2111
2206
|
});
|
|
2112
2207
|
var agentApiChannelMembershipParamsSchema = passthroughObject({
|
|
2113
|
-
channelId:
|
|
2208
|
+
channelId: z3.string().trim().min(1).transform(asChannelId)
|
|
2114
2209
|
});
|
|
2115
2210
|
var agentApiAttachmentDownloadParamsSchema = passthroughObject({
|
|
2116
|
-
attachmentId:
|
|
2211
|
+
attachmentId: z3.string().trim().min(1)
|
|
2117
2212
|
});
|
|
2118
2213
|
var agentApiAttachmentCommentsParamsSchema = passthroughObject({
|
|
2119
|
-
attachmentId:
|
|
2214
|
+
attachmentId: z3.string().trim().min(1)
|
|
2120
2215
|
});
|
|
2121
2216
|
var agentApiAttachmentCommentsQuerySchema = passthroughObject({
|
|
2122
2217
|
limit: optionalStringSchema
|
|
2123
2218
|
});
|
|
2124
2219
|
var agentApiAttachmentCommentAnchorSchema = passthroughObject({
|
|
2125
|
-
type:
|
|
2126
|
-
data:
|
|
2220
|
+
type: z3.string().trim().min(1),
|
|
2221
|
+
data: z3.record(z3.string(), z3.unknown())
|
|
2127
2222
|
});
|
|
2128
2223
|
var agentApiAttachmentCommentReactionSchema = passthroughObject({
|
|
2129
|
-
emoji:
|
|
2130
|
-
reactorType:
|
|
2131
|
-
reactorId:
|
|
2132
|
-
createdAt:
|
|
2224
|
+
emoji: z3.string().trim().min(1),
|
|
2225
|
+
reactorType: z3.string().trim().min(1),
|
|
2226
|
+
reactorId: z3.string().trim().min(1),
|
|
2227
|
+
createdAt: z3.string().datetime()
|
|
2133
2228
|
});
|
|
2134
2229
|
var agentApiAttachmentCommentResolvedBySchema = passthroughObject({
|
|
2135
|
-
reactorId:
|
|
2136
|
-
reactorType:
|
|
2230
|
+
reactorId: z3.string().trim().min(1),
|
|
2231
|
+
reactorType: z3.string().trim().min(1)
|
|
2137
2232
|
});
|
|
2138
2233
|
var agentApiAttachmentCommentSchema = passthroughObject({
|
|
2139
|
-
id:
|
|
2140
|
-
channelId:
|
|
2141
|
-
senderId:
|
|
2142
|
-
senderType:
|
|
2143
|
-
senderName:
|
|
2234
|
+
id: z3.string().trim().min(1),
|
|
2235
|
+
channelId: z3.string().trim().min(1).optional(),
|
|
2236
|
+
senderId: z3.string().trim().min(1),
|
|
2237
|
+
senderType: z3.enum(["user", "agent"]),
|
|
2238
|
+
senderName: z3.string().trim().min(1),
|
|
2144
2239
|
senderAvatarUrl: nullableStringSchema.optional(),
|
|
2145
2240
|
senderGravatarHash: nullableStringSchema.optional(),
|
|
2146
|
-
content:
|
|
2147
|
-
createdAt:
|
|
2148
|
-
reactions:
|
|
2241
|
+
content: z3.string(),
|
|
2242
|
+
createdAt: z3.string().datetime(),
|
|
2243
|
+
reactions: z3.array(agentApiAttachmentCommentReactionSchema),
|
|
2149
2244
|
anchor: agentApiAttachmentCommentAnchorSchema.nullable(),
|
|
2150
|
-
resolved:
|
|
2245
|
+
resolved: z3.boolean().optional(),
|
|
2151
2246
|
resolvedBy: agentApiAttachmentCommentResolvedBySchema.nullable().optional(),
|
|
2152
|
-
resolvedAt:
|
|
2247
|
+
resolvedAt: z3.string().datetime().nullable().optional()
|
|
2153
2248
|
});
|
|
2154
2249
|
var agentApiAttachmentCommentsResponseSchema = passthroughObject({
|
|
2155
|
-
comments:
|
|
2250
|
+
comments: z3.array(agentApiAttachmentCommentSchema),
|
|
2156
2251
|
threadChannelId: nullableStringSchema.optional(),
|
|
2157
2252
|
viewer: passthroughObject({
|
|
2158
|
-
canComment:
|
|
2159
|
-
reason:
|
|
2160
|
-
canResolve:
|
|
2253
|
+
canComment: z3.boolean(),
|
|
2254
|
+
reason: z3.string().optional(),
|
|
2255
|
+
canResolve: z3.boolean(),
|
|
2161
2256
|
resolveAction: passthroughObject({
|
|
2162
|
-
type:
|
|
2163
|
-
emoji:
|
|
2257
|
+
type: z3.string().trim().min(1),
|
|
2258
|
+
emoji: z3.string().trim().min(1)
|
|
2164
2259
|
}).optional()
|
|
2165
2260
|
}).optional()
|
|
2166
2261
|
});
|
|
2167
2262
|
var agentApiChannelMembersQuerySchema = passthroughObject({
|
|
2168
|
-
channel:
|
|
2263
|
+
channel: z3.string().trim().min(1)
|
|
2169
2264
|
});
|
|
2170
2265
|
var agentApiResolveChannelBodySchema = passthroughObject({
|
|
2171
|
-
target:
|
|
2266
|
+
target: z3.string().trim().min(1)
|
|
2172
2267
|
});
|
|
2173
2268
|
var agentApiResolveChannelResponseSchema = passthroughObject({
|
|
2174
|
-
channelId:
|
|
2269
|
+
channelId: z3.string().trim().min(1)
|
|
2175
2270
|
});
|
|
2176
2271
|
var agentApiThreadUnfollowBodySchema = passthroughObject({
|
|
2177
|
-
thread:
|
|
2178
|
-
reason:
|
|
2272
|
+
thread: z3.string().trim().min(1),
|
|
2273
|
+
reason: z3.string().trim().min(1).max(200).optional()
|
|
2179
2274
|
});
|
|
2180
2275
|
var agentApiTaskClaimBodySchema = passthroughObject({
|
|
2181
|
-
channel:
|
|
2182
|
-
task_numbers:
|
|
2276
|
+
channel: z3.string().trim().min(1),
|
|
2277
|
+
task_numbers: z3.array(z3.number().int().positive()).optional(),
|
|
2183
2278
|
message_ids: optionalStringArraySchema
|
|
2184
2279
|
});
|
|
2185
2280
|
var agentApiTaskListQuerySchema = passthroughObject({
|
|
2186
|
-
channel:
|
|
2187
|
-
status:
|
|
2281
|
+
channel: z3.string().trim().min(1),
|
|
2282
|
+
status: z3.union([taskStatusSchema, z3.literal("all")]).optional()
|
|
2188
2283
|
});
|
|
2189
2284
|
var agentApiTaskCreateBodySchema = passthroughObject({
|
|
2190
|
-
channel:
|
|
2191
|
-
tasks:
|
|
2192
|
-
title:
|
|
2285
|
+
channel: z3.string().trim().min(1),
|
|
2286
|
+
tasks: z3.array(passthroughObject({
|
|
2287
|
+
title: z3.string().trim().min(1)
|
|
2193
2288
|
})).min(1)
|
|
2194
2289
|
});
|
|
2195
2290
|
var agentApiTaskUnclaimBodySchema = passthroughObject({
|
|
2196
|
-
channel:
|
|
2197
|
-
task_number:
|
|
2291
|
+
channel: z3.string().trim().min(1),
|
|
2292
|
+
task_number: z3.number().int().positive()
|
|
2198
2293
|
});
|
|
2199
2294
|
var agentApiTaskUpdateStatusBodySchema = passthroughObject({
|
|
2200
|
-
channel:
|
|
2201
|
-
task_number:
|
|
2295
|
+
channel: z3.string().trim().min(1),
|
|
2296
|
+
task_number: z3.number().int().positive(),
|
|
2202
2297
|
status: taskStatusSchema
|
|
2203
2298
|
});
|
|
2204
2299
|
var agentApiReminderListQuerySchema = passthroughObject({
|
|
@@ -2206,20 +2301,20 @@ var agentApiReminderListQuerySchema = passthroughObject({
|
|
|
2206
2301
|
all: optionalStringSchema
|
|
2207
2302
|
});
|
|
2208
2303
|
var agentApiReminderParamsSchema = passthroughObject({
|
|
2209
|
-
reminderId:
|
|
2304
|
+
reminderId: z3.string().trim().min(1)
|
|
2210
2305
|
});
|
|
2211
2306
|
var agentApiReminderScheduleBodySchema = passthroughObject({
|
|
2212
|
-
title:
|
|
2307
|
+
title: z3.string(),
|
|
2213
2308
|
fireAt: optionalStringSchema,
|
|
2214
2309
|
delaySeconds: optionalNumberSchema,
|
|
2215
|
-
msgId:
|
|
2216
|
-
payload:
|
|
2310
|
+
msgId: z3.string().nullable().optional(),
|
|
2311
|
+
payload: z3.unknown().optional(),
|
|
2217
2312
|
repeat: optionalStringSchema,
|
|
2218
2313
|
tz: optionalStringSchema,
|
|
2219
2314
|
channel: optionalStringSchema
|
|
2220
2315
|
});
|
|
2221
2316
|
var agentApiReminderSnoozeBodySchema = passthroughObject({
|
|
2222
|
-
delaySeconds:
|
|
2317
|
+
delaySeconds: z3.number().finite()
|
|
2223
2318
|
});
|
|
2224
2319
|
var agentApiReminderUpdateBodySchema = passthroughObject({
|
|
2225
2320
|
fireAt: optionalStringSchema,
|
|
@@ -2237,58 +2332,58 @@ var agentApiProfileUpdateBodySchema = passthroughObject({
|
|
|
2237
2332
|
description: optionalStringSchema
|
|
2238
2333
|
});
|
|
2239
2334
|
var agentApiProfileCreatedAgentSchema = passthroughObject({
|
|
2240
|
-
id:
|
|
2241
|
-
name:
|
|
2335
|
+
id: z3.string(),
|
|
2336
|
+
name: z3.string(),
|
|
2242
2337
|
displayName: nullableStringSchema,
|
|
2243
2338
|
avatarUrl: nullableStringSchema,
|
|
2244
|
-
runtime:
|
|
2339
|
+
runtime: z3.string(),
|
|
2245
2340
|
status: agentStatusSchema
|
|
2246
2341
|
});
|
|
2247
|
-
var agentApiProfileCreatorSchema =
|
|
2342
|
+
var agentApiProfileCreatorSchema = z3.union([
|
|
2248
2343
|
passthroughObject({
|
|
2249
|
-
type:
|
|
2250
|
-
id:
|
|
2251
|
-
name:
|
|
2344
|
+
type: z3.literal("human"),
|
|
2345
|
+
id: z3.string(),
|
|
2346
|
+
name: z3.string(),
|
|
2252
2347
|
displayName: nullableStringSchema,
|
|
2253
2348
|
avatarUrl: nullableStringSchema,
|
|
2254
|
-
gravatarHash:
|
|
2349
|
+
gravatarHash: z3.string()
|
|
2255
2350
|
}),
|
|
2256
2351
|
passthroughObject({
|
|
2257
|
-
type:
|
|
2258
|
-
id:
|
|
2259
|
-
name:
|
|
2352
|
+
type: z3.literal("agent"),
|
|
2353
|
+
id: z3.string(),
|
|
2354
|
+
name: z3.string(),
|
|
2260
2355
|
displayName: nullableStringSchema,
|
|
2261
2356
|
avatarUrl: nullableStringSchema,
|
|
2262
2357
|
deletedAt: nullableStringSchema
|
|
2263
2358
|
})
|
|
2264
2359
|
]);
|
|
2265
|
-
var agentApiProfileViewSchema =
|
|
2360
|
+
var agentApiProfileViewSchema = z3.discriminatedUnion("kind", [
|
|
2266
2361
|
passthroughObject({
|
|
2267
|
-
kind:
|
|
2268
|
-
id:
|
|
2269
|
-
isSelf:
|
|
2270
|
-
name:
|
|
2362
|
+
kind: z3.literal("human"),
|
|
2363
|
+
id: z3.string(),
|
|
2364
|
+
isSelf: z3.boolean(),
|
|
2365
|
+
name: z3.string(),
|
|
2271
2366
|
displayName: nullableStringSchema,
|
|
2272
2367
|
description: nullableStringSchema,
|
|
2273
2368
|
avatarUrl: nullableStringSchema,
|
|
2274
2369
|
email: nullableStringSchema,
|
|
2275
|
-
role:
|
|
2370
|
+
role: z3.enum(["owner", "admin", "member"]).nullable(),
|
|
2276
2371
|
joinedAt: nullableStringSchema,
|
|
2277
2372
|
membershipStatus: profileVisibilityMembershipStatusSchema,
|
|
2278
|
-
createdAgents:
|
|
2373
|
+
createdAgents: z3.array(agentApiProfileCreatedAgentSchema)
|
|
2279
2374
|
}),
|
|
2280
2375
|
passthroughObject({
|
|
2281
|
-
kind:
|
|
2282
|
-
id:
|
|
2283
|
-
isSelf:
|
|
2284
|
-
name:
|
|
2376
|
+
kind: z3.literal("agent"),
|
|
2377
|
+
id: z3.string(),
|
|
2378
|
+
isSelf: z3.boolean(),
|
|
2379
|
+
name: z3.string(),
|
|
2285
2380
|
displayName: nullableStringSchema,
|
|
2286
2381
|
description: nullableStringSchema,
|
|
2287
2382
|
avatarUrl: nullableStringSchema,
|
|
2288
2383
|
status: agentStatusSchema,
|
|
2289
|
-
serverRole:
|
|
2290
|
-
runtime:
|
|
2291
|
-
model:
|
|
2384
|
+
serverRole: z3.enum(["owner", "admin", "member"]).nullable(),
|
|
2385
|
+
runtime: z3.string(),
|
|
2386
|
+
model: z3.string(),
|
|
2292
2387
|
reasoningEffort: reasoningEffortSchema.nullable(),
|
|
2293
2388
|
executionMode: nullableStringSchema,
|
|
2294
2389
|
computerId: nullableStringSchema,
|
|
@@ -2296,20 +2391,20 @@ var agentApiProfileViewSchema = z2.discriminatedUnion("kind", [
|
|
|
2296
2391
|
computerHostname: nullableStringSchema,
|
|
2297
2392
|
daemonVersion: nullableStringSchema,
|
|
2298
2393
|
creator: agentApiProfileCreatorSchema.nullable(),
|
|
2299
|
-
createdAgents:
|
|
2300
|
-
createdAt:
|
|
2394
|
+
createdAgents: z3.array(agentApiProfileCreatedAgentSchema),
|
|
2395
|
+
createdAt: z3.string(),
|
|
2301
2396
|
deletedAt: nullableStringSchema
|
|
2302
2397
|
})
|
|
2303
2398
|
]);
|
|
2304
2399
|
var agentApiIntegrationLoginBodySchema = passthroughObject({
|
|
2305
|
-
service:
|
|
2400
|
+
service: z3.string().trim().min(1),
|
|
2306
2401
|
scopes: optionalStringArraySchema,
|
|
2307
2402
|
target: optionalStringSchema
|
|
2308
2403
|
});
|
|
2309
2404
|
var agentApiIntegrationAppPrepareBodySchema = passthroughObject({
|
|
2310
|
-
mode:
|
|
2311
|
-
target:
|
|
2312
|
-
clientKey:
|
|
2405
|
+
mode: z3.enum(["register", "update"]),
|
|
2406
|
+
target: z3.string().trim().min(1),
|
|
2407
|
+
clientKey: z3.string().trim().min(1),
|
|
2313
2408
|
name: optionalStringSchema,
|
|
2314
2409
|
description: optionalStringSchema,
|
|
2315
2410
|
homepageUrl: optionalStringSchema,
|
|
@@ -2320,138 +2415,158 @@ var agentApiIntegrationAppPrepareBodySchema = passthroughObject({
|
|
|
2320
2415
|
draftHint: optionalStringSchema
|
|
2321
2416
|
});
|
|
2322
2417
|
var agentApiIntegrationAppRotateSecretBodySchema = passthroughObject({
|
|
2323
|
-
clientKey:
|
|
2418
|
+
clientKey: z3.string().trim().min(1)
|
|
2324
2419
|
});
|
|
2325
2420
|
var agentApiActionPrepareBodySchema = passthroughObject({
|
|
2326
|
-
target:
|
|
2421
|
+
target: z3.string().trim().min(1),
|
|
2327
2422
|
action: actionCardActionSchema
|
|
2328
2423
|
});
|
|
2329
2424
|
var agentApiServerInfoResponseSchema = passthroughObject({
|
|
2330
2425
|
runtimeContext: passthroughObject({
|
|
2331
|
-
agentId:
|
|
2332
|
-
runtime:
|
|
2333
|
-
model:
|
|
2426
|
+
agentId: z3.string(),
|
|
2427
|
+
runtime: z3.string().optional(),
|
|
2428
|
+
model: z3.string().optional(),
|
|
2334
2429
|
reasoningEffort: reasoningEffortSchema.nullable().optional(),
|
|
2335
|
-
serverId:
|
|
2336
|
-
machineId:
|
|
2337
|
-
machineName:
|
|
2338
|
-
machineDescription:
|
|
2339
|
-
machineHostname:
|
|
2340
|
-
machineOs:
|
|
2341
|
-
daemonVersion:
|
|
2342
|
-
workspacePath:
|
|
2430
|
+
serverId: z3.string(),
|
|
2431
|
+
machineId: z3.string().nullable().optional(),
|
|
2432
|
+
machineName: z3.string().nullable().optional(),
|
|
2433
|
+
machineDescription: z3.string().nullable().optional(),
|
|
2434
|
+
machineHostname: z3.string().nullable().optional(),
|
|
2435
|
+
machineOs: z3.string().nullable().optional(),
|
|
2436
|
+
daemonVersion: z3.string().nullable().optional(),
|
|
2437
|
+
workspacePath: z3.string().nullable().optional()
|
|
2343
2438
|
}),
|
|
2344
|
-
serverRole:
|
|
2439
|
+
serverRole: z3.string().nullable().optional(),
|
|
2345
2440
|
serverCapabilities: passthroughObject({}).optional(),
|
|
2346
|
-
channels:
|
|
2347
|
-
id:
|
|
2348
|
-
name:
|
|
2349
|
-
joined:
|
|
2441
|
+
channels: z3.array(passthroughObject({
|
|
2442
|
+
id: z3.string().transform(asChannelId),
|
|
2443
|
+
name: z3.string(),
|
|
2444
|
+
joined: z3.boolean()
|
|
2350
2445
|
})),
|
|
2351
|
-
agents:
|
|
2352
|
-
name:
|
|
2353
|
-
status:
|
|
2354
|
-
activity:
|
|
2355
|
-
activityDetail:
|
|
2356
|
-
role:
|
|
2446
|
+
agents: z3.array(passthroughObject({
|
|
2447
|
+
name: z3.string(),
|
|
2448
|
+
status: z3.string().optional(),
|
|
2449
|
+
activity: z3.string().nullable().optional(),
|
|
2450
|
+
activityDetail: z3.string().nullable().optional(),
|
|
2451
|
+
role: z3.enum(["owner", "admin", "member"]).nullable().optional()
|
|
2357
2452
|
})),
|
|
2358
|
-
humans:
|
|
2359
|
-
name:
|
|
2360
|
-
role:
|
|
2453
|
+
humans: z3.array(passthroughObject({
|
|
2454
|
+
name: z3.string(),
|
|
2455
|
+
role: z3.enum(["owner", "admin", "member"]).nullable().optional()
|
|
2361
2456
|
}))
|
|
2362
2457
|
});
|
|
2363
2458
|
var agentApiMentionActionsPendingQuerySchema = passthroughObject({
|
|
2364
2459
|
limit: optionalStringSchema
|
|
2365
2460
|
});
|
|
2366
2461
|
var agentApiMentionActionEnvelopeSchema = passthroughObject({
|
|
2367
|
-
resolutionId:
|
|
2462
|
+
resolutionId: z3.string()
|
|
2463
|
+
});
|
|
2464
|
+
var agentApiMentionActionResultSchema = passthroughObject({
|
|
2465
|
+
resolutionId: z3.string(),
|
|
2466
|
+
status: z3.enum([
|
|
2467
|
+
"queued",
|
|
2468
|
+
"delivered",
|
|
2469
|
+
"dropped",
|
|
2470
|
+
"stale",
|
|
2471
|
+
"expired",
|
|
2472
|
+
"no_permission",
|
|
2473
|
+
"not_found",
|
|
2474
|
+
"ambiguous"
|
|
2475
|
+
]),
|
|
2476
|
+
action: z3.enum(["notify", "add"]).optional(),
|
|
2477
|
+
reason: optionalStringSchema,
|
|
2478
|
+
messageId: optionalStringSchema,
|
|
2479
|
+
channelId: optionalStringSchema,
|
|
2480
|
+
targetType: z3.enum(["user", "agent"]).optional(),
|
|
2481
|
+
targetId: optionalStringSchema,
|
|
2482
|
+
dedupedResolutionIds: optionalStringArraySchema
|
|
2368
2483
|
});
|
|
2369
2484
|
var agentApiMentionActionsPendingResponseSchema = passthroughObject({
|
|
2370
|
-
pendingMentionActions:
|
|
2371
|
-
has_more:
|
|
2485
|
+
pendingMentionActions: z3.array(agentApiMentionActionEnvelopeSchema),
|
|
2486
|
+
has_more: z3.boolean().optional()
|
|
2372
2487
|
});
|
|
2373
2488
|
var agentApiMentionActionsExecuteBodySchema = passthroughObject({
|
|
2374
|
-
action:
|
|
2489
|
+
action: z3.enum(["notify", "add"]),
|
|
2375
2490
|
resolutionIds: optionalStringArraySchema,
|
|
2376
2491
|
ids: optionalStringArraySchema
|
|
2377
2492
|
});
|
|
2378
2493
|
var agentApiMentionActionsExecuteResponseSchema = passthroughObject({
|
|
2379
|
-
ok:
|
|
2380
|
-
action:
|
|
2381
|
-
results:
|
|
2494
|
+
ok: z3.literal(true),
|
|
2495
|
+
action: z3.enum(["notify", "add"]),
|
|
2496
|
+
results: z3.array(agentApiMentionActionResultSchema)
|
|
2382
2497
|
});
|
|
2383
2498
|
var agentApiIntegrationServiceSchema = passthroughObject({
|
|
2384
|
-
id:
|
|
2385
|
-
clientId:
|
|
2386
|
-
appType:
|
|
2387
|
-
name:
|
|
2499
|
+
id: z3.string(),
|
|
2500
|
+
clientId: z3.string(),
|
|
2501
|
+
appType: z3.enum(["server_local", "slock_builtin", "third_party_global"]).optional(),
|
|
2502
|
+
name: z3.string(),
|
|
2388
2503
|
description: nullableStringSchema,
|
|
2389
2504
|
homepageUrl: nullableStringSchema,
|
|
2390
2505
|
returnUrl: nullableStringSchema,
|
|
2391
2506
|
agentManifestUrl: nullableStringSchema,
|
|
2392
|
-
agentManifestUrlSource:
|
|
2393
|
-
createdAt:
|
|
2394
|
-
updatedAt:
|
|
2507
|
+
agentManifestUrlSource: z3.enum(["explicit", "well_known"]).nullable().optional(),
|
|
2508
|
+
createdAt: z3.string(),
|
|
2509
|
+
updatedAt: z3.string()
|
|
2395
2510
|
});
|
|
2396
2511
|
var agentApiActiveIntegrationLoginSchema = passthroughObject({
|
|
2397
|
-
id:
|
|
2398
|
-
serviceId:
|
|
2399
|
-
clientId:
|
|
2400
|
-
appType:
|
|
2401
|
-
name:
|
|
2512
|
+
id: z3.string(),
|
|
2513
|
+
serviceId: z3.string(),
|
|
2514
|
+
clientId: z3.string(),
|
|
2515
|
+
appType: z3.enum(["server_local", "slock_builtin", "third_party_global"]).optional(),
|
|
2516
|
+
name: z3.string(),
|
|
2402
2517
|
description: nullableStringSchema,
|
|
2403
2518
|
homepageUrl: nullableStringSchema,
|
|
2404
2519
|
returnUrl: nullableStringSchema,
|
|
2405
2520
|
agentManifestUrl: nullableStringSchema,
|
|
2406
|
-
agentManifestUrlSource:
|
|
2407
|
-
scopes:
|
|
2408
|
-
createdAt:
|
|
2521
|
+
agentManifestUrlSource: z3.enum(["explicit", "well_known"]).nullable().optional(),
|
|
2522
|
+
scopes: z3.array(z3.string()),
|
|
2523
|
+
createdAt: z3.string()
|
|
2409
2524
|
});
|
|
2410
2525
|
var agentApiIntegrationListResponseSchema = passthroughObject({
|
|
2411
|
-
services:
|
|
2412
|
-
activeLogins:
|
|
2526
|
+
services: z3.array(agentApiIntegrationServiceSchema),
|
|
2527
|
+
activeLogins: z3.array(agentApiActiveIntegrationLoginSchema)
|
|
2413
2528
|
});
|
|
2414
2529
|
var agentApiIntegrationLoginResponseSchema = passthroughObject({
|
|
2415
|
-
status:
|
|
2530
|
+
status: z3.enum(["logged_in", "already_logged_in", "approval_required"]),
|
|
2416
2531
|
service: agentApiIntegrationServiceSchema,
|
|
2417
|
-
scopes:
|
|
2418
|
-
requestId:
|
|
2532
|
+
scopes: z3.array(z3.string()),
|
|
2533
|
+
requestId: z3.string().optional(),
|
|
2419
2534
|
session: passthroughObject({
|
|
2420
|
-
status:
|
|
2421
|
-
source:
|
|
2535
|
+
status: z3.literal("stored"),
|
|
2536
|
+
source: z3.enum(["cache", "fresh"]),
|
|
2422
2537
|
path: nullableStringSchema
|
|
2423
2538
|
}).optional(),
|
|
2424
2539
|
approval: passthroughObject({
|
|
2425
|
-
requestId:
|
|
2540
|
+
requestId: z3.string(),
|
|
2426
2541
|
target: nullableStringSchema,
|
|
2427
2542
|
actionCardMessageId: nullableStringSchema
|
|
2428
2543
|
}).optional()
|
|
2429
2544
|
});
|
|
2430
2545
|
var agentApiIntegrationAppPrepareResponseSchema = passthroughObject({
|
|
2431
|
-
status:
|
|
2432
|
-
mode:
|
|
2433
|
-
target:
|
|
2434
|
-
actionCardMessageId:
|
|
2435
|
-
action:
|
|
2546
|
+
status: z3.literal("prepared"),
|
|
2547
|
+
mode: z3.enum(["register", "update"]),
|
|
2548
|
+
target: z3.string(),
|
|
2549
|
+
actionCardMessageId: z3.string(),
|
|
2550
|
+
action: z3.discriminatedUnion("type", [
|
|
2436
2551
|
integrationRegisterAppOperationSchema,
|
|
2437
2552
|
integrationUpdateAppRegistrationOperationSchema
|
|
2438
2553
|
])
|
|
2439
2554
|
});
|
|
2440
2555
|
var agentApiIntegrationAppRotateSecretResponseSchema = passthroughObject({
|
|
2441
|
-
clientId:
|
|
2442
|
-
clientKey:
|
|
2443
|
-
clientName:
|
|
2444
|
-
clientSecret:
|
|
2556
|
+
clientId: z3.string(),
|
|
2557
|
+
clientKey: z3.string(),
|
|
2558
|
+
clientName: z3.string(),
|
|
2559
|
+
clientSecret: z3.string()
|
|
2445
2560
|
});
|
|
2446
2561
|
var agentApiAttachmentEnvelopeSchema = passthroughObject({
|
|
2447
|
-
id:
|
|
2448
|
-
filename:
|
|
2562
|
+
id: z3.string(),
|
|
2563
|
+
filename: z3.string()
|
|
2449
2564
|
});
|
|
2450
2565
|
var agentApiAttachmentUploadResponseSchema = passthroughObject({
|
|
2451
|
-
id:
|
|
2452
|
-
filename:
|
|
2566
|
+
id: z3.string().trim().min(1),
|
|
2567
|
+
filename: z3.string(),
|
|
2453
2568
|
mimeType: nullableStringSchema,
|
|
2454
|
-
sizeBytes:
|
|
2569
|
+
sizeBytes: z3.number().int().nonnegative(),
|
|
2455
2570
|
thumbnailUrl: nullableStringSchema
|
|
2456
2571
|
});
|
|
2457
2572
|
var agentApiMessageEnvelopeSchema = passthroughObject({
|
|
@@ -2464,69 +2579,69 @@ var agentApiMessageEnvelopeSchema = passthroughObject({
|
|
|
2464
2579
|
sender_type: optionalStringSchema,
|
|
2465
2580
|
senderName: optionalStringSchema,
|
|
2466
2581
|
sender_name: optionalStringSchema,
|
|
2467
|
-
senderDescription:
|
|
2468
|
-
sender_description:
|
|
2582
|
+
senderDescription: z3.string().nullable().optional(),
|
|
2583
|
+
sender_description: z3.string().nullable().optional(),
|
|
2469
2584
|
channel_type: optionalStringSchema,
|
|
2470
2585
|
channel_name: optionalStringSchema,
|
|
2471
2586
|
parent_channel_type: optionalStringSchema,
|
|
2472
2587
|
parent_channel_name: optionalStringSchema,
|
|
2473
2588
|
content: optionalStringSchema,
|
|
2474
|
-
attachments:
|
|
2475
|
-
taskStatus:
|
|
2476
|
-
task_status:
|
|
2477
|
-
taskNumber:
|
|
2478
|
-
task_number:
|
|
2479
|
-
taskAssigneeId:
|
|
2480
|
-
task_assignee_id:
|
|
2481
|
-
taskAssigneeType:
|
|
2482
|
-
task_assignee_type:
|
|
2483
|
-
threadId:
|
|
2484
|
-
replyCount:
|
|
2589
|
+
attachments: z3.array(agentApiAttachmentEnvelopeSchema).optional(),
|
|
2590
|
+
taskStatus: z3.string().nullable().optional(),
|
|
2591
|
+
task_status: z3.string().nullable().optional(),
|
|
2592
|
+
taskNumber: z3.number().int().positive().nullable().optional(),
|
|
2593
|
+
task_number: z3.number().int().positive().nullable().optional(),
|
|
2594
|
+
taskAssigneeId: z3.string().nullable().optional(),
|
|
2595
|
+
task_assignee_id: z3.string().nullable().optional(),
|
|
2596
|
+
taskAssigneeType: z3.string().nullable().optional(),
|
|
2597
|
+
task_assignee_type: z3.string().nullable().optional(),
|
|
2598
|
+
threadId: z3.string().nullable().optional(),
|
|
2599
|
+
replyCount: z3.number().int().nonnegative().nullable().optional()
|
|
2485
2600
|
});
|
|
2486
2601
|
var agentApiEventsResponseSchema = passthroughObject({
|
|
2487
|
-
events:
|
|
2602
|
+
events: z3.array(agentApiMessageEnvelopeSchema),
|
|
2488
2603
|
last_seen_msgId: nullableStringSchema,
|
|
2489
2604
|
last_seen_seq: nullableNumberSchema,
|
|
2490
2605
|
reply_target: nullableStringSchema,
|
|
2491
|
-
pending_notice_ids:
|
|
2492
|
-
wake_reason:
|
|
2493
|
-
has_more:
|
|
2606
|
+
pending_notice_ids: z3.array(z3.string()),
|
|
2607
|
+
wake_reason: z3.string().nullable(),
|
|
2608
|
+
has_more: z3.boolean()
|
|
2494
2609
|
});
|
|
2495
2610
|
var agentApiHistoryResponseSchema = passthroughObject({
|
|
2496
|
-
messages:
|
|
2497
|
-
has_more:
|
|
2498
|
-
has_older:
|
|
2499
|
-
has_newer:
|
|
2611
|
+
messages: z3.array(agentApiMessageEnvelopeSchema),
|
|
2612
|
+
has_more: z3.boolean(),
|
|
2613
|
+
has_older: z3.boolean(),
|
|
2614
|
+
has_newer: z3.boolean(),
|
|
2500
2615
|
last_read_seq: nullableNumberSchema.optional()
|
|
2501
2616
|
});
|
|
2502
2617
|
var agentApiHeldFreshnessResponseSchema = passthroughObject({
|
|
2503
|
-
ok:
|
|
2504
|
-
state:
|
|
2505
|
-
outcome:
|
|
2506
|
-
subtype:
|
|
2507
|
-
reason:
|
|
2508
|
-
decision:
|
|
2618
|
+
ok: z3.literal(true).optional(),
|
|
2619
|
+
state: z3.literal("held"),
|
|
2620
|
+
outcome: z3.literal("held").optional(),
|
|
2621
|
+
subtype: z3.literal("freshness").optional(),
|
|
2622
|
+
reason: z3.string().optional(),
|
|
2623
|
+
decision: z3.enum(["local_hold", "syncing_hold"]).optional(),
|
|
2509
2624
|
producerFactId: optionalStringSchema,
|
|
2510
|
-
available_actions:
|
|
2511
|
-
heldMessages:
|
|
2512
|
-
recentUnread:
|
|
2625
|
+
available_actions: z3.array(z3.string()).optional(),
|
|
2626
|
+
heldMessages: z3.array(agentApiMessageEnvelopeSchema).optional(),
|
|
2627
|
+
recentUnread: z3.array(agentApiMessageEnvelopeSchema).optional(),
|
|
2513
2628
|
newMessageCount: optionalNumberSchema,
|
|
2514
2629
|
shownMessageCount: optionalNumberSchema,
|
|
2515
2630
|
omittedMessageCount: optionalNumberSchema,
|
|
2516
2631
|
mentionAnnotation: passthroughObject({
|
|
2517
|
-
formalMentionCount:
|
|
2632
|
+
formalMentionCount: z3.number().finite()
|
|
2518
2633
|
}).optional(),
|
|
2519
2634
|
continueAnywaySuggested: optionalBooleanSchema,
|
|
2520
2635
|
seenUpToSeq: optionalNumberSchema,
|
|
2521
2636
|
seenUpToMessageId: nullableStringSchema.optional()
|
|
2522
2637
|
});
|
|
2523
2638
|
var agentApiSendSentResponseSchema = passthroughObject({
|
|
2524
|
-
ok:
|
|
2525
|
-
state:
|
|
2526
|
-
messageId:
|
|
2639
|
+
ok: z3.literal(true),
|
|
2640
|
+
state: z3.literal("sent"),
|
|
2641
|
+
messageId: z3.string(),
|
|
2527
2642
|
messageSeq: optionalNumberSchema,
|
|
2528
|
-
recentUnread:
|
|
2529
|
-
pendingMentionActions:
|
|
2643
|
+
recentUnread: z3.array(agentApiMessageEnvelopeSchema).optional(),
|
|
2644
|
+
pendingMentionActions: z3.array(agentApiMessageEnvelopeSchema).optional(),
|
|
2530
2645
|
attention: passthroughObject({
|
|
2531
2646
|
driveByJoinedToPost: passthroughObject({
|
|
2532
2647
|
reason: optionalStringSchema,
|
|
@@ -2535,7 +2650,7 @@ var agentApiSendSentResponseSchema = passthroughObject({
|
|
|
2535
2650
|
}).optional()
|
|
2536
2651
|
}).optional()
|
|
2537
2652
|
});
|
|
2538
|
-
var agentApiSendResponseSchema =
|
|
2653
|
+
var agentApiSendResponseSchema = z3.discriminatedUnion("state", [
|
|
2539
2654
|
agentApiSendSentResponseSchema,
|
|
2540
2655
|
agentApiHeldFreshnessResponseSchema
|
|
2541
2656
|
]);
|
|
@@ -2551,46 +2666,46 @@ var agentApiChannelAttentionSchema = passthroughObject({
|
|
|
2551
2666
|
manageApi: optionalStringSchema
|
|
2552
2667
|
});
|
|
2553
2668
|
var agentApiOkResponseSchema = passthroughObject({
|
|
2554
|
-
ok:
|
|
2669
|
+
ok: z3.literal(true),
|
|
2555
2670
|
attention: agentApiChannelAttentionSchema.optional()
|
|
2556
2671
|
});
|
|
2557
2672
|
var agentApiSearchResultSchema = passthroughObject({
|
|
2558
|
-
id:
|
|
2559
|
-
seq:
|
|
2560
|
-
channelId:
|
|
2561
|
-
threadId:
|
|
2562
|
-
parentMessageId:
|
|
2563
|
-
parentMessageContent:
|
|
2564
|
-
parentChannelId:
|
|
2565
|
-
parentChannelName:
|
|
2566
|
-
parentChannelType:
|
|
2673
|
+
id: z3.string(),
|
|
2674
|
+
seq: z3.number().int().nonnegative(),
|
|
2675
|
+
channelId: z3.string(),
|
|
2676
|
+
threadId: z3.string().nullable(),
|
|
2677
|
+
parentMessageId: z3.string().nullable(),
|
|
2678
|
+
parentMessageContent: z3.string().nullable(),
|
|
2679
|
+
parentChannelId: z3.string(),
|
|
2680
|
+
parentChannelName: z3.string(),
|
|
2681
|
+
parentChannelType: z3.string(),
|
|
2567
2682
|
parentChannelArchivedAt: nullableStringSchema,
|
|
2568
|
-
senderId:
|
|
2569
|
-
senderType:
|
|
2570
|
-
senderName:
|
|
2571
|
-
channelName:
|
|
2572
|
-
channelType:
|
|
2683
|
+
senderId: z3.string(),
|
|
2684
|
+
senderType: z3.string(),
|
|
2685
|
+
senderName: z3.string(),
|
|
2686
|
+
channelName: z3.string(),
|
|
2687
|
+
channelType: z3.string(),
|
|
2573
2688
|
channelArchivedAt: nullableStringSchema,
|
|
2574
|
-
content:
|
|
2575
|
-
snippet:
|
|
2576
|
-
createdAt:
|
|
2689
|
+
content: z3.string(),
|
|
2690
|
+
snippet: z3.string(),
|
|
2691
|
+
createdAt: z3.string().datetime()
|
|
2577
2692
|
});
|
|
2578
2693
|
var agentApiMessageSearchResponseSchema = passthroughObject({
|
|
2579
|
-
results:
|
|
2580
|
-
hasMore:
|
|
2694
|
+
results: z3.array(agentApiSearchResultSchema),
|
|
2695
|
+
hasMore: z3.boolean()
|
|
2581
2696
|
});
|
|
2582
2697
|
var agentApiChannelMembersResponseSchema = passthroughObject({
|
|
2583
2698
|
channel: passthroughObject({
|
|
2584
|
-
ref:
|
|
2585
|
-
type:
|
|
2699
|
+
ref: z3.string(),
|
|
2700
|
+
type: z3.string()
|
|
2586
2701
|
}),
|
|
2587
|
-
agents:
|
|
2588
|
-
name:
|
|
2702
|
+
agents: z3.array(passthroughObject({
|
|
2703
|
+
name: z3.string(),
|
|
2589
2704
|
status: optionalStringSchema
|
|
2590
2705
|
})),
|
|
2591
|
-
humans:
|
|
2592
|
-
name:
|
|
2593
|
-
description:
|
|
2706
|
+
humans: z3.array(passthroughObject({
|
|
2707
|
+
name: z3.string(),
|
|
2708
|
+
description: z3.string().nullable().optional(),
|
|
2594
2709
|
role: optionalStringSchema
|
|
2595
2710
|
}))
|
|
2596
2711
|
});
|
|
@@ -2611,105 +2726,105 @@ var agentApiChannelMuteResponseSchema = passthroughObject({
|
|
|
2611
2726
|
});
|
|
2612
2727
|
var agentApiChannelMuteBodySchema = passthroughObject({
|
|
2613
2728
|
attentionHintAccepted: passthroughObject({
|
|
2614
|
-
schema:
|
|
2615
|
-
trigger:
|
|
2616
|
-
scope:
|
|
2729
|
+
schema: z3.literal(ATTENTION_HINT_SCHEMA),
|
|
2730
|
+
trigger: z3.enum(["M2", "M3"]),
|
|
2731
|
+
scope: z3.string().trim().min(1),
|
|
2617
2732
|
suggested_command: optionalStringSchema,
|
|
2618
|
-
copy_version:
|
|
2619
|
-
epoch_ms:
|
|
2733
|
+
copy_version: z3.string().trim().min(1),
|
|
2734
|
+
epoch_ms: z3.number().int().nonnegative()
|
|
2620
2735
|
}).optional()
|
|
2621
2736
|
});
|
|
2622
2737
|
var agentApiTaskClaimResultSchema = passthroughObject({
|
|
2623
|
-
taskNumber:
|
|
2738
|
+
taskNumber: z3.number().int().positive().optional(),
|
|
2624
2739
|
messageId: optionalStringSchema,
|
|
2625
|
-
success:
|
|
2740
|
+
success: z3.boolean(),
|
|
2626
2741
|
reason: optionalStringSchema
|
|
2627
2742
|
});
|
|
2628
2743
|
var agentApiTaskClaimSuccessResponseSchema = passthroughObject({
|
|
2629
|
-
results:
|
|
2744
|
+
results: z3.array(agentApiTaskClaimResultSchema)
|
|
2630
2745
|
});
|
|
2631
|
-
var agentApiTaskClaimResponseSchema =
|
|
2746
|
+
var agentApiTaskClaimResponseSchema = z3.union([
|
|
2632
2747
|
agentApiTaskClaimSuccessResponseSchema,
|
|
2633
2748
|
agentApiHeldFreshnessResponseSchema
|
|
2634
2749
|
]);
|
|
2635
2750
|
var agentApiTaskEnvelopeSchema = passthroughObject({
|
|
2636
|
-
taskNumber:
|
|
2637
|
-
status:
|
|
2751
|
+
taskNumber: z3.number().int().positive().optional(),
|
|
2752
|
+
status: z3.string().optional(),
|
|
2638
2753
|
title: optionalStringSchema,
|
|
2639
|
-
claimedByName:
|
|
2640
|
-
createdByName:
|
|
2641
|
-
messageId:
|
|
2754
|
+
claimedByName: z3.string().nullable().optional(),
|
|
2755
|
+
createdByName: z3.string().nullable().optional(),
|
|
2756
|
+
messageId: z3.string().nullable().optional(),
|
|
2642
2757
|
isLegacy: optionalBooleanSchema
|
|
2643
2758
|
});
|
|
2644
2759
|
var agentApiTaskListResponseSchema = passthroughObject({
|
|
2645
|
-
tasks:
|
|
2760
|
+
tasks: z3.array(agentApiTaskEnvelopeSchema)
|
|
2646
2761
|
});
|
|
2647
2762
|
var agentApiCreatedTaskEnvelopeSchema = passthroughObject({
|
|
2648
|
-
taskNumber:
|
|
2649
|
-
messageId:
|
|
2650
|
-
title:
|
|
2763
|
+
taskNumber: z3.number().int().positive(),
|
|
2764
|
+
messageId: z3.string(),
|
|
2765
|
+
title: z3.string()
|
|
2651
2766
|
});
|
|
2652
2767
|
var agentApiTaskCreateResponseSchema = passthroughObject({
|
|
2653
|
-
tasks:
|
|
2768
|
+
tasks: z3.array(agentApiCreatedTaskEnvelopeSchema)
|
|
2654
2769
|
});
|
|
2655
2770
|
var agentApiTaskUnclaimResponseSchema = passthroughObject({
|
|
2656
|
-
ok:
|
|
2771
|
+
ok: z3.literal(true)
|
|
2657
2772
|
});
|
|
2658
2773
|
var agentApiTaskUpdateStatusSuccessResponseSchema = passthroughObject({
|
|
2659
|
-
ok:
|
|
2774
|
+
ok: z3.literal(true)
|
|
2660
2775
|
});
|
|
2661
|
-
var agentApiTaskUpdateStatusResponseSchema =
|
|
2776
|
+
var agentApiTaskUpdateStatusResponseSchema = z3.union([
|
|
2662
2777
|
agentApiTaskUpdateStatusSuccessResponseSchema,
|
|
2663
2778
|
agentApiHeldFreshnessResponseSchema
|
|
2664
2779
|
]);
|
|
2665
2780
|
var agentApiActionPrepareResponseSchema = passthroughObject({
|
|
2666
|
-
messageId:
|
|
2781
|
+
messageId: z3.string(),
|
|
2667
2782
|
metadata: passthroughObject({
|
|
2668
|
-
kind:
|
|
2783
|
+
kind: z3.literal("action-card")
|
|
2669
2784
|
})
|
|
2670
2785
|
});
|
|
2671
|
-
var agentApiReminderRecurrenceSchema =
|
|
2672
|
-
kind:
|
|
2673
|
-
description:
|
|
2786
|
+
var agentApiReminderRecurrenceSchema = z3.object({
|
|
2787
|
+
kind: z3.enum(["interval", "daily", "weekly", "unsupported"]),
|
|
2788
|
+
description: z3.string()
|
|
2674
2789
|
});
|
|
2675
|
-
var agentApiReminderSummarySchema =
|
|
2676
|
-
reminderId:
|
|
2677
|
-
ownerAgentId:
|
|
2678
|
-
title:
|
|
2679
|
-
fireAt:
|
|
2790
|
+
var agentApiReminderSummarySchema = z3.object({
|
|
2791
|
+
reminderId: z3.string(),
|
|
2792
|
+
ownerAgentId: z3.string(),
|
|
2793
|
+
title: z3.string(),
|
|
2794
|
+
fireAt: z3.string(),
|
|
2680
2795
|
firedAt: nullableStringSchema.optional(),
|
|
2681
|
-
createdAt:
|
|
2796
|
+
createdAt: z3.string(),
|
|
2682
2797
|
status: reminderStatusSchema,
|
|
2683
2798
|
msgRef: nullableStringSchema,
|
|
2684
2799
|
msgPermalink: nullableStringSchema,
|
|
2685
2800
|
recurrence: agentApiReminderRecurrenceSchema.nullable()
|
|
2686
2801
|
});
|
|
2687
|
-
var agentApiReminderEventSummarySchema =
|
|
2688
|
-
eventId:
|
|
2689
|
-
reminderId:
|
|
2802
|
+
var agentApiReminderEventSummarySchema = z3.object({
|
|
2803
|
+
eventId: z3.string(),
|
|
2804
|
+
reminderId: z3.string(),
|
|
2690
2805
|
eventType: reminderEventTypeSchema,
|
|
2691
|
-
actorType:
|
|
2806
|
+
actorType: z3.enum(["agent", "human", "system"]),
|
|
2692
2807
|
actorId: nullableStringSchema,
|
|
2693
|
-
occurredAt:
|
|
2808
|
+
occurredAt: z3.string(),
|
|
2694
2809
|
nextFireAt: nullableStringSchema,
|
|
2695
|
-
metadata:
|
|
2810
|
+
metadata: z3.record(z3.string(), z3.unknown()).nullable()
|
|
2696
2811
|
});
|
|
2697
2812
|
var agentApiReminderListResponseSchema = passthroughObject({
|
|
2698
|
-
reminders:
|
|
2813
|
+
reminders: z3.array(agentApiReminderSummarySchema)
|
|
2699
2814
|
});
|
|
2700
2815
|
var agentApiReminderResponseSchema = passthroughObject({
|
|
2701
2816
|
reminder: agentApiReminderSummarySchema,
|
|
2702
2817
|
warning: optionalStringSchema
|
|
2703
2818
|
});
|
|
2704
2819
|
var agentApiReminderLogResponseSchema = passthroughObject({
|
|
2705
|
-
events:
|
|
2820
|
+
events: z3.array(agentApiReminderEventSummarySchema)
|
|
2706
2821
|
});
|
|
2707
|
-
var agentApiMigrationStateSchema =
|
|
2822
|
+
var agentApiMigrationStateSchema = z3.enum(["provisioning", "prep", "ready", "in_transit", "arriving", "completed", "aborted", "failed"]);
|
|
2708
2823
|
var agentApiMigrationSummarySchema = passthroughObject({
|
|
2709
|
-
id:
|
|
2710
|
-
agentId:
|
|
2711
|
-
sourceMachineId:
|
|
2712
|
-
targetMachineId:
|
|
2824
|
+
id: z3.string(),
|
|
2825
|
+
agentId: z3.string(),
|
|
2826
|
+
sourceMachineId: z3.string(),
|
|
2827
|
+
targetMachineId: z3.string(),
|
|
2713
2828
|
state: agentApiMigrationStateSchema,
|
|
2714
2829
|
manifestPath: nullableStringSchema,
|
|
2715
2830
|
manifestSha256: nullableStringSchema,
|
|
@@ -2717,26 +2832,26 @@ var agentApiMigrationSummarySchema = passthroughObject({
|
|
|
2717
2832
|
arrivalReportSha256: nullableStringSchema,
|
|
2718
2833
|
abortReason: nullableStringSchema,
|
|
2719
2834
|
failureReason: nullableStringSchema,
|
|
2720
|
-
prepDeadlineAt:
|
|
2721
|
-
transferDeadlineAt:
|
|
2722
|
-
arrivalDeadlineAt:
|
|
2835
|
+
prepDeadlineAt: z3.string().datetime(),
|
|
2836
|
+
transferDeadlineAt: z3.string().datetime(),
|
|
2837
|
+
arrivalDeadlineAt: z3.string().datetime(),
|
|
2723
2838
|
readyAt: nullableStringSchema,
|
|
2724
2839
|
flippedAt: nullableStringSchema,
|
|
2725
2840
|
arrivedAt: nullableStringSchema,
|
|
2726
2841
|
completedAt: nullableStringSchema,
|
|
2727
2842
|
abortedAt: nullableStringSchema,
|
|
2728
|
-
revision:
|
|
2729
|
-
createdAt:
|
|
2730
|
-
updatedAt:
|
|
2843
|
+
revision: z3.number().int().positive(),
|
|
2844
|
+
createdAt: z3.string().datetime(),
|
|
2845
|
+
updatedAt: z3.string().datetime()
|
|
2731
2846
|
});
|
|
2732
2847
|
var agentApiMigrationBeginBodySchema = passthroughObject({
|
|
2733
|
-
targetMachineId:
|
|
2734
|
-
prepDeadlineMs:
|
|
2735
|
-
transferDeadlineMs:
|
|
2736
|
-
arrivalDeadlineMs:
|
|
2848
|
+
targetMachineId: z3.string().trim().min(1),
|
|
2849
|
+
prepDeadlineMs: z3.number().int().positive().optional(),
|
|
2850
|
+
transferDeadlineMs: z3.number().int().positive().optional(),
|
|
2851
|
+
arrivalDeadlineMs: z3.number().int().positive().optional()
|
|
2737
2852
|
});
|
|
2738
2853
|
var agentApiMigrationReadyBodySchema = passthroughObject({
|
|
2739
|
-
manifestPath:
|
|
2854
|
+
manifestPath: z3.string().trim().min(1),
|
|
2740
2855
|
manifestSha256: optionalStringSchema
|
|
2741
2856
|
});
|
|
2742
2857
|
var agentApiMigrationArrivedBodySchema = passthroughObject({
|
|
@@ -3215,47 +3330,47 @@ var agentApiContract = {
|
|
|
3215
3330
|
};
|
|
3216
3331
|
|
|
3217
3332
|
// ../shared/src/daemonApiContract.ts
|
|
3218
|
-
import { z as
|
|
3333
|
+
import { z as z4 } from "zod";
|
|
3219
3334
|
var DAEMON_API_BASE_PATH = "/internal/agent-api";
|
|
3220
|
-
var optionalStringSchema2 =
|
|
3221
|
-
var optionalNonNegativeIntSchema =
|
|
3222
|
-
var optionalQueryIntSchema =
|
|
3223
|
-
var nullableNumberSchema2 =
|
|
3224
|
-
var passthroughObject2 = (shape) =>
|
|
3225
|
-
var daemonApiInboxFlagSchema =
|
|
3335
|
+
var optionalStringSchema2 = z4.string().trim().optional();
|
|
3336
|
+
var optionalNonNegativeIntSchema = z4.number().int().nonnegative().optional();
|
|
3337
|
+
var optionalQueryIntSchema = z4.union([z4.number().int().nonnegative(), z4.string().trim().min(1)]).optional();
|
|
3338
|
+
var nullableNumberSchema2 = z4.number().finite().nullable();
|
|
3339
|
+
var passthroughObject2 = (shape) => z4.object(shape).passthrough();
|
|
3340
|
+
var daemonApiInboxFlagSchema = z4.enum(["mention", "thread", "dm", "task"]);
|
|
3226
3341
|
var daemonApiAttentionHintSchema = passthroughObject2({
|
|
3227
|
-
schema:
|
|
3228
|
-
trigger:
|
|
3229
|
-
scope:
|
|
3230
|
-
suggested_command:
|
|
3231
|
-
copy:
|
|
3232
|
-
copy_version:
|
|
3233
|
-
epoch_ms:
|
|
3342
|
+
schema: z4.literal(ATTENTION_HINT_SCHEMA),
|
|
3343
|
+
trigger: z4.enum(["M2", "M3"]),
|
|
3344
|
+
scope: z4.string().trim().min(1),
|
|
3345
|
+
suggested_command: z4.string().trim().min(1),
|
|
3346
|
+
copy: z4.string().trim().min(1),
|
|
3347
|
+
copy_version: z4.literal("attention-hint-copy-v1"),
|
|
3348
|
+
epoch_ms: z4.number().int().nonnegative(),
|
|
3234
3349
|
thresholds: passthroughObject2({
|
|
3235
3350
|
K: optionalNonNegativeIntSchema,
|
|
3236
3351
|
k: optionalNonNegativeIntSchema,
|
|
3237
|
-
window_ms:
|
|
3352
|
+
window_ms: z4.number().int().positive()
|
|
3238
3353
|
})
|
|
3239
3354
|
});
|
|
3240
3355
|
var daemonApiInboxTargetRowSchema = passthroughObject2({
|
|
3241
|
-
target:
|
|
3356
|
+
target: z4.string().trim().min(1),
|
|
3242
3357
|
channelId: optionalStringSchema2,
|
|
3243
3358
|
channelType: optionalStringSchema2,
|
|
3244
|
-
pendingCount:
|
|
3359
|
+
pendingCount: z4.number().int().nonnegative(),
|
|
3245
3360
|
firstPendingMsgId: optionalStringSchema2,
|
|
3246
3361
|
firstPendingSeq: optionalNonNegativeIntSchema,
|
|
3247
3362
|
latestMsgId: optionalStringSchema2,
|
|
3248
3363
|
latestSeq: optionalNonNegativeIntSchema,
|
|
3249
3364
|
latestSenderName: optionalStringSchema2,
|
|
3250
|
-
latestSenderType:
|
|
3251
|
-
flags:
|
|
3365
|
+
latestSenderType: z4.enum(["human", "agent", "system", "third_party_app"]).optional(),
|
|
3366
|
+
flags: z4.array(daemonApiInboxFlagSchema),
|
|
3252
3367
|
attentionHint: daemonApiAttentionHintSchema.optional()
|
|
3253
3368
|
});
|
|
3254
3369
|
var daemonApiInboxCheckResponseSchema = passthroughObject2({
|
|
3255
|
-
rows:
|
|
3370
|
+
rows: z4.array(daemonApiInboxTargetRowSchema).optional()
|
|
3256
3371
|
});
|
|
3257
3372
|
var daemonApiWakeHintsQuerySchema = passthroughObject2({
|
|
3258
|
-
since:
|
|
3373
|
+
since: z4.union([z4.literal("latest"), z4.number().int().nonnegative(), z4.string().trim().min(1)]).optional(),
|
|
3259
3374
|
limit: optionalQueryIntSchema
|
|
3260
3375
|
});
|
|
3261
3376
|
var daemonApiWakeHintSchema = passthroughObject2({
|
|
@@ -3263,8 +3378,8 @@ var daemonApiWakeHintSchema = passthroughObject2({
|
|
|
3263
3378
|
hint_id: optionalStringSchema2,
|
|
3264
3379
|
eventId: optionalStringSchema2,
|
|
3265
3380
|
event_id: optionalStringSchema2,
|
|
3266
|
-
messageId:
|
|
3267
|
-
message_id:
|
|
3381
|
+
messageId: z4.string().nullable().optional(),
|
|
3382
|
+
message_id: z4.string().nullable().optional(),
|
|
3268
3383
|
seq: optionalNonNegativeIntSchema,
|
|
3269
3384
|
id: optionalStringSchema2,
|
|
3270
3385
|
target: optionalStringSchema2,
|
|
@@ -3277,27 +3392,27 @@ var daemonApiWakeHintSchema = passthroughObject2({
|
|
|
3277
3392
|
created_at: optionalStringSchema2
|
|
3278
3393
|
});
|
|
3279
3394
|
var daemonApiWakeHintsFetchResponseSchema = passthroughObject2({
|
|
3280
|
-
hints:
|
|
3281
|
-
wake_hints:
|
|
3395
|
+
hints: z4.array(daemonApiWakeHintSchema).optional(),
|
|
3396
|
+
wake_hints: z4.array(daemonApiWakeHintSchema).optional(),
|
|
3282
3397
|
last_seen_hint_seq: nullableNumberSchema2.optional(),
|
|
3283
3398
|
last_hint_seq: nullableNumberSchema2.optional(),
|
|
3284
|
-
has_more:
|
|
3399
|
+
has_more: z4.boolean().optional()
|
|
3285
3400
|
});
|
|
3286
3401
|
var daemonApiActivityEventSchema = passthroughObject2({
|
|
3287
3402
|
schema: optionalStringSchema2
|
|
3288
3403
|
});
|
|
3289
3404
|
var daemonApiActivityForwardBodySchema = passthroughObject2({
|
|
3290
|
-
schema:
|
|
3405
|
+
schema: z4.literal("raft-agent-activity-ingest.v1"),
|
|
3291
3406
|
coreSessionId: optionalStringSchema2,
|
|
3292
3407
|
adapterInstance: optionalStringSchema2,
|
|
3293
|
-
events:
|
|
3408
|
+
events: z4.array(daemonApiActivityEventSchema),
|
|
3294
3409
|
dropped: optionalNonNegativeIntSchema
|
|
3295
3410
|
});
|
|
3296
3411
|
var daemonApiActivityForwardResponseSchema = passthroughObject2({
|
|
3297
|
-
ok:
|
|
3298
|
-
acceptedCount:
|
|
3299
|
-
rejectedCount:
|
|
3300
|
-
droppedCount:
|
|
3412
|
+
ok: z4.literal(true).optional(),
|
|
3413
|
+
acceptedCount: z4.number().int().nonnegative().optional(),
|
|
3414
|
+
rejectedCount: z4.number().int().nonnegative().optional(),
|
|
3415
|
+
droppedCount: z4.number().int().nonnegative().optional()
|
|
3301
3416
|
});
|
|
3302
3417
|
function route2(input) {
|
|
3303
3418
|
return {
|
|
@@ -3391,7 +3506,7 @@ function formatAttentionHintField(hint) {
|
|
|
3391
3506
|
}
|
|
3392
3507
|
|
|
3393
3508
|
// ../shared/src/externalAgentIntegration.ts
|
|
3394
|
-
import { z as
|
|
3509
|
+
import { z as z5 } from "zod";
|
|
3395
3510
|
var EXTERNAL_AGENT_COMMS_PROTOCOL_VERSION = "agent-comms-core.v1";
|
|
3396
3511
|
var EXTERNAL_AGENT_PROOF_SCHEMA_VERSION = "agent-proof.v1";
|
|
3397
3512
|
var EXTERNAL_RUNTIME_INTEGRATION_MANIFEST_SCHEMA = "slock-external-runtime-integration.v1";
|
|
@@ -3435,35 +3550,35 @@ var externalAgentAdapterFailureValues = [
|
|
|
3435
3550
|
"auth_revoked"
|
|
3436
3551
|
];
|
|
3437
3552
|
var externalAgentServerApiModeValues = ["interim-agent-api-events", "agent-inbox-protocol"];
|
|
3438
|
-
var nonEmptyStringSchema =
|
|
3439
|
-
var isoTimestampSchema =
|
|
3553
|
+
var nonEmptyStringSchema = z5.string().min(1);
|
|
3554
|
+
var isoTimestampSchema = z5.string().refine((value) => !Number.isNaN(Date.parse(value)), {
|
|
3440
3555
|
message: "must be a parseable timestamp"
|
|
3441
3556
|
});
|
|
3442
|
-
var externalRuntimeIntegrationManifestSchema =
|
|
3443
|
-
schema:
|
|
3557
|
+
var externalRuntimeIntegrationManifestSchema = z5.object({
|
|
3558
|
+
schema: z5.literal(EXTERNAL_RUNTIME_INTEGRATION_MANIFEST_SCHEMA),
|
|
3444
3559
|
runtimeId: nonEmptyStringSchema,
|
|
3445
|
-
integrationPattern:
|
|
3446
|
-
commsMode:
|
|
3447
|
-
commsProtocolVersion:
|
|
3448
|
-
proofSchemaVersion:
|
|
3560
|
+
integrationPattern: z5.enum(externalAgentIntegrationPatternValues),
|
|
3561
|
+
commsMode: z5.enum(externalAgentCommsModeValues),
|
|
3562
|
+
commsProtocolVersion: z5.literal(EXTERNAL_AGENT_COMMS_PROTOCOL_VERSION),
|
|
3563
|
+
proofSchemaVersion: z5.literal(EXTERNAL_AGENT_PROOF_SCHEMA_VERSION),
|
|
3449
3564
|
minSlockCliVersion: nonEmptyStringSchema,
|
|
3450
|
-
multiplex:
|
|
3451
|
-
agentIsolation:
|
|
3452
|
-
bridgeLifecycle:
|
|
3453
|
-
explicitStartOnly:
|
|
3454
|
-
oneShotCommandsBridgeIndependent:
|
|
3455
|
-
requiresBridgeFailureCodes:
|
|
3456
|
-
autoStartDefault:
|
|
3565
|
+
multiplex: z5.boolean(),
|
|
3566
|
+
agentIsolation: z5.enum(externalAgentIsolationValues),
|
|
3567
|
+
bridgeLifecycle: z5.object({
|
|
3568
|
+
explicitStartOnly: z5.literal(true),
|
|
3569
|
+
oneShotCommandsBridgeIndependent: z5.literal(true),
|
|
3570
|
+
requiresBridgeFailureCodes: z5.array(z5.enum(["BRIDGE_NOT_RUNNING", "NO_CORE_SESSION"])).min(1),
|
|
3571
|
+
autoStartDefault: z5.literal(false)
|
|
3457
3572
|
}).strict(),
|
|
3458
|
-
serverApi:
|
|
3459
|
-
mode:
|
|
3460
|
-
deliveryOnly:
|
|
3461
|
-
cursorAuthority:
|
|
3573
|
+
serverApi: z5.object({
|
|
3574
|
+
mode: z5.enum(externalAgentServerApiModeValues),
|
|
3575
|
+
deliveryOnly: z5.boolean(),
|
|
3576
|
+
cursorAuthority: z5.literal("model_seen_only")
|
|
3462
3577
|
}).strict(),
|
|
3463
|
-
wakeAdapter:
|
|
3464
|
-
kind:
|
|
3578
|
+
wakeAdapter: z5.object({
|
|
3579
|
+
kind: z5.enum(externalAgentWakeAdapterKindValues),
|
|
3465
3580
|
protocol: nonEmptyStringSchema,
|
|
3466
|
-
requiresInteractiveSession:
|
|
3581
|
+
requiresInteractiveSession: z5.boolean().optional()
|
|
3467
3582
|
}).strict()
|
|
3468
3583
|
}).strict().superRefine((value, ctx) => {
|
|
3469
3584
|
if (!value.bridgeLifecycle.requiresBridgeFailureCodes.includes("BRIDGE_NOT_RUNNING")) {
|
|
@@ -3488,8 +3603,8 @@ var externalRuntimeIntegrationManifestSchema = z4.object({
|
|
|
3488
3603
|
});
|
|
3489
3604
|
}
|
|
3490
3605
|
});
|
|
3491
|
-
var externalAgentWakeEventBaseSchema =
|
|
3492
|
-
schema:
|
|
3606
|
+
var externalAgentWakeEventBaseSchema = z5.object({
|
|
3607
|
+
schema: z5.literal(EXTERNAL_AGENT_WAKE_EVENT_SCHEMA),
|
|
3493
3608
|
eventId: nonEmptyStringSchema,
|
|
3494
3609
|
attemptId: nonEmptyStringSchema,
|
|
3495
3610
|
messageId: nonEmptyStringSchema,
|
|
@@ -3499,30 +3614,30 @@ var externalAgentWakeEventBaseSchema = z4.object({
|
|
|
3499
3614
|
adapterInstance: nonEmptyStringSchema,
|
|
3500
3615
|
runtimeSession: nonEmptyStringSchema.nullable(),
|
|
3501
3616
|
occurredAt: isoTimestampSchema,
|
|
3502
|
-
lifecycleState:
|
|
3503
|
-
authority:
|
|
3504
|
-
source:
|
|
3505
|
-
provenance:
|
|
3617
|
+
lifecycleState: z5.enum(externalAgentCommsLifecycleStateValues),
|
|
3618
|
+
authority: z5.object({
|
|
3619
|
+
source: z5.enum(externalAgentLifecycleSourceValues),
|
|
3620
|
+
provenance: z5.enum(externalAgentLifecycleProvenanceValues)
|
|
3506
3621
|
}).strict()
|
|
3507
3622
|
}).strict();
|
|
3508
3623
|
var externalAgentProofEventEnvelopeSchema = externalAgentWakeEventBaseSchema.extend({
|
|
3509
|
-
kind:
|
|
3510
|
-
proofLevel:
|
|
3511
|
-
outcome:
|
|
3512
|
-
failureMeta:
|
|
3513
|
-
reason:
|
|
3624
|
+
kind: z5.literal("proof"),
|
|
3625
|
+
proofLevel: z5.enum(externalAgentWakeProofLevelValues),
|
|
3626
|
+
outcome: z5.literal("ok"),
|
|
3627
|
+
failureMeta: z5.undefined().optional(),
|
|
3628
|
+
reason: z5.string().optional()
|
|
3514
3629
|
});
|
|
3515
3630
|
var externalAgentFailedWakeEventEnvelopeSchema = externalAgentWakeEventBaseSchema.extend({
|
|
3516
|
-
kind:
|
|
3517
|
-
proofLevel:
|
|
3518
|
-
outcome:
|
|
3519
|
-
failureMeta:
|
|
3520
|
-
failureClass:
|
|
3521
|
-
retryAfterMs:
|
|
3631
|
+
kind: z5.literal("wake_attempt"),
|
|
3632
|
+
proofLevel: z5.undefined().optional(),
|
|
3633
|
+
outcome: z5.literal("failed"),
|
|
3634
|
+
failureMeta: z5.object({
|
|
3635
|
+
failureClass: z5.enum(externalAgentAdapterFailureValues),
|
|
3636
|
+
retryAfterMs: z5.number().int().positive().optional()
|
|
3522
3637
|
}).strict(),
|
|
3523
3638
|
reason: nonEmptyStringSchema
|
|
3524
3639
|
});
|
|
3525
|
-
var externalAgentWakeEventEnvelopeSchema =
|
|
3640
|
+
var externalAgentWakeEventEnvelopeSchema = z5.discriminatedUnion("kind", [
|
|
3526
3641
|
externalAgentProofEventEnvelopeSchema,
|
|
3527
3642
|
externalAgentFailedWakeEventEnvelopeSchema
|
|
3528
3643
|
]);
|
|
@@ -3659,6 +3774,7 @@ var SERVER_CAPABILITY_MATRIX = {
|
|
|
3659
3774
|
};
|
|
3660
3775
|
|
|
3661
3776
|
// ../shared/src/index.ts
|
|
3777
|
+
var COMPUTER_CAPABILITY_SUPERVISOR_MUTATIONS = "computer:supervisor-mutations-v1";
|
|
3662
3778
|
var RUNTIME_CONFIG_VERSION = 1;
|
|
3663
3779
|
var BUILTIN_RUNTIME_PROVIDER_ENV_KEYS = PI_BUILTIN_PROVIDER_API_KEY_ENV_KEYS_GENERATED;
|
|
3664
3780
|
var BUILTIN_RUNTIME_PROVIDERS = Object.entries(BUILTIN_RUNTIME_PROVIDER_ENV_KEYS).map(([id, envKey]) => ({ id, envKey }));
|
|
@@ -3710,6 +3826,10 @@ var AGENT_ACTIVITY_DETAIL_KINDS = [
|
|
|
3710
3826
|
"ready",
|
|
3711
3827
|
"runtime_interrupted",
|
|
3712
3828
|
"machine_disconnected",
|
|
3829
|
+
"computer_started",
|
|
3830
|
+
"computer_restarted",
|
|
3831
|
+
"computer_upgraded",
|
|
3832
|
+
"computer_operation_failed",
|
|
3713
3833
|
"daemon_activity",
|
|
3714
3834
|
"external_activity",
|
|
3715
3835
|
"synthetic_repair",
|
|
@@ -5143,6 +5263,15 @@ function listLegacySlockStatePaths(slockHome = resolveSlockHome(), homeDir = os.
|
|
|
5143
5263
|
return candidates.filter((candidate) => existsSync(candidate.path));
|
|
5144
5264
|
}
|
|
5145
5265
|
|
|
5266
|
+
// src/authEnv.ts
|
|
5267
|
+
var DAEMON_API_KEY_ENV = "SLOCK_MACHINE_API_KEY";
|
|
5268
|
+
var SLOCK_AGENT_TOKEN_ENV = "SLOCK_AGENT_TOKEN";
|
|
5269
|
+
function scrubDaemonChildEnv(env) {
|
|
5270
|
+
delete env[DAEMON_API_KEY_ENV];
|
|
5271
|
+
delete env[SLOCK_AGENT_TOKEN_ENV];
|
|
5272
|
+
return env;
|
|
5273
|
+
}
|
|
5274
|
+
|
|
5146
5275
|
// src/agentCredentialProxy.ts
|
|
5147
5276
|
import { randomBytes } from "crypto";
|
|
5148
5277
|
import http from "http";
|
|
@@ -6724,7 +6853,9 @@ var LOOPBACK_NO_PROXY = "127.0.0.1,localhost";
|
|
|
6724
6853
|
var CLI_TRANSPORT_TRACE_DIR_ENV = "SLOCK_CLI_TRANSPORT_TRACE_DIR";
|
|
6725
6854
|
var safePathPart = (value) => value.replace(/[^a-zA-Z0-9_.-]/g, "_");
|
|
6726
6855
|
var RAW_CREDENTIAL_ENV_DENYLIST = [
|
|
6727
|
-
"
|
|
6856
|
+
"SLOCK_AGENT_TOKEN",
|
|
6857
|
+
"SLOCK_AGENT_CREDENTIAL_KEY",
|
|
6858
|
+
"SLOCK_AGENT_CREDENTIAL_KEY_FILE"
|
|
6728
6859
|
];
|
|
6729
6860
|
var WORKSPACE_CLI_TRANSPORT_FILENAMES = [
|
|
6730
6861
|
"agent-token",
|
|
@@ -7079,7 +7210,7 @@ set "SLOCK_AGENT_ACTIVE_CAPABILITIES=${DEFAULT_ACTIVE_CAPABILITIES}"\r
|
|
|
7079
7210
|
SLOCK_SERVER_URL: ctx.config.serverUrl,
|
|
7080
7211
|
PATH: `${slockDir}${path2.delimiter}${process.env.PATH ?? ""}`
|
|
7081
7212
|
};
|
|
7082
|
-
|
|
7213
|
+
scrubDaemonChildEnv(spawnEnv);
|
|
7083
7214
|
for (const key of RAW_CREDENTIAL_ENV_DENYLIST) {
|
|
7084
7215
|
delete spawnEnv[key];
|
|
7085
7216
|
}
|
|
@@ -7392,6 +7523,46 @@ var ClaudeEventNormalizer = class {
|
|
|
7392
7523
|
}
|
|
7393
7524
|
};
|
|
7394
7525
|
|
|
7526
|
+
// src/drivers/claudeInputBudget.ts
|
|
7527
|
+
var CLAUDE_DEFAULT_CONTEXT_TOKENS = 2e5;
|
|
7528
|
+
var CLAUDE_FABLE_CONTEXT_TOKENS = 1e6;
|
|
7529
|
+
var CLAUDE_INPUT_TOKEN_RESERVE = 32e3;
|
|
7530
|
+
var ClaudeStartupPayloadTooLargeError = class extends Error {
|
|
7531
|
+
constructor(details) {
|
|
7532
|
+
super(
|
|
7533
|
+
`INPUT_TOO_LARGE: Claude daemon-owned startup payload is too large before command launch (estimated ${details.estimatedTokens} tokens, budget ${details.budgetTokens}, context limit ${details.contextLimitTokens}, model ${details.model}). Reduce the current prompt or daemon-injected startup context before retrying.`
|
|
7534
|
+
);
|
|
7535
|
+
this.details = details;
|
|
7536
|
+
this.name = "ClaudeStartupPayloadTooLargeError";
|
|
7537
|
+
}
|
|
7538
|
+
};
|
|
7539
|
+
function assertClaudeStartupPayloadWithinBudget(config, input) {
|
|
7540
|
+
const model = claudeModelName(config);
|
|
7541
|
+
const contextLimitTokens = claudeContextLimitTokens(model);
|
|
7542
|
+
const budgetTokens = Math.max(1, contextLimitTokens - CLAUDE_INPUT_TOKEN_RESERVE);
|
|
7543
|
+
const estimatedTokens = estimateClaudeInputTokens(input);
|
|
7544
|
+
if (estimatedTokens <= budgetTokens) return;
|
|
7545
|
+
throw new ClaudeStartupPayloadTooLargeError({
|
|
7546
|
+
estimatedTokens,
|
|
7547
|
+
budgetTokens,
|
|
7548
|
+
contextLimitTokens,
|
|
7549
|
+
model
|
|
7550
|
+
});
|
|
7551
|
+
}
|
|
7552
|
+
function estimateClaudeInputTokens(input) {
|
|
7553
|
+
return Math.ceil(Buffer.byteLength(input, "utf8") / 3);
|
|
7554
|
+
}
|
|
7555
|
+
function claudeModelName(config) {
|
|
7556
|
+
const runtimeConfig = config.runtimeConfig;
|
|
7557
|
+
if (runtimeConfig?.runtime === "claude") {
|
|
7558
|
+
return runtimeConfigModelValue(runtimeConfig);
|
|
7559
|
+
}
|
|
7560
|
+
return config.model || "unknown";
|
|
7561
|
+
}
|
|
7562
|
+
function claudeContextLimitTokens(model) {
|
|
7563
|
+
return /\bfable\b/i.test(model) ? CLAUDE_FABLE_CONTEXT_TOKENS : CLAUDE_DEFAULT_CONTEXT_TOKENS;
|
|
7564
|
+
}
|
|
7565
|
+
|
|
7395
7566
|
// src/drivers/claudeLaunch.ts
|
|
7396
7567
|
import { writeFileSync as writeFileSync2 } from "fs";
|
|
7397
7568
|
import path5 from "path";
|
|
@@ -7647,7 +7818,7 @@ function requiresWindowsShell(command, platform = process.platform) {
|
|
|
7647
7818
|
}
|
|
7648
7819
|
function resolveCommandOnPath(command, deps = {}) {
|
|
7649
7820
|
const platform = deps.platform ?? process.platform;
|
|
7650
|
-
const env = withWindowsUserEnvironment(deps.env ?? process.env, deps);
|
|
7821
|
+
const env = scrubDaemonChildEnv({ ...withWindowsUserEnvironment(deps.env ?? process.env, deps) });
|
|
7651
7822
|
const execFileSyncFn = deps.execFileSyncFn ?? execFileSync;
|
|
7652
7823
|
const existsSyncFn = deps.existsSyncFn ?? existsSync3;
|
|
7653
7824
|
if (platform === "win32") {
|
|
@@ -7673,7 +7844,7 @@ function firstExistingPath(candidates, deps = {}) {
|
|
|
7673
7844
|
return null;
|
|
7674
7845
|
}
|
|
7675
7846
|
function readCommandVersion(command, args = [], deps = {}) {
|
|
7676
|
-
const env = withWindowsUserEnvironment(deps.env ?? process.env, deps);
|
|
7847
|
+
const env = scrubDaemonChildEnv({ ...withWindowsUserEnvironment(deps.env ?? process.env, deps) });
|
|
7677
7848
|
const execFileSyncFn = deps.execFileSyncFn ?? execFileSync;
|
|
7678
7849
|
try {
|
|
7679
7850
|
const output = normalizeExecOutput(execFileSyncFn(command, [...args, "--version"], {
|
|
@@ -7811,6 +7982,8 @@ var ClaudeDriver = class {
|
|
|
7811
7982
|
return buildClaudeArgs(config, opts);
|
|
7812
7983
|
}
|
|
7813
7984
|
async spawn(ctx) {
|
|
7985
|
+
assertClaudeStartupPayloadWithinBudget(ctx.config, `${ctx.standingPrompt}
|
|
7986
|
+
${ctx.prompt}`);
|
|
7814
7987
|
const { slockDir, tokenFile, spawnEnv } = await prepareCliTransport(
|
|
7815
7988
|
ctx,
|
|
7816
7989
|
buildClaudeProviderIsolationEnv(ctx)
|
|
@@ -7924,6 +8097,12 @@ function codexSessionRootCandidates(homeDirOrCodexRoot) {
|
|
|
7924
8097
|
var RuntimeTurnState = class {
|
|
7925
8098
|
currentTurnId = null;
|
|
7926
8099
|
pendingTurnId = null;
|
|
8100
|
+
turnInProgress = false;
|
|
8101
|
+
currentTurnHadRuntimeActivity = false;
|
|
8102
|
+
currentTurnHadTokenUsage = false;
|
|
8103
|
+
currentTurnHadNonEmptyInput = false;
|
|
8104
|
+
pendingNonEmptyInputTurnIds = /* @__PURE__ */ new Set();
|
|
8105
|
+
completedTurnIds = /* @__PURE__ */ new Set();
|
|
7927
8106
|
/**
|
|
7928
8107
|
* Post-tool window where the app-server may not yet accept stdin steering.
|
|
7929
8108
|
* Gate busy-mode delivery until turn/completed or next progress.
|
|
@@ -7932,6 +8111,12 @@ var RuntimeTurnState = class {
|
|
|
7932
8111
|
reset() {
|
|
7933
8112
|
this.currentTurnId = null;
|
|
7934
8113
|
this.pendingTurnId = null;
|
|
8114
|
+
this.turnInProgress = false;
|
|
8115
|
+
this.currentTurnHadRuntimeActivity = false;
|
|
8116
|
+
this.currentTurnHadTokenUsage = false;
|
|
8117
|
+
this.currentTurnHadNonEmptyInput = false;
|
|
8118
|
+
this.pendingNonEmptyInputTurnIds.clear();
|
|
8119
|
+
this.completedTurnIds.clear();
|
|
7935
8120
|
this.steeringGateActive = false;
|
|
7936
8121
|
}
|
|
7937
8122
|
get activeTurnId() {
|
|
@@ -7946,20 +8131,54 @@ var RuntimeTurnState = class {
|
|
|
7946
8131
|
this.currentTurnId = startedTurnId;
|
|
7947
8132
|
}
|
|
7948
8133
|
this.pendingTurnId = null;
|
|
8134
|
+
this.turnInProgress = true;
|
|
8135
|
+
this.currentTurnHadRuntimeActivity = false;
|
|
8136
|
+
this.currentTurnHadTokenUsage = false;
|
|
8137
|
+
this.currentTurnHadNonEmptyInput = startedTurnId ? this.pendingNonEmptyInputTurnIds.delete(startedTurnId) : false;
|
|
7949
8138
|
this.steeringGateActive = false;
|
|
7950
8139
|
}
|
|
7951
8140
|
noteTurnAccepted(turnId) {
|
|
7952
8141
|
this.pendingTurnId = turnId;
|
|
7953
8142
|
}
|
|
7954
8143
|
markProgress() {
|
|
8144
|
+
this.currentTurnHadRuntimeActivity = true;
|
|
7955
8145
|
this.steeringGateActive = false;
|
|
7956
8146
|
}
|
|
7957
8147
|
markToolBoundary() {
|
|
8148
|
+
this.currentTurnHadRuntimeActivity = true;
|
|
7958
8149
|
this.steeringGateActive = true;
|
|
7959
8150
|
}
|
|
8151
|
+
markTokenUsage() {
|
|
8152
|
+
this.currentTurnHadTokenUsage = true;
|
|
8153
|
+
}
|
|
8154
|
+
markNonEmptyInputForTurn(turnId) {
|
|
8155
|
+
if (!turnId || this.completedTurnIds.has(turnId)) return;
|
|
8156
|
+
if (this.turnInProgress && this.currentTurnId === turnId) {
|
|
8157
|
+
this.currentTurnHadNonEmptyInput = true;
|
|
8158
|
+
} else {
|
|
8159
|
+
this.pendingNonEmptyInputTurnIds.add(turnId);
|
|
8160
|
+
}
|
|
8161
|
+
}
|
|
8162
|
+
hasNonEmptyInputEvidence() {
|
|
8163
|
+
return this.currentTurnHadNonEmptyInput;
|
|
8164
|
+
}
|
|
8165
|
+
completedWithoutRuntimeActivity() {
|
|
8166
|
+
return this.turnInProgress && !this.currentTurnHadRuntimeActivity && !this.currentTurnHadTokenUsage;
|
|
8167
|
+
}
|
|
7960
8168
|
markTurnCompleted() {
|
|
8169
|
+
if (this.currentTurnId) {
|
|
8170
|
+
this.completedTurnIds.add(this.currentTurnId);
|
|
8171
|
+
if (this.completedTurnIds.size > 16) {
|
|
8172
|
+
const oldest = this.completedTurnIds.values().next().value;
|
|
8173
|
+
if (oldest) this.completedTurnIds.delete(oldest);
|
|
8174
|
+
}
|
|
8175
|
+
}
|
|
7961
8176
|
this.currentTurnId = null;
|
|
7962
8177
|
this.pendingTurnId = null;
|
|
8178
|
+
this.turnInProgress = false;
|
|
8179
|
+
this.currentTurnHadRuntimeActivity = false;
|
|
8180
|
+
this.currentTurnHadTokenUsage = false;
|
|
8181
|
+
this.currentTurnHadNonEmptyInput = false;
|
|
7963
8182
|
this.steeringGateActive = false;
|
|
7964
8183
|
}
|
|
7965
8184
|
};
|
|
@@ -8212,6 +8431,9 @@ var CodexEventNormalizer = class {
|
|
|
8212
8431
|
get canSteerBusy() {
|
|
8213
8432
|
return this.turnState.canSteerBusy;
|
|
8214
8433
|
}
|
|
8434
|
+
markNonEmptyTurnInput(turnId) {
|
|
8435
|
+
this.turnState.markNonEmptyInputForTurn(turnId);
|
|
8436
|
+
}
|
|
8215
8437
|
adoptThreadId(threadId) {
|
|
8216
8438
|
this.currentThreadId = threadId;
|
|
8217
8439
|
}
|
|
@@ -8241,6 +8463,9 @@ var CodexEventNormalizer = class {
|
|
|
8241
8463
|
}
|
|
8242
8464
|
const telemetry = parseCodexTelemetryEvent(message);
|
|
8243
8465
|
if (telemetry) {
|
|
8466
|
+
if (telemetry.kind === "telemetry" && telemetry.name === "token_usage") {
|
|
8467
|
+
this.turnState.markTokenUsage();
|
|
8468
|
+
}
|
|
8244
8469
|
const telemetrySessionId = codexMessageThreadId(message);
|
|
8245
8470
|
const telemetryTurnId = nonEmptyString2(message.params?.turnId) ?? nonEmptyString2(message.params?.turn?.id);
|
|
8246
8471
|
if (telemetrySessionId) {
|
|
@@ -8257,6 +8482,7 @@ var CodexEventNormalizer = class {
|
|
|
8257
8482
|
}
|
|
8258
8483
|
const rawProgress = rawResponseItemProgressEvent(message);
|
|
8259
8484
|
if (rawProgress) {
|
|
8485
|
+
this.turnState.markProgress();
|
|
8260
8486
|
events.push(rawProgress);
|
|
8261
8487
|
return { events };
|
|
8262
8488
|
}
|
|
@@ -8385,6 +8611,7 @@ var CodexEventNormalizer = class {
|
|
|
8385
8611
|
break;
|
|
8386
8612
|
case "commandExecution":
|
|
8387
8613
|
if (isStarted && typeof item.command === "string") {
|
|
8614
|
+
this.turnState.markProgress();
|
|
8388
8615
|
events.push({ kind: "tool_call", name: "shell", input: { command: item.command } });
|
|
8389
8616
|
}
|
|
8390
8617
|
if (isCompleted) {
|
|
@@ -8394,19 +8621,23 @@ var CodexEventNormalizer = class {
|
|
|
8394
8621
|
break;
|
|
8395
8622
|
case "contextCompaction":
|
|
8396
8623
|
if (isStarted) {
|
|
8624
|
+
this.turnState.markProgress();
|
|
8397
8625
|
events.push({ kind: "compaction_started" });
|
|
8398
8626
|
}
|
|
8399
8627
|
if (isCompleted) {
|
|
8628
|
+
this.turnState.markProgress();
|
|
8400
8629
|
events.push({ kind: "compaction_finished" });
|
|
8401
8630
|
}
|
|
8402
8631
|
break;
|
|
8403
8632
|
case "enteredReviewMode":
|
|
8404
8633
|
if (isStarted) {
|
|
8634
|
+
this.turnState.markProgress();
|
|
8405
8635
|
events.push({ kind: "review_started" });
|
|
8406
8636
|
}
|
|
8407
8637
|
break;
|
|
8408
8638
|
case "exitedReviewMode":
|
|
8409
8639
|
if (isCompleted) {
|
|
8640
|
+
this.turnState.markProgress();
|
|
8410
8641
|
events.push({ kind: "review_finished" });
|
|
8411
8642
|
}
|
|
8412
8643
|
break;
|
|
@@ -8414,6 +8645,7 @@ var CodexEventNormalizer = class {
|
|
|
8414
8645
|
if (isStarted && Array.isArray(item.changes)) {
|
|
8415
8646
|
let outputCount = 0;
|
|
8416
8647
|
for (const change of item.changes) {
|
|
8648
|
+
this.turnState.markProgress();
|
|
8417
8649
|
events.push({
|
|
8418
8650
|
kind: "tool_call",
|
|
8419
8651
|
name: "file_change",
|
|
@@ -8445,6 +8677,7 @@ var CodexEventNormalizer = class {
|
|
|
8445
8677
|
case "mcpToolCall":
|
|
8446
8678
|
if (isStarted) {
|
|
8447
8679
|
const toolName = codexMcpToolName(item);
|
|
8680
|
+
this.turnState.markProgress();
|
|
8448
8681
|
events.push({ kind: "tool_call", name: toolName, input: item.arguments });
|
|
8449
8682
|
}
|
|
8450
8683
|
if (isCompleted) {
|
|
@@ -8455,6 +8688,7 @@ var CodexEventNormalizer = class {
|
|
|
8455
8688
|
break;
|
|
8456
8689
|
case "collabAgentToolCall":
|
|
8457
8690
|
if (isStarted) {
|
|
8691
|
+
this.turnState.markProgress();
|
|
8458
8692
|
events.push({ kind: "tool_call", name: "collab_tool_call", input: { tool: item.tool, prompt: item.prompt } });
|
|
8459
8693
|
}
|
|
8460
8694
|
if (isCompleted) {
|
|
@@ -8464,6 +8698,7 @@ var CodexEventNormalizer = class {
|
|
|
8464
8698
|
break;
|
|
8465
8699
|
case "webSearch":
|
|
8466
8700
|
if (isStarted) {
|
|
8701
|
+
this.turnState.markProgress();
|
|
8467
8702
|
events.push({ kind: "tool_call", name: "web_search", input: { query: item.query } });
|
|
8468
8703
|
}
|
|
8469
8704
|
if (isCompleted) {
|
|
@@ -8483,6 +8718,26 @@ var CodexEventNormalizer = class {
|
|
|
8483
8718
|
const detail = typeof turn?.error?.message === "string" && turn.error.message.length > 0 ? `: ${turn.error.message}` : "";
|
|
8484
8719
|
events.push({ kind: "error", message: `Codex turn interrupted${detail}` });
|
|
8485
8720
|
}
|
|
8721
|
+
if (turn?.status === "completed" && this.turnState.completedWithoutRuntimeActivity()) {
|
|
8722
|
+
const inputEvidence = this.turnState.hasNonEmptyInputEvidence() ? "nonempty" : "unknown";
|
|
8723
|
+
const diagnosticMessage = "Codex runtime completed an empty turn with no output, progress, or token usage";
|
|
8724
|
+
const userMessage = inputEvidence === "nonempty" ? "Codex runtime returned an empty response. Please retry." : "Codex runtime completed without a response. Please retry.";
|
|
8725
|
+
events.push({
|
|
8726
|
+
kind: "runtime_diagnostic",
|
|
8727
|
+
severity: "warning",
|
|
8728
|
+
source: "codex_app_server_notification",
|
|
8729
|
+
itemType: "codex_zero_evidence_turn_completed",
|
|
8730
|
+
message: diagnosticMessage,
|
|
8731
|
+
details: "Codex runtime reported turn/completed status=completed after turn/started with no assistant text, reasoning text, tool activity, internal progress, raw response-item progress, or valid thread/tokenUsage/updated payload.",
|
|
8732
|
+
payloadBytes: payloadBytes(message.params),
|
|
8733
|
+
inputEvidence,
|
|
8734
|
+
...this.currentThreadId ? { sessionId: this.currentThreadId } : {}
|
|
8735
|
+
});
|
|
8736
|
+
events.push({
|
|
8737
|
+
kind: "error",
|
|
8738
|
+
message: `${userMessage} (codex_zero_evidence_turn_completed)`
|
|
8739
|
+
});
|
|
8740
|
+
}
|
|
8486
8741
|
this.turnState.markTurnCompleted();
|
|
8487
8742
|
this.streamedAgentMessageIds.clear();
|
|
8488
8743
|
this.streamedReasoningIds.clear();
|
|
@@ -8520,6 +8775,15 @@ var CodexEventNormalizer = class {
|
|
|
8520
8775
|
// src/drivers/codex.ts
|
|
8521
8776
|
var CODEX_DESKTOP_BUNDLE_PATH = "/Applications/Codex.app/Contents/Resources/codex";
|
|
8522
8777
|
var CODEX_APP_SERVER_PROBE_ARGS = ["app-server", "--help"];
|
|
8778
|
+
function hasNonEmptyCodexTextInput(input) {
|
|
8779
|
+
return Array.isArray(input) && input.some(
|
|
8780
|
+
(item) => item && typeof item === "object" && item.type === "text" && typeof item.text === "string" && item.text.length > 0
|
|
8781
|
+
);
|
|
8782
|
+
}
|
|
8783
|
+
function resultTurnId(message) {
|
|
8784
|
+
const turn = message.result?.turn;
|
|
8785
|
+
return turn && typeof turn.id === "string" ? turn.id : null;
|
|
8786
|
+
}
|
|
8523
8787
|
function isWindowsSandboxRunner(commandPath) {
|
|
8524
8788
|
return path7.basename(commandPath).toLowerCase().startsWith("codex-command-runner");
|
|
8525
8789
|
}
|
|
@@ -8849,6 +9113,7 @@ var CodexDriver = class {
|
|
|
8849
9113
|
pendingResumeFallbackParams = null;
|
|
8850
9114
|
pendingResumeThreadId = null;
|
|
8851
9115
|
pendingInitialTurnRequestId = null;
|
|
9116
|
+
pendingInitialTurnInput = null;
|
|
8852
9117
|
pendingDeliveryRequests = /* @__PURE__ */ new Map();
|
|
8853
9118
|
initialTurnStarted = false;
|
|
8854
9119
|
normalizer = new CodexEventNormalizer();
|
|
@@ -8869,6 +9134,7 @@ var CodexDriver = class {
|
|
|
8869
9134
|
this.pendingResumeFallbackParams = null;
|
|
8870
9135
|
this.pendingResumeThreadId = null;
|
|
8871
9136
|
this.pendingInitialTurnRequestId = null;
|
|
9137
|
+
this.pendingInitialTurnInput = null;
|
|
8872
9138
|
this.pendingDeliveryRequests.clear();
|
|
8873
9139
|
this.initialTurnStarted = false;
|
|
8874
9140
|
this.normalizer.reset();
|
|
@@ -8991,28 +9257,33 @@ var CodexDriver = class {
|
|
|
8991
9257
|
startupRequestMethod: "turn/start"
|
|
8992
9258
|
});
|
|
8993
9259
|
} else {
|
|
9260
|
+
if (hasNonEmptyCodexTextInput(this.pendingInitialTurnInput)) {
|
|
9261
|
+
this.normalizer.markNonEmptyTurnInput(resultTurnId(message));
|
|
9262
|
+
}
|
|
8994
9263
|
this.pendingInitialPrompt = null;
|
|
8995
9264
|
}
|
|
9265
|
+
this.pendingInitialTurnInput = null;
|
|
8996
9266
|
return events;
|
|
8997
9267
|
}
|
|
8998
9268
|
if (isResponse && message.id !== void 0 && this.pendingDeliveryRequests.has(message.id)) {
|
|
8999
|
-
const
|
|
9269
|
+
const deliveryRequest = this.pendingDeliveryRequests.get(message.id);
|
|
9000
9270
|
this.pendingDeliveryRequests.delete(message.id);
|
|
9001
9271
|
if (hasJsonRpcField(message, "error")) {
|
|
9002
9272
|
const params = message.error ?? {};
|
|
9003
9273
|
events.push({
|
|
9004
9274
|
kind: "delivery_error",
|
|
9005
9275
|
message: message.error?.message || "Codex app-server request failed",
|
|
9006
|
-
requestMethod,
|
|
9276
|
+
requestMethod: deliveryRequest.method,
|
|
9007
9277
|
source: "codex_app_server_response",
|
|
9008
9278
|
payloadBytes: payloadBytes2(params)
|
|
9009
9279
|
});
|
|
9280
|
+
} else if (hasNonEmptyCodexTextInput(deliveryRequest.input)) {
|
|
9281
|
+
this.normalizer.markNonEmptyTurnInput(deliveryRequest.turnId ?? resultTurnId(message));
|
|
9010
9282
|
}
|
|
9011
9283
|
return events;
|
|
9012
9284
|
}
|
|
9013
9285
|
const result = this.normalizer.normalizeMessage(message);
|
|
9014
9286
|
if (result.turnStarted) {
|
|
9015
|
-
this.pendingInitialTurnRequestId = null;
|
|
9016
9287
|
this.pendingInitialPrompt = null;
|
|
9017
9288
|
}
|
|
9018
9289
|
if (result.threadReady) {
|
|
@@ -9029,7 +9300,9 @@ var CodexDriver = class {
|
|
|
9029
9300
|
if (mode === "busy") {
|
|
9030
9301
|
if (!this.normalizer.canSteerBusy) return null;
|
|
9031
9302
|
const id2 = this.nextRequestId();
|
|
9032
|
-
|
|
9303
|
+
const input2 = [{ type: "text", text }];
|
|
9304
|
+
const turnId = this.normalizer.activeTurnId;
|
|
9305
|
+
this.pendingDeliveryRequests.set(id2, { method: "turn/steer", input: input2, turnId });
|
|
9033
9306
|
return JSON.stringify({
|
|
9034
9307
|
jsonrpc: "2.0",
|
|
9035
9308
|
id: id2,
|
|
@@ -9037,19 +9310,20 @@ var CodexDriver = class {
|
|
|
9037
9310
|
params: {
|
|
9038
9311
|
threadId: this.normalizer.threadId,
|
|
9039
9312
|
expectedTurnId: this.normalizer.activeTurnId,
|
|
9040
|
-
input:
|
|
9313
|
+
input: input2
|
|
9041
9314
|
}
|
|
9042
9315
|
});
|
|
9043
9316
|
}
|
|
9044
9317
|
const id = this.nextRequestId();
|
|
9045
|
-
|
|
9318
|
+
const input = [{ type: "text", text }];
|
|
9319
|
+
this.pendingDeliveryRequests.set(id, { method: "turn/start", input, turnId: null });
|
|
9046
9320
|
return JSON.stringify({
|
|
9047
9321
|
jsonrpc: "2.0",
|
|
9048
9322
|
id,
|
|
9049
9323
|
method: "turn/start",
|
|
9050
9324
|
params: {
|
|
9051
9325
|
threadId: this.normalizer.threadId,
|
|
9052
|
-
input
|
|
9326
|
+
input
|
|
9053
9327
|
}
|
|
9054
9328
|
});
|
|
9055
9329
|
}
|
|
@@ -9071,9 +9345,11 @@ var CodexDriver = class {
|
|
|
9071
9345
|
if (this.initialTurnStarted || this.pendingInitialTurnRequestId !== null || !this.pendingInitialPrompt || !this.normalizer.threadId) return;
|
|
9072
9346
|
this.initialTurnStarted = true;
|
|
9073
9347
|
const prompt = this.pendingInitialPrompt;
|
|
9348
|
+
const input = [{ type: "text", text: prompt }];
|
|
9349
|
+
this.pendingInitialTurnInput = input;
|
|
9074
9350
|
this.pendingInitialTurnRequestId = this.sendRequest("turn/start", {
|
|
9075
9351
|
threadId: this.normalizer.threadId,
|
|
9076
|
-
input
|
|
9352
|
+
input
|
|
9077
9353
|
});
|
|
9078
9354
|
}
|
|
9079
9355
|
sendRequest(method, params) {
|
|
@@ -9757,11 +10033,11 @@ function detectCursorModels(runCommand = runCursorModelsCommand) {
|
|
|
9757
10033
|
return parseCursorModelsOutput(String(result.stdout || ""));
|
|
9758
10034
|
}
|
|
9759
10035
|
function buildCursorModelProbeEnv(deps = {}) {
|
|
9760
|
-
return withWindowsUserEnvironment({
|
|
10036
|
+
return scrubDaemonChildEnv(withWindowsUserEnvironment({
|
|
9761
10037
|
...deps.env ?? process.env,
|
|
9762
10038
|
FORCE_COLOR: "0",
|
|
9763
10039
|
NO_COLOR: "1"
|
|
9764
|
-
}, deps);
|
|
10040
|
+
}, deps));
|
|
9765
10041
|
}
|
|
9766
10042
|
function runCursorModelsCommand() {
|
|
9767
10043
|
return spawnSync("cursor-agent", ["models"], {
|
|
@@ -9817,7 +10093,7 @@ function resolveGeminiSpawn(commandArgs, deps = {}) {
|
|
|
9817
10093
|
}
|
|
9818
10094
|
const execFileSyncFn = deps.execFileSyncFn ?? execFileSync3;
|
|
9819
10095
|
const existsSyncFn = deps.existsSyncFn ?? existsSync5;
|
|
9820
|
-
const env = deps.env ?? process.env;
|
|
10096
|
+
const env = scrubDaemonChildEnv({ ...deps.env ?? process.env });
|
|
9821
10097
|
const winPath = path8.win32;
|
|
9822
10098
|
let geminiEntry = null;
|
|
9823
10099
|
try {
|
|
@@ -9954,12 +10230,15 @@ var GeminiDriver = class {
|
|
|
9954
10230
|
// src/drivers/kimi.ts
|
|
9955
10231
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
9956
10232
|
import { spawn as spawn7 } from "child_process";
|
|
9957
|
-
import { existsSync as existsSync6, readFileSync as readFileSync3, writeFileSync as writeFileSync3 } from "fs";
|
|
10233
|
+
import { chmodSync, existsSync as existsSync6, readFileSync as readFileSync3, writeFileSync as writeFileSync3 } from "fs";
|
|
9958
10234
|
import os4 from "os";
|
|
9959
10235
|
import path9 from "path";
|
|
9960
10236
|
var KIMI_WIRE_PROTOCOL_VERSION = "1.3";
|
|
9961
10237
|
var KIMI_SYSTEM_PROMPT_FILE = ".slock-kimi-system.md";
|
|
9962
10238
|
var KIMI_AGENT_FILE = ".slock-kimi-agent.yaml";
|
|
10239
|
+
var KIMI_GENERATED_CONFIG_FILE = ".slock-kimi-config.toml";
|
|
10240
|
+
var SLOCK_KIMI_CONFIG_CONTENT_ENV = "SLOCK_KIMI_CONFIG_CONTENT";
|
|
10241
|
+
var SLOCK_KIMI_CONFIG_FILE_ENV = "SLOCK_KIMI_CONFIG_FILE";
|
|
9963
10242
|
function parseToolArguments(raw) {
|
|
9964
10243
|
if (typeof raw !== "string") return raw;
|
|
9965
10244
|
try {
|
|
@@ -9968,6 +10247,73 @@ function parseToolArguments(raw) {
|
|
|
9968
10247
|
return raw;
|
|
9969
10248
|
}
|
|
9970
10249
|
}
|
|
10250
|
+
function readKimiConfigSource(home = os4.homedir(), env = process.env) {
|
|
10251
|
+
const inlineConfig = env[SLOCK_KIMI_CONFIG_CONTENT_ENV];
|
|
10252
|
+
if (inlineConfig && inlineConfig.trim()) {
|
|
10253
|
+
return {
|
|
10254
|
+
raw: inlineConfig,
|
|
10255
|
+
explicitPath: null,
|
|
10256
|
+
sourcePath: SLOCK_KIMI_CONFIG_CONTENT_ENV
|
|
10257
|
+
};
|
|
10258
|
+
}
|
|
10259
|
+
const explicitPath = env[SLOCK_KIMI_CONFIG_FILE_ENV];
|
|
10260
|
+
const configPath = explicitPath && explicitPath.trim() ? explicitPath : path9.join(home, ".kimi", "config.toml");
|
|
10261
|
+
try {
|
|
10262
|
+
return {
|
|
10263
|
+
raw: readFileSync3(configPath, "utf8"),
|
|
10264
|
+
explicitPath: explicitPath && explicitPath.trim() ? explicitPath : null,
|
|
10265
|
+
sourcePath: configPath
|
|
10266
|
+
};
|
|
10267
|
+
} catch {
|
|
10268
|
+
return {
|
|
10269
|
+
raw: null,
|
|
10270
|
+
explicitPath: explicitPath && explicitPath.trim() ? explicitPath : null,
|
|
10271
|
+
sourcePath: configPath
|
|
10272
|
+
};
|
|
10273
|
+
}
|
|
10274
|
+
}
|
|
10275
|
+
function buildKimiSpawnEnv(env = process.env) {
|
|
10276
|
+
const spawnEnv = { ...env, FORCE_COLOR: "0", NO_COLOR: "1" };
|
|
10277
|
+
delete spawnEnv[SLOCK_KIMI_CONFIG_CONTENT_ENV];
|
|
10278
|
+
delete spawnEnv[SLOCK_KIMI_CONFIG_FILE_ENV];
|
|
10279
|
+
return scrubDaemonChildEnv(spawnEnv);
|
|
10280
|
+
}
|
|
10281
|
+
function buildKimiEffectiveEnv(ctx, overrideEnv) {
|
|
10282
|
+
return {
|
|
10283
|
+
...process.env,
|
|
10284
|
+
...ctx.config.envVars || {},
|
|
10285
|
+
...overrideEnv || {}
|
|
10286
|
+
};
|
|
10287
|
+
}
|
|
10288
|
+
function buildKimiLaunchOptions(ctx, opts = {}) {
|
|
10289
|
+
const env = buildKimiEffectiveEnv(ctx, opts.env);
|
|
10290
|
+
const source = readKimiConfigSource(opts.home ?? os4.homedir(), env);
|
|
10291
|
+
const args = [];
|
|
10292
|
+
let configFilePath = null;
|
|
10293
|
+
let configContent = null;
|
|
10294
|
+
if (source.explicitPath) {
|
|
10295
|
+
configFilePath = source.explicitPath;
|
|
10296
|
+
} else if (source.raw !== null && source.sourcePath === SLOCK_KIMI_CONFIG_CONTENT_ENV) {
|
|
10297
|
+
configFilePath = path9.join(ctx.workingDirectory, KIMI_GENERATED_CONFIG_FILE);
|
|
10298
|
+
configContent = source.raw;
|
|
10299
|
+
if (opts.writeGeneratedConfig !== false) {
|
|
10300
|
+
writeFileSync3(configFilePath, source.raw, { encoding: "utf8", mode: 384 });
|
|
10301
|
+
chmodSync(configFilePath, 384);
|
|
10302
|
+
}
|
|
10303
|
+
}
|
|
10304
|
+
if (configFilePath) {
|
|
10305
|
+
args.push("--config-file", configFilePath);
|
|
10306
|
+
}
|
|
10307
|
+
if (ctx.config.model && ctx.config.model !== "default") {
|
|
10308
|
+
args.push("--model", ctx.config.model);
|
|
10309
|
+
}
|
|
10310
|
+
return {
|
|
10311
|
+
args,
|
|
10312
|
+
env: buildKimiSpawnEnv(env),
|
|
10313
|
+
configFilePath,
|
|
10314
|
+
configContent
|
|
10315
|
+
};
|
|
10316
|
+
}
|
|
9971
10317
|
function resolveKimiSpawn(commandArgs, deps = {}) {
|
|
9972
10318
|
return {
|
|
9973
10319
|
command: resolveCommandOnPath("kimi", deps) ?? "kimi",
|
|
@@ -9991,7 +10337,25 @@ var KimiDriver = class {
|
|
|
9991
10337
|
};
|
|
9992
10338
|
model = {
|
|
9993
10339
|
detectedModelsVerifiedAs: "launchable",
|
|
9994
|
-
toLaunchSpec: (modelId) =>
|
|
10340
|
+
toLaunchSpec: (modelId, ctx, opts) => {
|
|
10341
|
+
if (!ctx) return { args: ["--model", modelId] };
|
|
10342
|
+
const launchCtx = {
|
|
10343
|
+
...ctx,
|
|
10344
|
+
config: {
|
|
10345
|
+
...ctx.config,
|
|
10346
|
+
model: modelId
|
|
10347
|
+
}
|
|
10348
|
+
};
|
|
10349
|
+
const launch = buildKimiLaunchOptions(launchCtx, {
|
|
10350
|
+
home: opts?.home,
|
|
10351
|
+
writeGeneratedConfig: false
|
|
10352
|
+
});
|
|
10353
|
+
return {
|
|
10354
|
+
args: launch.args,
|
|
10355
|
+
env: launch.env,
|
|
10356
|
+
configFiles: launch.configFilePath ? [launch.configFilePath] : void 0
|
|
10357
|
+
};
|
|
10358
|
+
}
|
|
9995
10359
|
};
|
|
9996
10360
|
supportsStdinNotification = true;
|
|
9997
10361
|
busyDeliveryMode = "direct";
|
|
@@ -10015,21 +10379,23 @@ var KimiDriver = class {
|
|
|
10015
10379
|
` system_prompt_path: ./${KIMI_SYSTEM_PROMPT_FILE}`,
|
|
10016
10380
|
""
|
|
10017
10381
|
].join("\n"), "utf8");
|
|
10382
|
+
const launch = buildKimiLaunchOptions(ctx);
|
|
10018
10383
|
const args = [
|
|
10019
10384
|
"--wire",
|
|
10020
10385
|
"--yolo",
|
|
10021
10386
|
"--agent-file",
|
|
10022
10387
|
agentFilePath,
|
|
10023
10388
|
"--session",
|
|
10024
|
-
this.sessionId
|
|
10389
|
+
this.sessionId,
|
|
10390
|
+
...launch.args
|
|
10025
10391
|
];
|
|
10026
10392
|
const launchRuntimeFields = runtimeConfigToLaunchFields(hydrateRuntimeConfig(ctx.config));
|
|
10027
10393
|
if (launchRuntimeFields.model && launchRuntimeFields.model !== "default") {
|
|
10028
10394
|
args.push("--model", launchRuntimeFields.model);
|
|
10029
10395
|
}
|
|
10030
10396
|
const spawnEnv = (await prepareCliTransport(ctx, { NO_COLOR: "1" })).spawnEnv;
|
|
10031
|
-
const
|
|
10032
|
-
const proc = spawn7(
|
|
10397
|
+
const spawnTarget = resolveKimiSpawn(args);
|
|
10398
|
+
const proc = spawn7(spawnTarget.command, spawnTarget.args, {
|
|
10033
10399
|
cwd: ctx.workingDirectory,
|
|
10034
10400
|
stdio: ["pipe", "pipe", "pipe"],
|
|
10035
10401
|
env: spawnEnv,
|
|
@@ -10037,7 +10403,7 @@ var KimiDriver = class {
|
|
|
10037
10403
|
// and has an 8191-character command-line limit. Kimi's official
|
|
10038
10404
|
// installer/uv entrypoint is an executable, so launch it directly and
|
|
10039
10405
|
// keep prompts on stdin / files instead of routing through cmd.exe.
|
|
10040
|
-
shell:
|
|
10406
|
+
shell: spawnTarget.shell
|
|
10041
10407
|
});
|
|
10042
10408
|
proc.stdin?.write(JSON.stringify({
|
|
10043
10409
|
jsonrpc: "2.0",
|
|
@@ -10150,14 +10516,9 @@ var KimiDriver = class {
|
|
|
10150
10516
|
return detectKimiModels();
|
|
10151
10517
|
}
|
|
10152
10518
|
};
|
|
10153
|
-
function detectKimiModels(home = os4.homedir()) {
|
|
10154
|
-
const
|
|
10155
|
-
|
|
10156
|
-
try {
|
|
10157
|
-
raw = readFileSync3(configPath, "utf8");
|
|
10158
|
-
} catch {
|
|
10159
|
-
return null;
|
|
10160
|
-
}
|
|
10519
|
+
function detectKimiModels(home = os4.homedir(), opts = {}) {
|
|
10520
|
+
const raw = readKimiConfigSource(home, opts.env).raw;
|
|
10521
|
+
if (raw === null) return null;
|
|
10161
10522
|
const models = [];
|
|
10162
10523
|
const sectionRe = /^\s*\[models(?:\.([^\]]+)|"\.[^"]+"|\."[^"]+")\s*\]\s*$/gm;
|
|
10163
10524
|
const lineRe = /^\s*\[models\.(.+?)\s*\]\s*$/gm;
|
|
@@ -10417,6 +10778,12 @@ var KimiSdkRuntimeSession = class {
|
|
|
10417
10778
|
get closed() {
|
|
10418
10779
|
return this.didClose;
|
|
10419
10780
|
}
|
|
10781
|
+
// In-process SDK session: there is no OS pid to probe with signal-0, so
|
|
10782
|
+
// liveness is unknowable via the pid-probe boundary. Return undefined, which
|
|
10783
|
+
// callers treat the same as the historic "no pid" probe result (RS-011).
|
|
10784
|
+
isAlive() {
|
|
10785
|
+
return void 0;
|
|
10786
|
+
}
|
|
10420
10787
|
on(event, cb) {
|
|
10421
10788
|
this.events.on(event, cb);
|
|
10422
10789
|
}
|
|
@@ -10836,7 +11203,7 @@ function runOpenCodeModelsCommand(home, deps = {}) {
|
|
|
10836
11203
|
const platform = deps.platform ?? process.platform;
|
|
10837
11204
|
const spawnSyncFn = deps.spawnSyncFn ?? spawnSync2;
|
|
10838
11205
|
const result = spawnSyncFn("opencode", ["models"], {
|
|
10839
|
-
env: { ...process.env, HOME: home, FORCE_COLOR: "0", NO_COLOR: "1" },
|
|
11206
|
+
env: scrubDaemonChildEnv({ ...process.env, HOME: home, FORCE_COLOR: "0", NO_COLOR: "1" }),
|
|
10840
11207
|
encoding: "utf8",
|
|
10841
11208
|
timeout: 5e3,
|
|
10842
11209
|
shell: platform === "win32"
|
|
@@ -11684,6 +12051,12 @@ var PiSdkRuntimeSession = class {
|
|
|
11684
12051
|
get closed() {
|
|
11685
12052
|
return this.didClose;
|
|
11686
12053
|
}
|
|
12054
|
+
// In-process SDK session: there is no OS pid to probe with signal-0, so
|
|
12055
|
+
// liveness is unknowable via the pid-probe boundary. Return undefined, which
|
|
12056
|
+
// callers treat the same as the historic "no pid" probe result (RS-011).
|
|
12057
|
+
isAlive() {
|
|
12058
|
+
return void 0;
|
|
12059
|
+
}
|
|
11687
12060
|
on(event, cb) {
|
|
11688
12061
|
this.events.on(event, cb);
|
|
11689
12062
|
}
|
|
@@ -12002,6 +12375,25 @@ var ChildProcessRuntimeSession = class {
|
|
|
12002
12375
|
get closed() {
|
|
12003
12376
|
return this.process ? this.process.exitCode != null || this.process.signalCode != null : false;
|
|
12004
12377
|
}
|
|
12378
|
+
/**
|
|
12379
|
+
* Read-only OS liveness introspection (signal-0), NOT control IO — exposed so
|
|
12380
|
+
* managers query liveness through the session boundary (RS-011) instead of
|
|
12381
|
+
* poking the raw pid. Preserves the historic `probeRuntimeProcessLiveness`
|
|
12382
|
+
* semantics exactly: undefined when there is no pid, true on success or EPERM,
|
|
12383
|
+
* false otherwise. Deliberately does NOT short-circuit on `this.closed` — the
|
|
12384
|
+
* original probe checked only pid + signal-0.
|
|
12385
|
+
*/
|
|
12386
|
+
isAlive() {
|
|
12387
|
+
const pid = this.process?.pid;
|
|
12388
|
+
if (typeof pid !== "number") return void 0;
|
|
12389
|
+
try {
|
|
12390
|
+
process.kill(pid, 0);
|
|
12391
|
+
return true;
|
|
12392
|
+
} catch (err) {
|
|
12393
|
+
const code = typeof err === "object" && err !== null && "code" in err ? err.code : void 0;
|
|
12394
|
+
return code === "EPERM" ? true : false;
|
|
12395
|
+
}
|
|
12396
|
+
}
|
|
12005
12397
|
on(event, cb) {
|
|
12006
12398
|
this.events.on(event, cb);
|
|
12007
12399
|
}
|
|
@@ -12115,6 +12507,61 @@ function getDriver(runtimeId) {
|
|
|
12115
12507
|
return driver;
|
|
12116
12508
|
}
|
|
12117
12509
|
|
|
12510
|
+
// src/daemonOrphanReaper.ts
|
|
12511
|
+
async function reapOrphanProcesses(pids, logger2, recordTrace) {
|
|
12512
|
+
const survivors = pids.filter((pid) => {
|
|
12513
|
+
try {
|
|
12514
|
+
process.kill(pid, 0);
|
|
12515
|
+
return true;
|
|
12516
|
+
} catch {
|
|
12517
|
+
return false;
|
|
12518
|
+
}
|
|
12519
|
+
});
|
|
12520
|
+
if (survivors.length === 0) return false;
|
|
12521
|
+
for (const pid of survivors) {
|
|
12522
|
+
logger2.warn(`[Daemon] Agent subprocess ${pid} survived stopAll; sending SIGKILL`);
|
|
12523
|
+
try {
|
|
12524
|
+
process.kill(pid, "SIGKILL");
|
|
12525
|
+
} catch {
|
|
12526
|
+
}
|
|
12527
|
+
}
|
|
12528
|
+
recordTrace("daemon.agent.stop_all.survivor_reaped", {
|
|
12529
|
+
survivor_count: survivors.length,
|
|
12530
|
+
survivor_pids: survivors.join(","),
|
|
12531
|
+
reason: "shutdown_survivor",
|
|
12532
|
+
signal: "SIGKILL"
|
|
12533
|
+
});
|
|
12534
|
+
const deadline = Date.now() + 2e3;
|
|
12535
|
+
while (Date.now() < deadline) {
|
|
12536
|
+
const alive = survivors.filter((pid) => {
|
|
12537
|
+
try {
|
|
12538
|
+
process.kill(pid, 0);
|
|
12539
|
+
return true;
|
|
12540
|
+
} catch {
|
|
12541
|
+
return false;
|
|
12542
|
+
}
|
|
12543
|
+
});
|
|
12544
|
+
if (alive.length === 0) break;
|
|
12545
|
+
await new Promise((r) => setTimeout(r, 50));
|
|
12546
|
+
}
|
|
12547
|
+
const stillAlive = survivors.filter((pid) => {
|
|
12548
|
+
try {
|
|
12549
|
+
process.kill(pid, 0);
|
|
12550
|
+
return true;
|
|
12551
|
+
} catch {
|
|
12552
|
+
return false;
|
|
12553
|
+
}
|
|
12554
|
+
});
|
|
12555
|
+
const outcome = stillAlive.length > 0 ? "survivors_still_alive" : "survivors_killed";
|
|
12556
|
+
recordTrace("daemon.agent.stop_all.completed", {
|
|
12557
|
+
survivor_count: survivors.length,
|
|
12558
|
+
reaped_count: survivors.length - stillAlive.length,
|
|
12559
|
+
still_alive_count: stillAlive.length,
|
|
12560
|
+
outcome
|
|
12561
|
+
}, stillAlive.length > 0 ? "error" : "ok");
|
|
12562
|
+
return true;
|
|
12563
|
+
}
|
|
12564
|
+
|
|
12118
12565
|
// src/workspaces.ts
|
|
12119
12566
|
import { readdir, rm, stat } from "fs/promises";
|
|
12120
12567
|
import path13 from "path";
|
|
@@ -13205,6 +13652,7 @@ function buildRuntimeErrorDiagnosticEnvelope(message) {
|
|
|
13205
13652
|
const runtimeErrorReason = classifyRuntimeErrorReason(runtimeErrorClass);
|
|
13206
13653
|
const runtimeErrorAction = classifyRuntimeErrorAction(runtimeErrorClass);
|
|
13207
13654
|
const fingerprint = fingerprintRuntimeError(scrubbed);
|
|
13655
|
+
const inputTooLargeAttrs = runtimeErrorClass === "InputTooLargeError" ? extractInputTooLargeAttrs(rawMessage) : {};
|
|
13208
13656
|
const spanAttrs = {
|
|
13209
13657
|
turn_outcome: "failed",
|
|
13210
13658
|
turn_subtype: "runtime_error",
|
|
@@ -13215,7 +13663,8 @@ function buildRuntimeErrorDiagnosticEnvelope(message) {
|
|
|
13215
13663
|
runtime_error_fingerprint: fingerprint,
|
|
13216
13664
|
runtime_error_message_present: rawMessage.length > 0,
|
|
13217
13665
|
runtime_error_message_length_bucket: bucketLength(rawMessage.length),
|
|
13218
|
-
runtime_error_message_truncated: truncated
|
|
13666
|
+
runtime_error_message_truncated: truncated,
|
|
13667
|
+
...inputTooLargeAttrs
|
|
13219
13668
|
};
|
|
13220
13669
|
if (httpStatus !== null) {
|
|
13221
13670
|
spanAttrs.runtime_error_http_status = httpStatus;
|
|
@@ -13239,6 +13688,10 @@ function formatRuntimeStartTimeoutMessage(runtimeId) {
|
|
|
13239
13688
|
const runtimeLabel = runtimeDisplayName(runtimeId);
|
|
13240
13689
|
return `${runtimeLabel} did not finish starting on this machine. Check that ${runtimeLabel} is installed, logged in, and can run non-interactively, then retry starting this agent.`;
|
|
13241
13690
|
}
|
|
13691
|
+
function formatRuntimeInputTooLargeMessage(runtimeId) {
|
|
13692
|
+
const runtimeLabel = runtimeDisplayName(runtimeId);
|
|
13693
|
+
return `${runtimeLabel} reported input that is too large for the selected model. Reduce the current prompt or injected startup context. For a resumed session, compact it or start a new session before retrying.`;
|
|
13694
|
+
}
|
|
13242
13695
|
function scrubRuntimeErrorDiagnosticText(value) {
|
|
13243
13696
|
return value.replace(/\bBearer\s+[A-Za-z0-9._~+/=-]{8,}/gi, "Bearer [REDACTED_TOKEN]").replace(/\b(?:sk|sk-ant|sk-proj|xox[baprs]?)-[A-Za-z0-9_-]{8,}\b/g, "[REDACTED_TOKEN]").replace(/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g, "[REDACTED_EMAIL]").replace(/https?:\/\/[^\s"'<>]+/gi, (url) => redactUrlQuery(url)).replace(/\/Users\/[^\s"'<>:]+(?:\/[^\s"'<>:]+)*/g, "[REDACTED_PATH]").replace(/\/home\/[^\s"'<>:]+(?:\/[^\s"'<>:]+)*/g, "[REDACTED_PATH]").replace(/[A-Za-z]:\\Users\\[^\s"'<>:]+(?:\\[^\s"'<>:]+)*/g, "[REDACTED_PATH]");
|
|
13244
13697
|
}
|
|
@@ -13254,6 +13707,10 @@ function extractHttpStatus(message) {
|
|
|
13254
13707
|
}
|
|
13255
13708
|
function classifyRuntimeError(message, httpStatus) {
|
|
13256
13709
|
const explicit = /\b([A-Z][A-Za-z0-9_]*(?:Error|Exception))\b/.exec(message);
|
|
13710
|
+
if (explicit && /InputTooLargeError/i.test(explicit[1])) return "InputTooLargeError";
|
|
13711
|
+
if (/\bINPUT_TOO_LARGE\b/i.test(message) || /\binput too large\b/i.test(message) || /\bexceeds the maximum allowed\b/i.test(message)) {
|
|
13712
|
+
return "InputTooLargeError";
|
|
13713
|
+
}
|
|
13257
13714
|
if (explicit) return explicit[1];
|
|
13258
13715
|
if (httpStatus !== null) {
|
|
13259
13716
|
if (httpStatus === 429) return "RateLimitError";
|
|
@@ -13300,6 +13757,8 @@ function classifyRuntimeErrorReason(runtimeErrorClass) {
|
|
|
13300
13757
|
return "not_found";
|
|
13301
13758
|
case "ModelConfigError":
|
|
13302
13759
|
return "model_config_error";
|
|
13760
|
+
case "InputTooLargeError":
|
|
13761
|
+
return "input_too_large";
|
|
13303
13762
|
case "ProviderServerError":
|
|
13304
13763
|
return "provider_server_error";
|
|
13305
13764
|
case "ProviderApiError":
|
|
@@ -13308,6 +13767,34 @@ function classifyRuntimeErrorReason(runtimeErrorClass) {
|
|
|
13308
13767
|
return "unclassified_runtime_error";
|
|
13309
13768
|
}
|
|
13310
13769
|
}
|
|
13770
|
+
function extractInputTooLargeAttrs(message) {
|
|
13771
|
+
const attrs = {};
|
|
13772
|
+
const estimatedTokens = firstIntegerMatch(message, [
|
|
13773
|
+
/\bestimated\s+([\d,]+)\s+tokens?\b/i
|
|
13774
|
+
]);
|
|
13775
|
+
if (estimatedTokens !== null) attrs.runtime_input_estimated_tokens = estimatedTokens;
|
|
13776
|
+
const budgetTokens = firstIntegerMatch(message, [
|
|
13777
|
+
/\bbudget\s+([\d,]+)\b/i
|
|
13778
|
+
]);
|
|
13779
|
+
if (budgetTokens !== null) attrs.runtime_input_budget_tokens = budgetTokens;
|
|
13780
|
+
const contextLimitTokens = firstIntegerMatch(message, [
|
|
13781
|
+
/\bcontext limit\s+([\d,]+)\b/i,
|
|
13782
|
+
/\bmaximum allowed[^()]*\(([\d,]+)\)/i
|
|
13783
|
+
]);
|
|
13784
|
+
if (contextLimitTokens !== null) attrs.runtime_input_context_limit_tokens = contextLimitTokens;
|
|
13785
|
+
const model = /\bmodel\s+([A-Za-z0-9._:/+-]+)\b/i.exec(message);
|
|
13786
|
+
if (model) attrs.runtime_input_model = model[1];
|
|
13787
|
+
return attrs;
|
|
13788
|
+
}
|
|
13789
|
+
function firstIntegerMatch(message, patterns) {
|
|
13790
|
+
for (const pattern of patterns) {
|
|
13791
|
+
const match = pattern.exec(message);
|
|
13792
|
+
if (!match) continue;
|
|
13793
|
+
const parsed = Number.parseInt(match[1].replace(/,/g, ""), 10);
|
|
13794
|
+
if (Number.isSafeInteger(parsed)) return parsed;
|
|
13795
|
+
}
|
|
13796
|
+
return null;
|
|
13797
|
+
}
|
|
13311
13798
|
function runtimeDisplayName(runtimeId) {
|
|
13312
13799
|
switch (runtimeId) {
|
|
13313
13800
|
case "antigravity":
|
|
@@ -13541,6 +14028,88 @@ var RuntimeNotificationState = class {
|
|
|
13541
14028
|
}
|
|
13542
14029
|
};
|
|
13543
14030
|
|
|
14031
|
+
// src/proxyFailureTrace.ts
|
|
14032
|
+
function failureReason(input) {
|
|
14033
|
+
if (input.lifecycleInvalidContext) return "local_daemon_state_invalid";
|
|
14034
|
+
const text = `${input.errorCause ?? ""} ${input.errorMessage}`.toLowerCase();
|
|
14035
|
+
if (/enotfound|eai_again|\bdns\b/.test(text)) return "dns";
|
|
14036
|
+
if (/econnrefused|econnreset|epipe|und_err_socket|\bsocket\b|other side closed|terminated/.test(text)) return "tcp";
|
|
14037
|
+
if (/certificate|\btls\b/.test(text)) return "tls";
|
|
14038
|
+
if (/und_err_headers_timeout|und_err_body_timeout|\btimeout\b/.test(text)) return "read_timeout";
|
|
14039
|
+
if (/\bproxy\b/.test(text)) return "proxy_connect";
|
|
14040
|
+
if (/\bfly\b/.test(text)) return "fly_edge";
|
|
14041
|
+
return "unknown";
|
|
14042
|
+
}
|
|
14043
|
+
function boundedErrorClass(value) {
|
|
14044
|
+
if (value === "TypeError") return "TypeError";
|
|
14045
|
+
if (value === "AbortError") return "AbortError";
|
|
14046
|
+
if (value === "Error") return "Error";
|
|
14047
|
+
return "OtherError";
|
|
14048
|
+
}
|
|
14049
|
+
function boundedMethod(value) {
|
|
14050
|
+
const method = value.toUpperCase();
|
|
14051
|
+
return ["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"].includes(method) ? method : "OTHER";
|
|
14052
|
+
}
|
|
14053
|
+
function cannedExcerpt(reason) {
|
|
14054
|
+
switch (reason) {
|
|
14055
|
+
case "local_daemon_state_invalid":
|
|
14056
|
+
return "Local daemon lifecycle state rejected the proxy request";
|
|
14057
|
+
case "dns":
|
|
14058
|
+
return "Upstream DNS resolution failed";
|
|
14059
|
+
case "tcp":
|
|
14060
|
+
return "Upstream TCP connection failed";
|
|
14061
|
+
case "tls":
|
|
14062
|
+
return "Upstream TLS negotiation failed";
|
|
14063
|
+
case "read_timeout":
|
|
14064
|
+
return "Upstream response timed out";
|
|
14065
|
+
case "proxy_connect":
|
|
14066
|
+
return "Upstream proxy connection failed";
|
|
14067
|
+
case "fly_edge":
|
|
14068
|
+
return "Upstream edge transport failed";
|
|
14069
|
+
case "unknown":
|
|
14070
|
+
return "Proxy request failed with an unclassified cause";
|
|
14071
|
+
}
|
|
14072
|
+
}
|
|
14073
|
+
function daemonProxyFailureTraceAttrs(input) {
|
|
14074
|
+
const reason = failureReason(input);
|
|
14075
|
+
return {
|
|
14076
|
+
route_family: routeFamilyForPath(input.pathname),
|
|
14077
|
+
method: boundedMethod(input.method),
|
|
14078
|
+
outcome: "error",
|
|
14079
|
+
reason,
|
|
14080
|
+
error_class: boundedErrorClass(input.errorName),
|
|
14081
|
+
error_excerpt: cannedExcerpt(reason),
|
|
14082
|
+
...typeof input.responseStatusCode === "number" ? { response_status_code: input.responseStatusCode } : {},
|
|
14083
|
+
response_code_present: Boolean(input.responseCode)
|
|
14084
|
+
};
|
|
14085
|
+
}
|
|
14086
|
+
function daemonTransportErrorExcerpt(input) {
|
|
14087
|
+
if (input.normalizedCode === "local_daemon_state_invalid") {
|
|
14088
|
+
return "Local daemon lifecycle state rejected the proxy request";
|
|
14089
|
+
}
|
|
14090
|
+
if (input.normalizedCode === "server_5xx") return "Upstream server returned a 5xx response";
|
|
14091
|
+
switch (input.upstreamLayer) {
|
|
14092
|
+
case "dns":
|
|
14093
|
+
return "Upstream DNS resolution failed";
|
|
14094
|
+
case "tcp":
|
|
14095
|
+
return "Upstream TCP connection failed";
|
|
14096
|
+
case "tls":
|
|
14097
|
+
return "Upstream TLS negotiation failed";
|
|
14098
|
+
case "read_timeout":
|
|
14099
|
+
return "Upstream response timed out";
|
|
14100
|
+
case "proxy_connect":
|
|
14101
|
+
return "Upstream proxy connection failed";
|
|
14102
|
+
case "fly_edge":
|
|
14103
|
+
return "Upstream edge transport failed";
|
|
14104
|
+
case "body_decode_failure":
|
|
14105
|
+
return "Upstream response body could not be decoded";
|
|
14106
|
+
case "http_status":
|
|
14107
|
+
return "Upstream HTTP request failed";
|
|
14108
|
+
case "unknown":
|
|
14109
|
+
return "Proxy transport failed with an unclassified cause";
|
|
14110
|
+
}
|
|
14111
|
+
}
|
|
14112
|
+
|
|
13544
14113
|
// src/agentProcessManager.ts
|
|
13545
14114
|
var DEFAULT_MAX_CONCURRENT_AGENT_STARTS = 5;
|
|
13546
14115
|
var DEFAULT_AGENT_START_INTERVAL_MS = 500;
|
|
@@ -14846,7 +15415,8 @@ function runtimeDiagnosticTraceAttrs(event) {
|
|
|
14846
15415
|
details_present: Boolean(event.details),
|
|
14847
15416
|
path_present: Boolean(event.path),
|
|
14848
15417
|
range_present: event.range !== void 0,
|
|
14849
|
-
session_id_present: Boolean(event.sessionId)
|
|
15418
|
+
session_id_present: Boolean(event.sessionId),
|
|
15419
|
+
input_evidence: event.inputEvidence
|
|
14850
15420
|
};
|
|
14851
15421
|
}
|
|
14852
15422
|
function runtimeRecoveryTrajectoryEntry(event) {
|
|
@@ -14915,10 +15485,11 @@ function classifyTerminalFailure(ap) {
|
|
|
14915
15485
|
for (const text of candidates) {
|
|
14916
15486
|
const diagnostics = buildRuntimeErrorDiagnosticEnvelope(text);
|
|
14917
15487
|
const lower = text.toLowerCase();
|
|
14918
|
-
if (lower.includes("usage limit") || lower.includes("quota exceeded") || lower.includes("quota limit") || lower.includes("budget limit exceeded") || lower.includes("usage not included in your plan") || lower.includes("modelnotfounderror") || lower.includes("requested entity was not found") || lower.includes("model deprecated") || lower.includes("model not found") || lower.includes("model is not supported") || lower.includes("unsupported model") || /\bmodel\b.*\bnot supported\b/i.test(text) || diagnostics.spanAttrs.runtime_error_action_required === true || isProviderStreamFailureText(text) || isRuntimeStartTimeoutText(text)) {
|
|
15488
|
+
if (lower.includes("usage limit") || lower.includes("quota exceeded") || lower.includes("quota limit") || lower.includes("budget limit exceeded") || lower.includes("usage not included in your plan") || lower.includes("modelnotfounderror") || lower.includes("requested entity was not found") || lower.includes("model deprecated") || lower.includes("model not found") || lower.includes("model is not supported") || lower.includes("unsupported model") || lower.includes("codex_zero_evidence_turn_completed") || /\bmodel\b.*\bnot supported\b/i.test(text) || diagnostics.spanAttrs.runtime_error_action_required === true || diagnostics.spanAttrs.runtime_error_class === "InputTooLargeError" || isProviderStreamFailureText(text) || isRuntimeStartTimeoutText(text)) {
|
|
14919
15489
|
const actionRequired = diagnostics.spanAttrs.runtime_error_action_required === true;
|
|
15490
|
+
const inputTooLarge = diagnostics.spanAttrs.runtime_error_class === "InputTooLargeError";
|
|
14920
15491
|
return {
|
|
14921
|
-
detail: actionRequired ? formatRuntimeActionRequiredMessage(ap) : text,
|
|
15492
|
+
detail: actionRequired ? formatRuntimeActionRequiredMessage(ap) : inputTooLarge ? formatRuntimeInputTooLargeMessage(ap.driver.id) : text,
|
|
14922
15493
|
actionRequired,
|
|
14923
15494
|
...actionRequired ? { entries: buildRuntimeActionRequiredEntries(ap, text, diagnostics) } : {}
|
|
14924
15495
|
};
|
|
@@ -14930,6 +15501,7 @@ function classifyStickyTerminalFailure(ap) {
|
|
|
14930
15501
|
const terminalFailure = classifyTerminalFailure(ap);
|
|
14931
15502
|
if (!terminalFailure) return null;
|
|
14932
15503
|
if (terminalFailure.actionRequired) return terminalFailure;
|
|
15504
|
+
if (/\bcodex_zero_evidence_turn_completed\b/i.test(terminalFailure.detail)) return terminalFailure;
|
|
14933
15505
|
if (/\bmodel\b.*\bnot supported\b/i.test(terminalFailure.detail)) return terminalFailure;
|
|
14934
15506
|
if (/\bunsupported\b.*\bmodel\b/i.test(terminalFailure.detail)) return terminalFailure;
|
|
14935
15507
|
if (isProviderStreamFailureText(terminalFailure.detail)) return null;
|
|
@@ -16006,17 +16578,9 @@ var AgentProcessManager = class _AgentProcessManager {
|
|
|
16006
16578
|
};
|
|
16007
16579
|
}
|
|
16008
16580
|
recordAgentProxyFailure(agentId, input) {
|
|
16009
|
-
this.recordDaemonTrace("daemon.
|
|
16581
|
+
this.recordDaemonTrace("daemon.proxy.failed", {
|
|
16010
16582
|
agentId,
|
|
16011
|
-
|
|
16012
|
-
path: input.pathname,
|
|
16013
|
-
query_keys: input.queryKeys,
|
|
16014
|
-
error_name: input.errorName,
|
|
16015
|
-
error_message: input.errorMessage,
|
|
16016
|
-
response_status_code: input.responseStatusCode,
|
|
16017
|
-
response_code: input.responseCode,
|
|
16018
|
-
lifecycle_invalid_agent_id: input.lifecycleInvalidAgentId,
|
|
16019
|
-
lifecycle_invalid_context: input.lifecycleInvalidContext
|
|
16583
|
+
...daemonProxyFailureTraceAttrs(input)
|
|
16020
16584
|
}, "error");
|
|
16021
16585
|
}
|
|
16022
16586
|
recordAgentProxyTransportNormalizedError(agentId, input) {
|
|
@@ -16028,7 +16592,7 @@ var AgentProcessManager = class _AgentProcessManager {
|
|
|
16028
16592
|
response_started: input.responseStarted,
|
|
16029
16593
|
upstream_layer: input.upstreamLayer,
|
|
16030
16594
|
...typeof input.upstreamStatus === "number" ? { upstream_status: input.upstreamStatus } : {},
|
|
16031
|
-
|
|
16595
|
+
error_excerpt: daemonTransportErrorExcerpt(input),
|
|
16032
16596
|
launchId: input.launchId,
|
|
16033
16597
|
target_host_class: input.targetHostClass,
|
|
16034
16598
|
downstream_caller: input.downstreamCaller,
|
|
@@ -17219,8 +17783,14 @@ Use \`raft message read\` to catch up on the channels listed above, then stop. R
|
|
|
17219
17783
|
this.broadcastActivity(agentId, "error", visibleErrorMessage, [
|
|
17220
17784
|
...terminalFailure?.entries ?? [{ kind: "text", text: `Error: ${visibleErrorMessage}` }]
|
|
17221
17785
|
], agentProcess.launchId, "runtime_error");
|
|
17786
|
+
} else if (diagnostics?.spanAttrs.runtime_error_class === "InputTooLargeError") {
|
|
17787
|
+
const visibleErrorMessage = formatRuntimeInputTooLargeMessage(agentProcess.driver.id);
|
|
17788
|
+
this.broadcastActivity(agentId, "error", visibleErrorMessage, [
|
|
17789
|
+
{ kind: "text", text: `Error: ${visibleErrorMessage}` }
|
|
17790
|
+
], agentProcess.launchId, "runtime_error");
|
|
17222
17791
|
}
|
|
17223
|
-
|
|
17792
|
+
const visibleStartError = diagnostics?.spanAttrs.runtime_error_class === "InputTooLargeError" ? formatRuntimeInputTooLargeMessage(agentProcess.driver.id) : startResult.error;
|
|
17793
|
+
throw new Error(`Runtime session failed to start: ${startResult.reason}${visibleStartError ? ` (${visibleStartError})` : ""}`);
|
|
17224
17794
|
}
|
|
17225
17795
|
this.closeNoProcessResidency(agentId, "advanced");
|
|
17226
17796
|
if (this.lifecycleRecords.deleteTerminalFailure(agentId)) {
|
|
@@ -18188,57 +18758,12 @@ Use \`raft message read\` to catch up on the channels listed above, then stop. R
|
|
|
18188
18758
|
pids: pids.join(",")
|
|
18189
18759
|
});
|
|
18190
18760
|
await Promise.all(ids.map((id) => this.stopAgent(id, { wait: true, silent: true })));
|
|
18191
|
-
const
|
|
18192
|
-
|
|
18193
|
-
|
|
18194
|
-
|
|
18195
|
-
|
|
18196
|
-
|
|
18197
|
-
}
|
|
18198
|
-
});
|
|
18199
|
-
if (survivors.length > 0) {
|
|
18200
|
-
for (const pid of survivors) {
|
|
18201
|
-
logger.warn(`[Daemon] Agent subprocess ${pid} survived stopAll; sending SIGKILL`);
|
|
18202
|
-
try {
|
|
18203
|
-
process.kill(pid, "SIGKILL");
|
|
18204
|
-
} catch {
|
|
18205
|
-
}
|
|
18206
|
-
}
|
|
18207
|
-
this.recordDaemonTrace("daemon.agent.stop_all.survivor_reaped", {
|
|
18208
|
-
survivor_count: survivors.length,
|
|
18209
|
-
survivor_pids: survivors.join(","),
|
|
18210
|
-
reason: "shutdown_survivor",
|
|
18211
|
-
signal: "SIGKILL"
|
|
18212
|
-
});
|
|
18213
|
-
const deadline = Date.now() + 2e3;
|
|
18214
|
-
while (Date.now() < deadline) {
|
|
18215
|
-
const alive = survivors.filter((pid) => {
|
|
18216
|
-
try {
|
|
18217
|
-
process.kill(pid, 0);
|
|
18218
|
-
return true;
|
|
18219
|
-
} catch {
|
|
18220
|
-
return false;
|
|
18221
|
-
}
|
|
18222
|
-
});
|
|
18223
|
-
if (alive.length === 0) break;
|
|
18224
|
-
await new Promise((r) => setTimeout(r, 50));
|
|
18225
|
-
}
|
|
18226
|
-
const stillAlive = survivors.filter((pid) => {
|
|
18227
|
-
try {
|
|
18228
|
-
process.kill(pid, 0);
|
|
18229
|
-
return true;
|
|
18230
|
-
} catch {
|
|
18231
|
-
return false;
|
|
18232
|
-
}
|
|
18233
|
-
});
|
|
18234
|
-
const outcome = stillAlive.length > 0 ? "survivors_still_alive" : "survivors_killed";
|
|
18235
|
-
this.recordDaemonTrace("daemon.agent.stop_all.completed", {
|
|
18236
|
-
survivor_count: survivors.length,
|
|
18237
|
-
reaped_count: survivors.length - stillAlive.length,
|
|
18238
|
-
still_alive_count: stillAlive.length,
|
|
18239
|
-
outcome
|
|
18240
|
-
}, stillAlive.length > 0 ? "error" : "ok");
|
|
18241
|
-
} else {
|
|
18761
|
+
const reapedSurvivors = await reapOrphanProcesses(
|
|
18762
|
+
pids,
|
|
18763
|
+
logger,
|
|
18764
|
+
(name, attrs, status) => this.recordDaemonTrace(name, attrs, status)
|
|
18765
|
+
);
|
|
18766
|
+
if (!reapedSurvivors) {
|
|
18242
18767
|
this.recordDaemonTrace("daemon.agent.stop_all.completed", {
|
|
18243
18768
|
agent_count: ids.length,
|
|
18244
18769
|
survivor_count: 0,
|
|
@@ -18980,7 +19505,8 @@ Use \`raft message read\` to catch up on the channels listed above, then stop. R
|
|
|
18980
19505
|
const ap = this.agents.get(agentId);
|
|
18981
19506
|
const entries = [...extraTrajectory];
|
|
18982
19507
|
const hasToolStart = entries.some((e) => e.kind === "tool_start");
|
|
18983
|
-
|
|
19508
|
+
const isThinkingProgressFrame = activityKind === "thinking" && detail === "" && detailKind === "none" && entries.every((e) => e.kind === "thinking" || e.kind === "text");
|
|
19509
|
+
if (!hasToolStart && !isThinkingProgressFrame) {
|
|
18984
19510
|
entries.push({
|
|
18985
19511
|
kind: "status",
|
|
18986
19512
|
activity: activityKind,
|
|
@@ -19992,15 +20518,7 @@ Use \`raft message read\` to catch up on the channels listed above, then stop. R
|
|
|
19992
20518
|
return true;
|
|
19993
20519
|
}
|
|
19994
20520
|
probeRuntimeProcessLiveness(ap) {
|
|
19995
|
-
|
|
19996
|
-
if (typeof pid !== "number") return void 0;
|
|
19997
|
-
try {
|
|
19998
|
-
process.kill(pid, 0);
|
|
19999
|
-
return true;
|
|
20000
|
-
} catch (err) {
|
|
20001
|
-
const code = typeof err === "object" && err !== null && "code" in err ? err.code : void 0;
|
|
20002
|
-
return code === "EPERM" ? true : false;
|
|
20003
|
-
}
|
|
20521
|
+
return ap.runtime.isAlive();
|
|
20004
20522
|
}
|
|
20005
20523
|
recoverStaleProcessForQueuedMessageIfNeeded(agentId, ap) {
|
|
20006
20524
|
const staleForMs = ap.runtimeProgress.ageMs();
|
|
@@ -21621,7 +22139,8 @@ var DIAGNOSTIC_ID_ATTRS = /* @__PURE__ */ new Set([
|
|
|
21621
22139
|
"process_instance_id",
|
|
21622
22140
|
"launch_id",
|
|
21623
22141
|
"correlation_id",
|
|
21624
|
-
"migration_attempt_id"
|
|
22142
|
+
"migration_attempt_id",
|
|
22143
|
+
"operation_id"
|
|
21625
22144
|
]);
|
|
21626
22145
|
var DIAGNOSTIC_ERROR_ATTRS = /* @__PURE__ */ new Set([
|
|
21627
22146
|
"runtime_error_class",
|
|
@@ -22073,23 +22592,190 @@ function readPositiveIntegerEnv2(name, fallback) {
|
|
|
22073
22592
|
}
|
|
22074
22593
|
|
|
22075
22594
|
// src/computerMigrationGuard.ts
|
|
22076
|
-
import { existsSync as existsSync9, readdirSync as readdirSync6, readFileSync as
|
|
22595
|
+
import { existsSync as existsSync9, readdirSync as readdirSync6, readFileSync as readFileSync9 } from "fs";
|
|
22077
22596
|
import path18 from "path";
|
|
22597
|
+
|
|
22598
|
+
// src/legacySupervisor.ts
|
|
22599
|
+
import { execFileSync as execFileSync4 } from "child_process";
|
|
22600
|
+
import { readFileSync as readFileSync8 } from "fs";
|
|
22601
|
+
function execFileText(file, args) {
|
|
22602
|
+
try {
|
|
22603
|
+
return execFileSync4(file, args, {
|
|
22604
|
+
encoding: "utf8",
|
|
22605
|
+
timeout: 1e3,
|
|
22606
|
+
maxBuffer: 256 * 1024,
|
|
22607
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
22608
|
+
});
|
|
22609
|
+
} catch {
|
|
22610
|
+
return void 0;
|
|
22611
|
+
}
|
|
22612
|
+
}
|
|
22613
|
+
function readFileText(file) {
|
|
22614
|
+
try {
|
|
22615
|
+
return readFileSync8(file, "utf8");
|
|
22616
|
+
} catch {
|
|
22617
|
+
return void 0;
|
|
22618
|
+
}
|
|
22619
|
+
}
|
|
22620
|
+
function defaultProbe(pid) {
|
|
22621
|
+
return {
|
|
22622
|
+
pid,
|
|
22623
|
+
platform: process.platform,
|
|
22624
|
+
env: process.env,
|
|
22625
|
+
execFile: execFileText,
|
|
22626
|
+
readFile: readFileText
|
|
22627
|
+
};
|
|
22628
|
+
}
|
|
22629
|
+
function shellQuote(value) {
|
|
22630
|
+
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
22631
|
+
}
|
|
22632
|
+
function parentPid(probe, pid) {
|
|
22633
|
+
const stdout = probe.execFile("ps", ["-o", "ppid=", "-p", String(pid)]);
|
|
22634
|
+
const parsed = Number.parseInt(stdout?.trim() ?? "", 10);
|
|
22635
|
+
return Number.isInteger(parsed) && parsed > 0 ? parsed : void 0;
|
|
22636
|
+
}
|
|
22637
|
+
function processCommand(probe, pid) {
|
|
22638
|
+
return probe.execFile("ps", ["-o", "command=", "-p", String(pid)])?.trim().toLowerCase() ?? "";
|
|
22639
|
+
}
|
|
22640
|
+
function relatedProcessIds(probe) {
|
|
22641
|
+
const ids = [probe.pid];
|
|
22642
|
+
let current = probe.pid;
|
|
22643
|
+
for (let depth = 0; depth < 12; depth += 1) {
|
|
22644
|
+
const parent = parentPid(probe, current);
|
|
22645
|
+
if (!parent || ids.includes(parent)) break;
|
|
22646
|
+
ids.push(parent);
|
|
22647
|
+
if (parent === 1) break;
|
|
22648
|
+
current = parent;
|
|
22649
|
+
}
|
|
22650
|
+
return ids;
|
|
22651
|
+
}
|
|
22652
|
+
function detectPm2(probe, relatedPids) {
|
|
22653
|
+
const hasPm2Ancestor = relatedPids.slice(1).some((pid) => processCommand(probe, pid).includes("pm2"));
|
|
22654
|
+
const hasPm2Environment = Boolean(probe.env.PM2_HOME || probe.env.pm_id);
|
|
22655
|
+
if (!hasPm2Ancestor && !hasPm2Environment) return void 0;
|
|
22656
|
+
const pm2Json = probe.execFile("pm2", ["jlist"]);
|
|
22657
|
+
if (pm2Json) {
|
|
22658
|
+
try {
|
|
22659
|
+
const entries = JSON.parse(pm2Json);
|
|
22660
|
+
const entry = entries.find(
|
|
22661
|
+
(candidate) => typeof candidate.pid === "number" && relatedPids.includes(candidate.pid)
|
|
22662
|
+
);
|
|
22663
|
+
if (entry) {
|
|
22664
|
+
const name = typeof entry.name === "string" && entry.name.length > 0 ? entry.name : String(entry.pid);
|
|
22665
|
+
return {
|
|
22666
|
+
kind: "pm2",
|
|
22667
|
+
detail: `PM2 app ${JSON.stringify(name)} is supervising this legacy daemon.`,
|
|
22668
|
+
cleanupCommands: [`pm2 delete ${shellQuote(name)}`, "pm2 save"]
|
|
22669
|
+
};
|
|
22670
|
+
}
|
|
22671
|
+
} catch {
|
|
22672
|
+
}
|
|
22673
|
+
}
|
|
22674
|
+
return {
|
|
22675
|
+
kind: "pm2",
|
|
22676
|
+
detail: "PM2 is supervising this legacy daemon, but its app name could not be resolved.",
|
|
22677
|
+
cleanupCommands: ["pm2 delete <legacy-daemon-app-name>", "pm2 save"]
|
|
22678
|
+
};
|
|
22679
|
+
}
|
|
22680
|
+
function systemdUnitFromCgroup(cgroup) {
|
|
22681
|
+
if (!cgroup) return void 0;
|
|
22682
|
+
for (const line of cgroup.split("\n")) {
|
|
22683
|
+
const pathPart = line.slice(line.lastIndexOf(":") + 1);
|
|
22684
|
+
let unit;
|
|
22685
|
+
for (const segment of pathPart.split("/")) {
|
|
22686
|
+
if (segment.endsWith(".service") && segment.length > ".service".length && !/^user@\d+\.service$/.test(segment)) {
|
|
22687
|
+
unit = segment;
|
|
22688
|
+
}
|
|
22689
|
+
}
|
|
22690
|
+
if (unit) return { unit, user: pathPart.includes("/user.slice/") };
|
|
22691
|
+
}
|
|
22692
|
+
return void 0;
|
|
22693
|
+
}
|
|
22694
|
+
function detectSystemd(probe) {
|
|
22695
|
+
if (probe.platform !== "linux") return void 0;
|
|
22696
|
+
const cgroupUnit = systemdUnitFromCgroup(
|
|
22697
|
+
probe.readFile(`/proc/${probe.pid}/cgroup`)
|
|
22698
|
+
);
|
|
22699
|
+
const hasSystemdEvidence = cgroupUnit !== void 0 || probe.env.INVOCATION_ID !== void 0;
|
|
22700
|
+
if (!hasSystemdEvidence) return void 0;
|
|
22701
|
+
if (cgroupUnit) {
|
|
22702
|
+
const prefix = cgroupUnit.user ? "systemctl --user" : "sudo systemctl";
|
|
22703
|
+
return {
|
|
22704
|
+
kind: "systemd",
|
|
22705
|
+
detail: `systemd unit ${JSON.stringify(cgroupUnit.unit)} is supervising this legacy daemon.`,
|
|
22706
|
+
cleanupCommands: [
|
|
22707
|
+
`${prefix} disable --now ${shellQuote(cgroupUnit.unit)}`
|
|
22708
|
+
]
|
|
22709
|
+
};
|
|
22710
|
+
}
|
|
22711
|
+
return {
|
|
22712
|
+
kind: "systemd",
|
|
22713
|
+
detail: "systemd is supervising this legacy daemon, but its unit name could not be resolved.",
|
|
22714
|
+
cleanupCommands: [
|
|
22715
|
+
"systemctl --user disable --now <legacy-daemon-unit>.service"
|
|
22716
|
+
]
|
|
22717
|
+
};
|
|
22718
|
+
}
|
|
22719
|
+
function detectLaunchd(probe) {
|
|
22720
|
+
if (probe.platform !== "darwin") return void 0;
|
|
22721
|
+
const label = probe.env.LAUNCH_JOBKEY_LABEL || probe.env.XPC_SERVICE_NAME;
|
|
22722
|
+
if (!label || label === "0") return void 0;
|
|
22723
|
+
return {
|
|
22724
|
+
kind: "launchd",
|
|
22725
|
+
detail: `launchd job ${JSON.stringify(label)} is supervising this legacy daemon.`,
|
|
22726
|
+
cleanupCommands: [
|
|
22727
|
+
`launchctl bootout gui/$(id -u)/${shellQuote(label)}`,
|
|
22728
|
+
`rm -f ~/Library/LaunchAgents/${shellQuote(`${label}.plist`)}`
|
|
22729
|
+
]
|
|
22730
|
+
};
|
|
22731
|
+
}
|
|
22732
|
+
function detectLegacyDaemonSupervisor(pid = process.pid) {
|
|
22733
|
+
return detectLegacyDaemonSupervisorWithProbe(defaultProbe(pid));
|
|
22734
|
+
}
|
|
22735
|
+
function detectLegacyDaemonSupervisorWithProbe(probe) {
|
|
22736
|
+
const relatedPids = relatedProcessIds(probe);
|
|
22737
|
+
return detectPm2(probe, relatedPids) ?? detectSystemd(probe) ?? detectLaunchd(probe);
|
|
22738
|
+
}
|
|
22739
|
+
var legacyDaemonSupervisorFallbackCommands = [
|
|
22740
|
+
"PM2: pm2 delete <legacy-daemon-app-name> && pm2 save",
|
|
22741
|
+
"systemd: systemctl --user disable --now <legacy-daemon-unit>.service",
|
|
22742
|
+
"launchd: launchctl bootout gui/$(id -u) ~/Library/LaunchAgents/<legacy-daemon-label>.plist && rm -f ~/Library/LaunchAgents/<legacy-daemon-label>.plist"
|
|
22743
|
+
];
|
|
22744
|
+
|
|
22745
|
+
// src/computerMigrationGuard.ts
|
|
22078
22746
|
var LegacyDaemonKeyAdoptedByComputerError = class extends Error {
|
|
22079
22747
|
code = "LEGACY_DAEMON_KEY_ADOPTED_BY_COMPUTER";
|
|
22080
22748
|
attachmentPath;
|
|
22081
22749
|
serverId;
|
|
22082
|
-
constructor(match) {
|
|
22750
|
+
constructor(match, supervisor = detectLegacyDaemonSupervisor() ?? null) {
|
|
22083
22751
|
const serverDisplay = match.serverSlug ? `/${match.serverSlug}` : match.serverId;
|
|
22084
22752
|
const startCommand = match.serverSlug ? `raft-computer start /${match.serverSlug}` : "raft-computer start";
|
|
22753
|
+
const statusCommand = match.serverSlug ? `raft-computer status /${match.serverSlug}` : "raft-computer status";
|
|
22754
|
+
const supervisorGuidance = formatSupervisorGuidance(
|
|
22755
|
+
supervisor ?? void 0
|
|
22756
|
+
);
|
|
22085
22757
|
super(
|
|
22086
|
-
`
|
|
22758
|
+
`Legacy Raft daemon startup refused: this machine key was already migrated to Raft Computer for ${serverDisplay}.
|
|
22759
|
+
Raft Computer now owns this connection; do not restart raft-daemon with the migrated key.
|
|
22760
|
+
${supervisorGuidance}
|
|
22761
|
+
Then start and verify Raft Computer:
|
|
22762
|
+
${startCommand}
|
|
22763
|
+
${statusCommand}`
|
|
22087
22764
|
);
|
|
22088
22765
|
this.name = "LegacyDaemonKeyAdoptedByComputerError";
|
|
22089
22766
|
this.attachmentPath = match.attachmentPath;
|
|
22090
22767
|
this.serverId = match.serverId;
|
|
22091
22768
|
}
|
|
22092
22769
|
};
|
|
22770
|
+
function formatSupervisorGuidance(supervisor) {
|
|
22771
|
+
if (supervisor) {
|
|
22772
|
+
return `${supervisor.detail}
|
|
22773
|
+
Remove the old supervisor entry so it cannot auto-restart:
|
|
22774
|
+
` + supervisor.cleanupCommands.map((command) => ` ${command}`).join("\n");
|
|
22775
|
+
}
|
|
22776
|
+
return `If a process manager keeps restarting the old daemon, remove the entry you configured:
|
|
22777
|
+
` + legacyDaemonSupervisorFallbackCommands.map((command) => ` ${command}`).join("\n");
|
|
22778
|
+
}
|
|
22093
22779
|
function daemonApiKeyFingerprint(apiKey) {
|
|
22094
22780
|
return getDaemonMachineLockId(apiKey).slice("machine-".length);
|
|
22095
22781
|
}
|
|
@@ -22106,7 +22792,7 @@ function findAdoptedComputerForLegacyFingerprint(slockHome, legacyApiKeyFingerpr
|
|
|
22106
22792
|
const attachmentPath = path18.join(serversDir, serverId, "runner.state.json");
|
|
22107
22793
|
let raw;
|
|
22108
22794
|
try {
|
|
22109
|
-
raw =
|
|
22795
|
+
raw = readFileSync9(attachmentPath, "utf8");
|
|
22110
22796
|
} catch {
|
|
22111
22797
|
continue;
|
|
22112
22798
|
}
|
|
@@ -22128,7 +22814,10 @@ function findAdoptedComputerForLegacyFingerprint(slockHome, legacyApiKeyFingerpr
|
|
|
22128
22814
|
}
|
|
22129
22815
|
function assertLegacyDaemonKeyNotAdoptedByComputer(options) {
|
|
22130
22816
|
const legacyApiKeyFingerprint = daemonApiKeyFingerprint(options.apiKey);
|
|
22131
|
-
const match = findAdoptedComputerForLegacyFingerprint(
|
|
22817
|
+
const match = findAdoptedComputerForLegacyFingerprint(
|
|
22818
|
+
options.slockHome,
|
|
22819
|
+
legacyApiKeyFingerprint
|
|
22820
|
+
);
|
|
22132
22821
|
if (match) throw new LegacyDaemonKeyAdoptedByComputerError(match);
|
|
22133
22822
|
}
|
|
22134
22823
|
|
|
@@ -22649,8 +23338,13 @@ function onceDrain(res) {
|
|
|
22649
23338
|
|
|
22650
23339
|
// src/agentMigrationObjectStoreBundle.ts
|
|
22651
23340
|
import { createHash as createHash9 } from "crypto";
|
|
22652
|
-
import {
|
|
23341
|
+
import { createReadStream as createReadStream2, createWriteStream } from "fs";
|
|
23342
|
+
import { lstat as lstat3, mkdir as mkdir3, readlink as readlink2, rm as rm3, symlink } from "fs/promises";
|
|
22653
23343
|
import path20 from "path";
|
|
23344
|
+
import { Transform } from "stream";
|
|
23345
|
+
import { pipeline } from "stream/promises";
|
|
23346
|
+
import { createGunzip, createGzip } from "zlib";
|
|
23347
|
+
import { extract, pack } from "tar-stream";
|
|
22654
23348
|
|
|
22655
23349
|
// src/agentMigrationExport.ts
|
|
22656
23350
|
import { createHash as createHash8 } from "crypto";
|
|
@@ -22659,11 +23353,15 @@ import { lstat as lstat2, readdir as readdir4, readFile as readFile3, readlink }
|
|
|
22659
23353
|
import path19 from "path";
|
|
22660
23354
|
var AGENT_MIGRATION_BUNDLE_SCHEMA_VERSION = "agent-bundle/v1";
|
|
22661
23355
|
var REGENERABLE_DIRECTORY_NAMES = [
|
|
23356
|
+
".cache",
|
|
23357
|
+
".gradle",
|
|
23358
|
+
".pnpm-store",
|
|
22662
23359
|
".venv",
|
|
22663
23360
|
"__pycache__",
|
|
22664
23361
|
"dist",
|
|
22665
23362
|
"node_modules",
|
|
22666
|
-
"target"
|
|
23363
|
+
"target",
|
|
23364
|
+
"vendor"
|
|
22667
23365
|
];
|
|
22668
23366
|
var SECRET_FILE_NAMES = /* @__PURE__ */ new Set([
|
|
22669
23367
|
".env",
|
|
@@ -22780,9 +23478,9 @@ async function includeWorkspacePath(workspaceRelativePath, state, opts) {
|
|
|
22780
23478
|
const normalizedRelativePath = normalizeRelativePath(workspaceRelativePath);
|
|
22781
23479
|
if (state.seenWorkspacePaths.has(normalizedRelativePath)) return;
|
|
22782
23480
|
const sourcePath = path19.join(state.workspace, normalizedRelativePath);
|
|
22783
|
-
let
|
|
23481
|
+
let stat5;
|
|
22784
23482
|
try {
|
|
22785
|
-
|
|
23483
|
+
stat5 = await lstat2(sourcePath);
|
|
22786
23484
|
} catch {
|
|
22787
23485
|
state.unreachable.push({
|
|
22788
23486
|
path: normalizedRelativePath,
|
|
@@ -22791,7 +23489,7 @@ async function includeWorkspacePath(workspaceRelativePath, state, opts) {
|
|
|
22791
23489
|
});
|
|
22792
23490
|
return;
|
|
22793
23491
|
}
|
|
22794
|
-
if (
|
|
23492
|
+
if (stat5.isDirectory()) {
|
|
22795
23493
|
if (!opts.forceIncludeRegenerable && isRegenerablePath(normalizedRelativePath)) {
|
|
22796
23494
|
state.excludedRegenerable.push({
|
|
22797
23495
|
path: normalizedRelativePath,
|
|
@@ -22809,10 +23507,10 @@ async function includeWorkspacePath(workspaceRelativePath, state, opts) {
|
|
|
22809
23507
|
sourcePath,
|
|
22810
23508
|
workspaceRelativePath: normalizedRelativePath,
|
|
22811
23509
|
bundlePath: `workspace/${normalizedRelativePath}`,
|
|
22812
|
-
mode:
|
|
22813
|
-
mtimeMs:
|
|
23510
|
+
mode: stat5.mode,
|
|
23511
|
+
mtimeMs: stat5.mtimeMs
|
|
22814
23512
|
};
|
|
22815
|
-
if (
|
|
23513
|
+
if (stat5.isSymbolicLink()) {
|
|
22816
23514
|
state.files.push({
|
|
22817
23515
|
...baseEntry,
|
|
22818
23516
|
kind: "symlink",
|
|
@@ -22820,7 +23518,7 @@ async function includeWorkspacePath(workspaceRelativePath, state, opts) {
|
|
|
22820
23518
|
});
|
|
22821
23519
|
return;
|
|
22822
23520
|
}
|
|
22823
|
-
if (!
|
|
23521
|
+
if (!stat5.isFile()) {
|
|
22824
23522
|
state.unreachable.push({
|
|
22825
23523
|
path: normalizedRelativePath,
|
|
22826
23524
|
sourcePath,
|
|
@@ -22835,7 +23533,7 @@ async function includeWorkspacePath(workspaceRelativePath, state, opts) {
|
|
|
22835
23533
|
state.files.push({
|
|
22836
23534
|
...baseEntry,
|
|
22837
23535
|
kind: "file",
|
|
22838
|
-
sizeBytes:
|
|
23536
|
+
sizeBytes: stat5.size,
|
|
22839
23537
|
sha256: await sha256File(sourcePath),
|
|
22840
23538
|
secretShapes: secretShapes.length > 0 ? secretShapes : void 0
|
|
22841
23539
|
});
|
|
@@ -22854,9 +23552,9 @@ async function buildCrossTreeRefs(refs) {
|
|
|
22854
23552
|
reason: ref.reason
|
|
22855
23553
|
};
|
|
22856
23554
|
try {
|
|
22857
|
-
const
|
|
22858
|
-
if (
|
|
22859
|
-
entry.sizeBytes =
|
|
23555
|
+
const stat5 = await lstat2(sourcePath);
|
|
23556
|
+
if (stat5.isFile()) {
|
|
23557
|
+
entry.sizeBytes = stat5.size;
|
|
22860
23558
|
entry.sha256 = await sha256File(sourcePath);
|
|
22861
23559
|
}
|
|
22862
23560
|
} catch {
|
|
@@ -22974,9 +23672,22 @@ function sortByPath(entries) {
|
|
|
22974
23672
|
}
|
|
22975
23673
|
|
|
22976
23674
|
// src/agentMigrationObjectStoreBundle.ts
|
|
22977
|
-
var AGENT_MIGRATION_OBJECT_STORE_BUNDLE_SCHEMA_VERSION = "agent-object-store-
|
|
22978
|
-
var AGENT_MIGRATION_OBJECT_STORE_CONTENT_TYPE = "application/vnd.
|
|
23675
|
+
var AGENT_MIGRATION_OBJECT_STORE_BUNDLE_SCHEMA_VERSION = "agent-object-store-tar/v2";
|
|
23676
|
+
var AGENT_MIGRATION_OBJECT_STORE_CONTENT_TYPE = "application/vnd.raft.agent-migration-bundle+tar+gzip";
|
|
23677
|
+
var ARCHIVE_MANIFEST_PATH = "manifest.json";
|
|
23678
|
+
var ARCHIVE_WORKSPACE_PREFIX = "workspace/";
|
|
23679
|
+
var MAX_ARCHIVE_MANIFEST_BYTES = 64 * 1024 * 1024;
|
|
23680
|
+
var AgentMigrationObjectStoreBundleTooLargeError = class extends Error {
|
|
23681
|
+
constructor(actualBytes, maxBytes) {
|
|
23682
|
+
super(`MIGRATION_OBJECT_STORE_BUNDLE_TOO_LARGE:actualBytes=${actualBytes}:maxBytes=${maxBytes}`);
|
|
23683
|
+
this.actualBytes = actualBytes;
|
|
23684
|
+
this.maxBytes = maxBytes;
|
|
23685
|
+
this.name = "AgentMigrationObjectStoreBundleTooLargeError";
|
|
23686
|
+
}
|
|
23687
|
+
code = "MIGRATION_OBJECT_STORE_BUNDLE_TOO_LARGE";
|
|
23688
|
+
};
|
|
22979
23689
|
async function buildAgentMigrationObjectStoreBundle(input) {
|
|
23690
|
+
assertPositiveMaxBytes(input.maxBytes);
|
|
22980
23691
|
const workspacePath = path20.resolve(input.workspacePath);
|
|
22981
23692
|
const manifest = await buildAgentMigrationExportManifest({
|
|
22982
23693
|
agentId: input.agentId,
|
|
@@ -22984,45 +23695,32 @@ async function buildAgentMigrationObjectStoreBundle(input) {
|
|
|
22984
23695
|
workspacePath,
|
|
22985
23696
|
mode: "forensic"
|
|
22986
23697
|
});
|
|
22987
|
-
const
|
|
22988
|
-
|
|
22989
|
-
if (entry.source !== "workspace" || !entry.workspaceRelativePath) {
|
|
22990
|
-
throw new Error("MIGRATION_OBJECT_STORE_UNSUPPORTED_ENTRY");
|
|
22991
|
-
}
|
|
22992
|
-
const sourcePath = path20.resolve(entry.sourcePath);
|
|
22993
|
-
if (entry.kind === "symlink") {
|
|
22994
|
-
files.push({
|
|
22995
|
-
kind: "symlink",
|
|
22996
|
-
workspaceRelativePath: normalizeWorkspaceRelativePath(entry.workspaceRelativePath),
|
|
22997
|
-
linkTarget: entry.linkTarget ?? await readlink2(sourcePath)
|
|
22998
|
-
});
|
|
22999
|
-
continue;
|
|
23000
|
-
}
|
|
23001
|
-
const stat4 = await lstat3(sourcePath);
|
|
23002
|
-
if (!stat4.isFile()) throw new Error("MIGRATION_OBJECT_STORE_FILE_KIND_MISMATCH");
|
|
23003
|
-
files.push({
|
|
23004
|
-
kind: "file",
|
|
23005
|
-
workspaceRelativePath: normalizeWorkspaceRelativePath(entry.workspaceRelativePath),
|
|
23006
|
-
contentBase64: (await readFile4(sourcePath)).toString("base64")
|
|
23007
|
-
});
|
|
23008
|
-
}
|
|
23009
|
-
const payload = {
|
|
23698
|
+
const contentBytes = assertAgentMigrationObjectStoreBundleSize(manifest, input.maxBytes);
|
|
23699
|
+
const archiveManifest = {
|
|
23010
23700
|
schemaVersion: AGENT_MIGRATION_OBJECT_STORE_BUNDLE_SCHEMA_VERSION,
|
|
23011
|
-
manifest
|
|
23012
|
-
files
|
|
23701
|
+
manifest
|
|
23013
23702
|
};
|
|
23014
|
-
const
|
|
23703
|
+
const manifestBuffer = Buffer.from(`${canonicalJson2(archiveManifest)}
|
|
23015
23704
|
`, "utf8");
|
|
23016
|
-
if (
|
|
23017
|
-
throw new Error("
|
|
23018
|
-
}
|
|
23705
|
+
if (manifestBuffer.byteLength > MAX_ARCHIVE_MANIFEST_BYTES) {
|
|
23706
|
+
throw new Error("MIGRATION_OBJECT_STORE_MANIFEST_TOO_LARGE");
|
|
23707
|
+
}
|
|
23708
|
+
const tarPack = pack();
|
|
23709
|
+
const gzip = createGzip();
|
|
23710
|
+
const bundle = tarPack.pipe(gzip);
|
|
23711
|
+
tarPack.on("error", (error) => gzip.destroy(error));
|
|
23712
|
+
void writeArchive(tarPack, manifestBuffer, manifest, workspacePath).catch((error) => {
|
|
23713
|
+
tarPack.destroy(error instanceof Error ? error : new Error(String(error)));
|
|
23714
|
+
});
|
|
23019
23715
|
return {
|
|
23020
23716
|
bundle,
|
|
23021
|
-
|
|
23717
|
+
manifest,
|
|
23718
|
+
manifestSha256: sha256Buffer2(Buffer.from(canonicalJson2(manifest), "utf8")),
|
|
23719
|
+
contentBytes
|
|
23022
23720
|
};
|
|
23023
23721
|
}
|
|
23024
23722
|
async function stageAgentMigrationObjectStoreBundle(input) {
|
|
23025
|
-
|
|
23723
|
+
assertPositiveMaxBytes(input.maxBytes);
|
|
23026
23724
|
const stagingWorkspacePath = path20.join(
|
|
23027
23725
|
path20.resolve(input.slockHome),
|
|
23028
23726
|
"migrations",
|
|
@@ -23031,45 +23729,198 @@ async function stageAgentMigrationObjectStoreBundle(input) {
|
|
|
23031
23729
|
);
|
|
23032
23730
|
await rm3(stagingWorkspacePath, { recursive: true, force: true });
|
|
23033
23731
|
await mkdir3(stagingWorkspacePath, { recursive: true });
|
|
23034
|
-
|
|
23035
|
-
|
|
23036
|
-
|
|
23037
|
-
|
|
23038
|
-
|
|
23039
|
-
|
|
23040
|
-
|
|
23732
|
+
let archiveManifest = null;
|
|
23733
|
+
let expectedEntries = /* @__PURE__ */ new Map();
|
|
23734
|
+
const extractedEntries = /* @__PURE__ */ new Set();
|
|
23735
|
+
let contentBytes = 0;
|
|
23736
|
+
const tarExtract = extract();
|
|
23737
|
+
tarExtract.on("entry", (header, stream, next) => {
|
|
23738
|
+
void handleArchiveEntry({
|
|
23739
|
+
header,
|
|
23740
|
+
stream,
|
|
23741
|
+
stagingWorkspacePath,
|
|
23742
|
+
maxBytes: input.maxBytes,
|
|
23743
|
+
getArchiveManifest: () => archiveManifest,
|
|
23744
|
+
setArchiveManifest: (value) => {
|
|
23745
|
+
archiveManifest = value;
|
|
23746
|
+
expectedEntries = expectedWorkspaceEntries(value.manifest);
|
|
23747
|
+
},
|
|
23748
|
+
getExpectedEntries: () => expectedEntries,
|
|
23749
|
+
extractedEntries,
|
|
23750
|
+
addContentBytes: (value) => {
|
|
23751
|
+
contentBytes += value;
|
|
23752
|
+
if (contentBytes > input.maxBytes) {
|
|
23753
|
+
throw new AgentMigrationObjectStoreBundleTooLargeError(contentBytes, input.maxBytes);
|
|
23754
|
+
}
|
|
23755
|
+
}
|
|
23756
|
+
}).then(() => next(), next);
|
|
23757
|
+
});
|
|
23758
|
+
try {
|
|
23759
|
+
await pipeline(input.bundle, createGunzip(), tarExtract);
|
|
23760
|
+
const completedManifest = archiveManifest;
|
|
23761
|
+
if (!completedManifest) throw new Error("MIGRATION_OBJECT_STORE_MANIFEST_MISSING");
|
|
23762
|
+
for (const relativePath of expectedEntries.keys()) {
|
|
23763
|
+
if (!extractedEntries.has(relativePath)) {
|
|
23764
|
+
throw new Error(`MIGRATION_OBJECT_STORE_ARCHIVE_ENTRY_MISSING:${relativePath}`);
|
|
23765
|
+
}
|
|
23766
|
+
}
|
|
23767
|
+
return {
|
|
23768
|
+
manifest: completedManifest.manifest,
|
|
23769
|
+
manifestSha256: sha256Buffer2(
|
|
23770
|
+
Buffer.from(canonicalJson2(completedManifest.manifest), "utf8")
|
|
23771
|
+
),
|
|
23772
|
+
stagingWorkspacePath,
|
|
23773
|
+
contentBytes
|
|
23774
|
+
};
|
|
23775
|
+
} catch (error) {
|
|
23776
|
+
await rm3(stagingWorkspacePath, { recursive: true, force: true });
|
|
23777
|
+
throw error;
|
|
23778
|
+
}
|
|
23779
|
+
}
|
|
23780
|
+
async function writeArchive(tarPack, manifestBuffer, manifest, workspacePath) {
|
|
23781
|
+
await writeBufferedEntry(tarPack, {
|
|
23782
|
+
name: ARCHIVE_MANIFEST_PATH,
|
|
23783
|
+
type: "file",
|
|
23784
|
+
size: manifestBuffer.byteLength,
|
|
23785
|
+
mode: 384,
|
|
23786
|
+
mtime: new Date(manifest.createdAt)
|
|
23787
|
+
}, manifestBuffer);
|
|
23788
|
+
for (const entry of manifest.files) {
|
|
23789
|
+
if (entry.source !== "workspace" || !entry.workspaceRelativePath) {
|
|
23790
|
+
throw new Error("MIGRATION_OBJECT_STORE_UNSUPPORTED_ENTRY");
|
|
23791
|
+
}
|
|
23792
|
+
const relativePath = normalizeWorkspaceRelativePath(entry.workspaceRelativePath);
|
|
23793
|
+
const sourcePath = path20.resolve(entry.sourcePath);
|
|
23794
|
+
const archivePath = `${ARCHIVE_WORKSPACE_PREFIX}${relativePath}`;
|
|
23795
|
+
if (entry.kind === "symlink") {
|
|
23796
|
+
await writeBufferedEntry(tarPack, {
|
|
23797
|
+
name: archivePath,
|
|
23798
|
+
type: "symlink",
|
|
23799
|
+
size: 0,
|
|
23800
|
+
mode: archiveMode(entry.mode),
|
|
23801
|
+
mtime: archiveMtime(entry.mtimeMs),
|
|
23802
|
+
linkname: entry.linkTarget ?? await readlink2(sourcePath)
|
|
23803
|
+
}, Buffer.alloc(0));
|
|
23041
23804
|
continue;
|
|
23042
23805
|
}
|
|
23043
|
-
|
|
23044
|
-
|
|
23806
|
+
const stat5 = await lstat3(sourcePath);
|
|
23807
|
+
if (!stat5.isFile() || stat5.size !== entry.sizeBytes) {
|
|
23808
|
+
throw new Error(`MIGRATION_OBJECT_STORE_FILE_CHANGED:${relativePath}`);
|
|
23045
23809
|
}
|
|
23046
|
-
|
|
23810
|
+
const tarEntry = tarPack.entry({
|
|
23811
|
+
name: archivePath,
|
|
23812
|
+
type: "file",
|
|
23813
|
+
size: stat5.size,
|
|
23814
|
+
mode: archiveMode(entry.mode),
|
|
23815
|
+
mtime: archiveMtime(entry.mtimeMs)
|
|
23816
|
+
});
|
|
23817
|
+
await pipeline(createReadStream2(sourcePath), tarEntry);
|
|
23818
|
+
}
|
|
23819
|
+
tarPack.finalize();
|
|
23820
|
+
}
|
|
23821
|
+
async function handleArchiveEntry(input) {
|
|
23822
|
+
if (input.header.name === ARCHIVE_MANIFEST_PATH) {
|
|
23823
|
+
if (input.getArchiveManifest()) throw new Error("MIGRATION_OBJECT_STORE_MANIFEST_DUPLICATE");
|
|
23824
|
+
if (input.header.type !== "file") throw new Error("MIGRATION_OBJECT_STORE_MANIFEST_INVALID");
|
|
23825
|
+
const manifestBuffer = await readEntryBuffer(input.stream, MAX_ARCHIVE_MANIFEST_BYTES);
|
|
23826
|
+
input.setArchiveManifest(parseArchiveManifest(manifestBuffer));
|
|
23827
|
+
return;
|
|
23828
|
+
}
|
|
23829
|
+
const archiveManifest = input.getArchiveManifest();
|
|
23830
|
+
if (!archiveManifest) throw new Error("MIGRATION_OBJECT_STORE_MANIFEST_MUST_BE_FIRST");
|
|
23831
|
+
if (!input.header.name.startsWith(ARCHIVE_WORKSPACE_PREFIX)) {
|
|
23832
|
+
throw new Error("MIGRATION_OBJECT_STORE_ARCHIVE_ENTRY_UNEXPECTED");
|
|
23833
|
+
}
|
|
23834
|
+
const relativePath = normalizeWorkspaceRelativePath(
|
|
23835
|
+
input.header.name.slice(ARCHIVE_WORKSPACE_PREFIX.length)
|
|
23836
|
+
);
|
|
23837
|
+
if (input.extractedEntries.has(relativePath)) {
|
|
23838
|
+
throw new Error(`MIGRATION_OBJECT_STORE_ARCHIVE_ENTRY_DUPLICATE:${relativePath}`);
|
|
23839
|
+
}
|
|
23840
|
+
const expected = input.getExpectedEntries().get(relativePath);
|
|
23841
|
+
if (!expected) throw new Error(`MIGRATION_OBJECT_STORE_ARCHIVE_ENTRY_UNEXPECTED:${relativePath}`);
|
|
23842
|
+
input.extractedEntries.add(relativePath);
|
|
23843
|
+
const targetPath = path20.join(input.stagingWorkspacePath, relativePath);
|
|
23844
|
+
await mkdir3(path20.dirname(targetPath), { recursive: true });
|
|
23845
|
+
if (expected.kind === "symlink") {
|
|
23846
|
+
if (input.header.type !== "symlink" || input.header.linkname !== expected.linkTarget) {
|
|
23847
|
+
throw new Error(`MIGRATION_OBJECT_STORE_LINK_TARGET_MISMATCH:${relativePath}`);
|
|
23848
|
+
}
|
|
23849
|
+
await drainEntry(input.stream);
|
|
23850
|
+
await symlink(expected.linkTarget ?? "", targetPath);
|
|
23851
|
+
return;
|
|
23852
|
+
}
|
|
23853
|
+
if (input.header.type !== "file" || input.header.size !== expected.sizeBytes) {
|
|
23854
|
+
throw new Error(`MIGRATION_OBJECT_STORE_FILE_SIZE_MISMATCH:${relativePath}`);
|
|
23855
|
+
}
|
|
23856
|
+
input.addContentBytes(input.header.size ?? 0);
|
|
23857
|
+
const hash = createHash9("sha256");
|
|
23858
|
+
const hashPassThrough = new Transform({
|
|
23859
|
+
transform(chunk, _encoding, callback) {
|
|
23860
|
+
hash.update(chunk);
|
|
23861
|
+
callback(null, chunk);
|
|
23862
|
+
}
|
|
23863
|
+
});
|
|
23864
|
+
await pipeline(
|
|
23865
|
+
input.stream,
|
|
23866
|
+
hashPassThrough,
|
|
23867
|
+
createWriteStream(targetPath, { mode: archiveMode(expected.mode) })
|
|
23868
|
+
);
|
|
23869
|
+
if (expected.sha256 && hash.digest("hex") !== expected.sha256) {
|
|
23870
|
+
throw new Error(`MIGRATION_OBJECT_STORE_FILE_HASH_MISMATCH:${relativePath}`);
|
|
23047
23871
|
}
|
|
23048
|
-
return {
|
|
23049
|
-
manifest: parsed.manifest,
|
|
23050
|
-
manifestSha256: sha256Buffer2(Buffer.from(canonicalJson2(parsed.manifest), "utf8")),
|
|
23051
|
-
stagingWorkspacePath
|
|
23052
|
-
};
|
|
23053
23872
|
}
|
|
23054
|
-
function
|
|
23873
|
+
function parseArchiveManifest(buffer) {
|
|
23055
23874
|
let parsed;
|
|
23056
23875
|
try {
|
|
23057
23876
|
parsed = JSON.parse(buffer.toString("utf8"));
|
|
23058
23877
|
} catch {
|
|
23059
|
-
throw new Error("
|
|
23878
|
+
throw new Error("MIGRATION_OBJECT_STORE_MANIFEST_INVALID_JSON");
|
|
23060
23879
|
}
|
|
23061
23880
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
23062
|
-
throw new Error("
|
|
23881
|
+
throw new Error("MIGRATION_OBJECT_STORE_MANIFEST_INVALID");
|
|
23063
23882
|
}
|
|
23064
|
-
const
|
|
23065
|
-
if (
|
|
23883
|
+
const archiveManifest = parsed;
|
|
23884
|
+
if (archiveManifest.schemaVersion !== AGENT_MIGRATION_OBJECT_STORE_BUNDLE_SCHEMA_VERSION) {
|
|
23066
23885
|
throw new Error("MIGRATION_OBJECT_STORE_BUNDLE_SCHEMA_UNSUPPORTED");
|
|
23067
23886
|
}
|
|
23068
|
-
if (!
|
|
23069
|
-
throw new Error("
|
|
23887
|
+
if (!archiveManifest.manifest || typeof archiveManifest.manifest !== "object" || Array.isArray(archiveManifest.manifest) || archiveManifest.manifest.schemaVersion !== AGENT_MIGRATION_BUNDLE_SCHEMA_VERSION || !Array.isArray(archiveManifest.manifest.files)) {
|
|
23888
|
+
throw new Error("MIGRATION_OBJECT_STORE_MANIFEST_INVALID");
|
|
23070
23889
|
}
|
|
23071
|
-
|
|
23072
|
-
|
|
23890
|
+
return archiveManifest;
|
|
23891
|
+
}
|
|
23892
|
+
function expectedWorkspaceEntries(manifest) {
|
|
23893
|
+
const result = /* @__PURE__ */ new Map();
|
|
23894
|
+
for (const entry of manifest.files) {
|
|
23895
|
+
if (entry.source !== "workspace" || !entry.workspaceRelativePath) {
|
|
23896
|
+
throw new Error("MIGRATION_OBJECT_STORE_UNSUPPORTED_ENTRY");
|
|
23897
|
+
}
|
|
23898
|
+
const relativePath = normalizeWorkspaceRelativePath(entry.workspaceRelativePath);
|
|
23899
|
+
if (result.has(relativePath)) {
|
|
23900
|
+
throw new Error(`MIGRATION_OBJECT_STORE_MANIFEST_ENTRY_DUPLICATE:${relativePath}`);
|
|
23901
|
+
}
|
|
23902
|
+
result.set(relativePath, entry);
|
|
23903
|
+
}
|
|
23904
|
+
return result;
|
|
23905
|
+
}
|
|
23906
|
+
function assertAgentMigrationObjectStoreBundleSize(manifest, maxBytes) {
|
|
23907
|
+
assertPositiveMaxBytes(maxBytes);
|
|
23908
|
+
let total = 0;
|
|
23909
|
+
for (const entry of manifest.files) {
|
|
23910
|
+
if (entry.source !== "workspace" || !entry.workspaceRelativePath) {
|
|
23911
|
+
throw new Error("MIGRATION_OBJECT_STORE_UNSUPPORTED_ENTRY");
|
|
23912
|
+
}
|
|
23913
|
+
if (entry.kind !== "file") continue;
|
|
23914
|
+
if (!Number.isSafeInteger(entry.sizeBytes) || (entry.sizeBytes ?? -1) < 0) {
|
|
23915
|
+
throw new Error("MIGRATION_OBJECT_STORE_FILE_SIZE_INVALID");
|
|
23916
|
+
}
|
|
23917
|
+
total += entry.sizeBytes ?? 0;
|
|
23918
|
+
if (!Number.isSafeInteger(total)) throw new Error("MIGRATION_OBJECT_STORE_FILE_SIZE_INVALID");
|
|
23919
|
+
}
|
|
23920
|
+
if (total > maxBytes) {
|
|
23921
|
+
throw new AgentMigrationObjectStoreBundleTooLargeError(total, maxBytes);
|
|
23922
|
+
}
|
|
23923
|
+
return total;
|
|
23073
23924
|
}
|
|
23074
23925
|
function normalizeWorkspaceRelativePath(relativePath) {
|
|
23075
23926
|
const normalized = path20.posix.normalize(relativePath.replaceAll("\\", "/"));
|
|
@@ -23078,6 +23929,40 @@ function normalizeWorkspaceRelativePath(relativePath) {
|
|
|
23078
23929
|
}
|
|
23079
23930
|
return normalized;
|
|
23080
23931
|
}
|
|
23932
|
+
function writeBufferedEntry(tarPack, header, buffer) {
|
|
23933
|
+
return new Promise((resolve, reject) => {
|
|
23934
|
+
tarPack.entry(header, buffer, (error) => {
|
|
23935
|
+
if (error) reject(error);
|
|
23936
|
+
else resolve();
|
|
23937
|
+
});
|
|
23938
|
+
});
|
|
23939
|
+
}
|
|
23940
|
+
async function readEntryBuffer(stream, maxBytes) {
|
|
23941
|
+
const chunks = [];
|
|
23942
|
+
let total = 0;
|
|
23943
|
+
for await (const chunk of stream) {
|
|
23944
|
+
const buffer = Buffer.from(chunk);
|
|
23945
|
+
total += buffer.byteLength;
|
|
23946
|
+
if (total > maxBytes) throw new Error("MIGRATION_OBJECT_STORE_MANIFEST_TOO_LARGE");
|
|
23947
|
+
chunks.push(buffer);
|
|
23948
|
+
}
|
|
23949
|
+
return Buffer.concat(chunks, total);
|
|
23950
|
+
}
|
|
23951
|
+
async function drainEntry(stream) {
|
|
23952
|
+
for await (const _chunk of stream) {
|
|
23953
|
+
}
|
|
23954
|
+
}
|
|
23955
|
+
function assertPositiveMaxBytes(maxBytes) {
|
|
23956
|
+
if (!Number.isSafeInteger(maxBytes) || maxBytes <= 0) {
|
|
23957
|
+
throw new Error("MIGRATION_OBJECT_STORE_MAX_BYTES_INVALID");
|
|
23958
|
+
}
|
|
23959
|
+
}
|
|
23960
|
+
function archiveMode(mode) {
|
|
23961
|
+
return typeof mode === "number" ? mode & 511 : 384;
|
|
23962
|
+
}
|
|
23963
|
+
function archiveMtime(mtimeMs) {
|
|
23964
|
+
return typeof mtimeMs === "number" && Number.isFinite(mtimeMs) ? new Date(mtimeMs) : /* @__PURE__ */ new Date(0);
|
|
23965
|
+
}
|
|
23081
23966
|
function canonicalJson2(value) {
|
|
23082
23967
|
return JSON.stringify(sortJsonValue2(value));
|
|
23083
23968
|
}
|
|
@@ -23098,8 +23983,8 @@ function sanitizePathSegment(value) {
|
|
|
23098
23983
|
|
|
23099
23984
|
// src/agentMigrationImport.ts
|
|
23100
23985
|
import { createHash as createHash10 } from "crypto";
|
|
23101
|
-
import { createReadStream as
|
|
23102
|
-
import { access as access2, cp, lstat as lstat4, mkdir as mkdir4, readlink as readlink3, rename, writeFile as
|
|
23986
|
+
import { createReadStream as createReadStream3 } from "fs";
|
|
23987
|
+
import { access as access2, cp, lstat as lstat4, mkdir as mkdir4, readlink as readlink3, rename, writeFile as writeFile3 } from "fs/promises";
|
|
23103
23988
|
import path21 from "path";
|
|
23104
23989
|
async function buildAgentMigrationAdoptPlan(input) {
|
|
23105
23990
|
const slockHome = path21.resolve(input.slockHome);
|
|
@@ -23288,19 +24173,25 @@ async function placeWorkspace(sourceWorkspacePath, finalWorkspacePath) {
|
|
|
23288
24173
|
if (path21.resolve(sourceWorkspacePath) === path21.resolve(finalWorkspacePath)) return;
|
|
23289
24174
|
const stagingPath = `${finalWorkspacePath}.migration-${process.pid}-${Date.now()}`;
|
|
23290
24175
|
await mkdir4(path21.dirname(finalWorkspacePath), { recursive: true });
|
|
23291
|
-
await cp(sourceWorkspacePath, stagingPath, {
|
|
24176
|
+
await cp(sourceWorkspacePath, stagingPath, {
|
|
24177
|
+
recursive: true,
|
|
24178
|
+
dereference: false,
|
|
24179
|
+
verbatimSymlinks: true,
|
|
24180
|
+
errorOnExist: true,
|
|
24181
|
+
force: false
|
|
24182
|
+
});
|
|
23292
24183
|
await rename(stagingPath, finalWorkspacePath);
|
|
23293
24184
|
}
|
|
23294
24185
|
async function writeArrivalReport(reportPath, report) {
|
|
23295
24186
|
const payload = `${canonicalJson3(report)}
|
|
23296
24187
|
`;
|
|
23297
24188
|
await mkdir4(path21.dirname(reportPath), { recursive: true });
|
|
23298
|
-
await
|
|
24189
|
+
await writeFile3(reportPath, payload, { mode: 384 });
|
|
23299
24190
|
return sha256Buffer3(Buffer.from(payload, "utf8"));
|
|
23300
24191
|
}
|
|
23301
24192
|
async function sha256File2(filePath) {
|
|
23302
24193
|
const hash = createHash10("sha256");
|
|
23303
|
-
const stream =
|
|
24194
|
+
const stream = createReadStream3(filePath);
|
|
23304
24195
|
for await (const chunk of stream) {
|
|
23305
24196
|
hash.update(chunk);
|
|
23306
24197
|
}
|
|
@@ -23325,10 +24216,10 @@ function sanitizePathSegment2(value) {
|
|
|
23325
24216
|
}
|
|
23326
24217
|
|
|
23327
24218
|
// src/secretFile.ts
|
|
23328
|
-
import { chmodSync, mkdirSync as mkdirSync7, readFileSync as
|
|
24219
|
+
import { chmodSync as chmodSync2, mkdirSync as mkdirSync7, readFileSync as readFileSync10, writeFileSync as writeFileSync7 } from "fs";
|
|
23329
24220
|
import path22 from "path";
|
|
23330
24221
|
function readSecretFileSync(filePath) {
|
|
23331
|
-
return
|
|
24222
|
+
return readFileSync10(filePath, "utf8").trim();
|
|
23332
24223
|
}
|
|
23333
24224
|
|
|
23334
24225
|
// src/core.ts
|
|
@@ -23400,7 +24291,10 @@ var DAEMON_CORE_TRACE_ATTR_CONTRACTS = {
|
|
|
23400
24291
|
endAttrs: ["outcome", "error_class"]
|
|
23401
24292
|
},
|
|
23402
24293
|
"daemon.computer_control.received": {
|
|
23403
|
-
spanAttrs: ["action", "handled"]
|
|
24294
|
+
spanAttrs: ["action", "handled", "operation_id", "request_id"]
|
|
24295
|
+
},
|
|
24296
|
+
"daemon.computer_control.replayed": {
|
|
24297
|
+
spanAttrs: ["action", "operation_id", "outcome"]
|
|
23404
24298
|
},
|
|
23405
24299
|
"daemon.ready.sent": {
|
|
23406
24300
|
spanAttrs: ["runtimes_count", "running_agents_count", "idle_agents_count", "runtime_profile_reports_count"]
|
|
@@ -23439,6 +24333,28 @@ var DAEMON_CORE_TRACE_ATTR_CONTRACTS = {
|
|
|
23439
24333
|
"daemon.connection.local_disconnect_observed": {
|
|
23440
24334
|
spanAttrs: ["running_agents_count", "idle_agents_count"]
|
|
23441
24335
|
},
|
|
24336
|
+
"daemon.migration_transport.object_store": {
|
|
24337
|
+
spanAttrs: [
|
|
24338
|
+
"outcome",
|
|
24339
|
+
"role",
|
|
24340
|
+
"transfer_kind",
|
|
24341
|
+
"agent_id_present",
|
|
24342
|
+
"migration_id_present",
|
|
24343
|
+
"session_id_present",
|
|
24344
|
+
"error_class",
|
|
24345
|
+
"endpoint_class",
|
|
24346
|
+
"http_status",
|
|
24347
|
+
"content_length_present",
|
|
24348
|
+
"upload_body_mode",
|
|
24349
|
+
"bundle_size_bucket",
|
|
24350
|
+
"bundle_content_bytes",
|
|
24351
|
+
"max_bytes",
|
|
24352
|
+
"manifest_sha_present",
|
|
24353
|
+
"attempt",
|
|
24354
|
+
"status",
|
|
24355
|
+
"retry_delay_ms"
|
|
24356
|
+
]
|
|
24357
|
+
},
|
|
23442
24358
|
"daemon.agent.activity.produced": {
|
|
23443
24359
|
// isHeartbeat/is_heartbeat (#460 V1) and process_instance_id (#460 V3)
|
|
23444
24360
|
// were emitted by agentProcessManager but scrubbed here (pilot violation
|
|
@@ -23505,6 +24421,36 @@ function migrationTransferFailureMessage(err) {
|
|
|
23505
24421
|
const message = err instanceof Error ? err.message : String(err);
|
|
23506
24422
|
return message.slice(0, 500);
|
|
23507
24423
|
}
|
|
24424
|
+
function migrationTransferFailureCode(err) {
|
|
24425
|
+
return err instanceof AgentMigrationObjectStoreBundleTooLargeError ? err.code : void 0;
|
|
24426
|
+
}
|
|
24427
|
+
var MigrationObjectStoreUploadHttpError = class extends Error {
|
|
24428
|
+
constructor(status, archiveBytes) {
|
|
24429
|
+
super(`MIGRATION_OBJECT_STORE_UPLOAD_FAILED:${status}`);
|
|
24430
|
+
this.status = status;
|
|
24431
|
+
this.archiveBytes = archiveBytes;
|
|
24432
|
+
this.name = "MigrationObjectStoreUploadHttpError";
|
|
24433
|
+
}
|
|
24434
|
+
};
|
|
24435
|
+
function migrationObjectStoreFailureTraceAttrs(err) {
|
|
24436
|
+
if (!(err instanceof MigrationObjectStoreUploadHttpError)) return {};
|
|
24437
|
+
return {
|
|
24438
|
+
endpoint_class: "object_store",
|
|
24439
|
+
http_status: err.status,
|
|
24440
|
+
content_length_present: true,
|
|
24441
|
+
upload_body_mode: "spooled_file",
|
|
24442
|
+
bundle_size_bucket: migrationObjectStoreBundleSizeBucket(err.archiveBytes)
|
|
24443
|
+
};
|
|
24444
|
+
}
|
|
24445
|
+
function migrationObjectStoreBundleSizeBucket(bytes) {
|
|
24446
|
+
if (bytes < 1024 * 1024) return "lt_1_mib";
|
|
24447
|
+
if (bytes < 16 * 1024 * 1024) return "1_to_16_mib";
|
|
24448
|
+
if (bytes < 128 * 1024 * 1024) return "16_to_128_mib";
|
|
24449
|
+
if (bytes < 512 * 1024 * 1024) return "128_to_512_mib";
|
|
24450
|
+
if (bytes < 1024 * 1024 * 1024) return "512_mib_to_1_gib";
|
|
24451
|
+
if (bytes < 3 * 1024 * 1024 * 1024) return "1_to_3_gib";
|
|
24452
|
+
return "gte_3_gib";
|
|
24453
|
+
}
|
|
23508
24454
|
async function migrationStepErrorSuffix(response) {
|
|
23509
24455
|
try {
|
|
23510
24456
|
const body = await response.clone().json();
|
|
@@ -23534,6 +24480,8 @@ function parseDaemonCliArgs(args) {
|
|
|
23534
24480
|
return { serverUrl, apiKey };
|
|
23535
24481
|
}
|
|
23536
24482
|
function readDaemonVersion(moduleUrl = import.meta.url) {
|
|
24483
|
+
const baked = process.env.RAFT_DAEMON_VERSION;
|
|
24484
|
+
if (typeof baked === "string" && baked.length > 0) return baked;
|
|
23537
24485
|
try {
|
|
23538
24486
|
const require2 = createRequire3(moduleUrl);
|
|
23539
24487
|
return require2("../package.json").version;
|
|
@@ -23562,7 +24510,7 @@ function resolveSlockCliPathOrEmpty(moduleUrl = import.meta.url) {
|
|
|
23562
24510
|
}
|
|
23563
24511
|
async function runBundledSlockCli(argv) {
|
|
23564
24512
|
process.argv = [process.execPath, "slock", ...argv];
|
|
23565
|
-
await import("./dist-
|
|
24513
|
+
await import("./dist-6QZ4QRGY.js");
|
|
23566
24514
|
}
|
|
23567
24515
|
function detectRuntimes(tracer = noopTracer) {
|
|
23568
24516
|
const ids = [];
|
|
@@ -23740,6 +24688,7 @@ var DaemonCore = class {
|
|
|
23740
24688
|
traceBundleUploader = null;
|
|
23741
24689
|
coreStartingAgentIds = /* @__PURE__ */ new Set();
|
|
23742
24690
|
coreStartPendingDeliveries = /* @__PURE__ */ new Map();
|
|
24691
|
+
handledComputerControlOperationIds = /* @__PURE__ */ new Set();
|
|
23743
24692
|
constructor(options) {
|
|
23744
24693
|
this.options = options;
|
|
23745
24694
|
this.daemonVersion = options.daemonVersion ?? readDaemonVersion();
|
|
@@ -23896,7 +24845,12 @@ var DaemonCore = class {
|
|
|
23896
24845
|
span.addEvent("daemon.agents.stopped");
|
|
23897
24846
|
} finally {
|
|
23898
24847
|
if (this.connection.connected) {
|
|
23899
|
-
this.
|
|
24848
|
+
const lifecycleAcks = this.options.getComputerLifecycleAcks?.().filter((ack) => ack.phase === "shutdown");
|
|
24849
|
+
this.connection.send({
|
|
24850
|
+
type: "machine:shutdown",
|
|
24851
|
+
reason: shutdownReason,
|
|
24852
|
+
...lifecycleAcks && lifecycleAcks.length > 0 ? { lifecycleAcks } : {}
|
|
24853
|
+
});
|
|
23900
24854
|
span.addEvent("daemon.connection.shutdown_notice_sent", {
|
|
23901
24855
|
outcome: "sent",
|
|
23902
24856
|
shutdown_reason: shutdownReason
|
|
@@ -24093,7 +25047,8 @@ var DaemonCore = class {
|
|
|
24093
25047
|
agent_id_present: Boolean(lease.agentId),
|
|
24094
25048
|
migration_id_present: Boolean(lease.migrationId),
|
|
24095
25049
|
session_id_present: Boolean(lease.sessionId),
|
|
24096
|
-
error_class: err instanceof Error ? err.name : typeof err
|
|
25050
|
+
error_class: err instanceof Error ? err.name : typeof err,
|
|
25051
|
+
...migrationObjectStoreFailureTraceAttrs(err)
|
|
24097
25052
|
}, "error");
|
|
24098
25053
|
try {
|
|
24099
25054
|
await this.reportMigrationTransportLost(lease, err);
|
|
@@ -24134,23 +25089,44 @@ var DaemonCore = class {
|
|
|
24134
25089
|
workspacePath: path23.join(this.agentsDataDir, lease.agentId),
|
|
24135
25090
|
maxBytes: lease.maxBytes
|
|
24136
25091
|
});
|
|
24137
|
-
const
|
|
24138
|
-
|
|
24139
|
-
|
|
24140
|
-
|
|
24141
|
-
|
|
24142
|
-
|
|
24143
|
-
|
|
24144
|
-
|
|
24145
|
-
|
|
24146
|
-
|
|
25092
|
+
const spoolDirectory = await mkdtemp(path23.join(os8.tmpdir(), "raft-agent-migration-upload-"));
|
|
25093
|
+
const spoolPath = path23.join(spoolDirectory, "bundle.tar.gz");
|
|
25094
|
+
let archiveBytes = 0;
|
|
25095
|
+
let uploadStatus = 0;
|
|
25096
|
+
try {
|
|
25097
|
+
await pipeline2(
|
|
25098
|
+
built.bundle,
|
|
25099
|
+
createWriteStream2(spoolPath, { flags: "wx", mode: 384 })
|
|
25100
|
+
);
|
|
25101
|
+
archiveBytes = (await stat4(spoolPath)).size;
|
|
25102
|
+
const response = await daemonFetch(lease.url, {
|
|
25103
|
+
method: "PUT",
|
|
25104
|
+
headers: {
|
|
25105
|
+
...this.migrationObjectStoreHeaders(lease),
|
|
25106
|
+
"Content-Type": AGENT_MIGRATION_OBJECT_STORE_CONTENT_TYPE,
|
|
25107
|
+
"Content-Length": String(archiveBytes)
|
|
25108
|
+
},
|
|
25109
|
+
body: Readable3.toWeb(createReadStream4(spoolPath)),
|
|
25110
|
+
duplex: "half"
|
|
25111
|
+
});
|
|
25112
|
+
if (!response.ok) {
|
|
25113
|
+
throw new MigrationObjectStoreUploadHttpError(response.status, archiveBytes);
|
|
25114
|
+
}
|
|
25115
|
+
uploadStatus = response.status;
|
|
25116
|
+
} finally {
|
|
25117
|
+
await rm4(spoolDirectory, { recursive: true, force: true });
|
|
24147
25118
|
}
|
|
24148
25119
|
await this.reportMigrationSourceReady(lease, built.manifestSha256);
|
|
24149
25120
|
this.recordDaemonTrace("daemon.migration_transport.object_store", {
|
|
24150
25121
|
outcome: "uploaded",
|
|
24151
25122
|
role: lease.role,
|
|
24152
25123
|
transfer_kind: lease.transferKind,
|
|
24153
|
-
|
|
25124
|
+
endpoint_class: "object_store",
|
|
25125
|
+
http_status: uploadStatus,
|
|
25126
|
+
content_length_present: true,
|
|
25127
|
+
upload_body_mode: "spooled_file",
|
|
25128
|
+
bundle_size_bucket: migrationObjectStoreBundleSizeBucket(archiveBytes),
|
|
25129
|
+
bundle_content_bytes: built.contentBytes,
|
|
24154
25130
|
max_bytes: lease.maxBytes
|
|
24155
25131
|
});
|
|
24156
25132
|
}
|
|
@@ -24158,14 +25134,13 @@ var DaemonCore = class {
|
|
|
24158
25134
|
if (lease.transferKind !== "download") {
|
|
24159
25135
|
throw new Error("MIGRATION_OBJECT_STORE_TARGET_KIND_MISMATCH");
|
|
24160
25136
|
}
|
|
24161
|
-
const
|
|
24162
|
-
if (
|
|
24163
|
-
throw new Error("MIGRATION_OBJECT_STORE_BUNDLE_TOO_LARGE");
|
|
24164
|
-
}
|
|
25137
|
+
const response = await this.downloadMigrationObjectStoreBundleWithRetry(lease);
|
|
25138
|
+
if (!response.body) throw new Error("MIGRATION_OBJECT_STORE_DOWNLOAD_BODY_MISSING");
|
|
24165
25139
|
const staged = await stageAgentMigrationObjectStoreBundle({
|
|
24166
|
-
bundle,
|
|
25140
|
+
bundle: Readable3.fromWeb(response.body),
|
|
24167
25141
|
slockHome: this.slockHome,
|
|
24168
|
-
sessionId: lease.sessionId
|
|
25142
|
+
sessionId: lease.sessionId,
|
|
25143
|
+
maxBytes: lease.maxBytes
|
|
24169
25144
|
});
|
|
24170
25145
|
const targetImport = await this.fetchMigrationTargetImportView(lease.migrationId);
|
|
24171
25146
|
if (targetImport.agentId !== lease.agentId) {
|
|
@@ -24194,7 +25169,7 @@ var DaemonCore = class {
|
|
|
24194
25169
|
outcome: "imported",
|
|
24195
25170
|
role: lease.role,
|
|
24196
25171
|
transfer_kind: lease.transferKind,
|
|
24197
|
-
|
|
25172
|
+
bundle_content_bytes: staged.contentBytes,
|
|
24198
25173
|
manifest_sha_present: true
|
|
24199
25174
|
});
|
|
24200
25175
|
}
|
|
@@ -24212,7 +25187,7 @@ var DaemonCore = class {
|
|
|
24212
25187
|
headers: this.migrationObjectStoreHeaders(lease)
|
|
24213
25188
|
});
|
|
24214
25189
|
if (response.ok) {
|
|
24215
|
-
return
|
|
25190
|
+
return response;
|
|
24216
25191
|
}
|
|
24217
25192
|
lastStatus = response.status;
|
|
24218
25193
|
lastErrorClass = null;
|
|
@@ -24254,6 +25229,7 @@ var DaemonCore = class {
|
|
|
24254
25229
|
body: JSON.stringify({
|
|
24255
25230
|
role: lease.role,
|
|
24256
25231
|
transferKind: lease.transferKind,
|
|
25232
|
+
code: migrationTransferFailureCode(err),
|
|
24257
25233
|
message: migrationTransferFailureMessage(err)
|
|
24258
25234
|
})
|
|
24259
25235
|
});
|
|
@@ -24825,14 +25801,29 @@ var DaemonCore = class {
|
|
|
24825
25801
|
case "computer:restart":
|
|
24826
25802
|
case "computer:upgrade": {
|
|
24827
25803
|
const action = msg.type === "computer:restart" ? "restart" : "upgrade";
|
|
24828
|
-
const
|
|
25804
|
+
const operationId = msg.operationId ?? msg.requestId;
|
|
25805
|
+
const requestId = msg.requestId ?? msg.operationId;
|
|
25806
|
+
const alreadyDurable = operationId ? this.options.getComputerLifecycleAcks?.().some(
|
|
25807
|
+
(ack) => (ack.operationId ?? ack.requestId) === operationId
|
|
25808
|
+
) ?? false : false;
|
|
25809
|
+
if (operationId && (alreadyDurable || this.handledComputerControlOperationIds.has(operationId))) {
|
|
25810
|
+
this.recordDaemonTrace("daemon.computer_control.replayed", {
|
|
25811
|
+
action,
|
|
25812
|
+
operation_id: operationId,
|
|
25813
|
+
outcome: "ignored"
|
|
25814
|
+
});
|
|
25815
|
+
break;
|
|
25816
|
+
}
|
|
25817
|
+
if (operationId) this.handledComputerControlOperationIds.add(operationId);
|
|
24829
25818
|
this.recordDaemonTrace("daemon.computer_control.received", {
|
|
24830
25819
|
action,
|
|
24831
25820
|
handled: Boolean(this.options.onComputerControl),
|
|
25821
|
+
...operationId ? { operation_id: operationId } : {},
|
|
24832
25822
|
...requestId ? { request_id: requestId } : {}
|
|
24833
25823
|
});
|
|
24834
25824
|
if (this.options.onComputerControl) {
|
|
24835
25825
|
const ctx = {
|
|
25826
|
+
operationId,
|
|
24836
25827
|
requestId,
|
|
24837
25828
|
emitUpgradeProgress: (ev) => {
|
|
24838
25829
|
if (!requestId) return;
|
|
@@ -24853,6 +25844,16 @@ var DaemonCore = class {
|
|
|
24853
25844
|
}
|
|
24854
25845
|
break;
|
|
24855
25846
|
}
|
|
25847
|
+
case "computer:lifecycle:receipt": {
|
|
25848
|
+
if (this.options.onComputerLifecycleReceipt) {
|
|
25849
|
+
void Promise.resolve(this.options.onComputerLifecycleReceipt(msg.operationId, msg.phase)).catch((err) => {
|
|
25850
|
+
logger.warn(
|
|
25851
|
+
`[Daemon] lifecycle receipt persistence failed: ${err instanceof Error ? err.message : String(err)}`
|
|
25852
|
+
);
|
|
25853
|
+
});
|
|
25854
|
+
}
|
|
25855
|
+
break;
|
|
25856
|
+
}
|
|
24856
25857
|
}
|
|
24857
25858
|
}
|
|
24858
25859
|
onReminderFire(job) {
|
|
@@ -24881,14 +25882,21 @@ var DaemonCore = class {
|
|
|
24881
25882
|
const runtimeProfileReports = this.agentManager.getAgentRuntimeProfileReports();
|
|
24882
25883
|
this.connection.send({
|
|
24883
25884
|
type: "ready",
|
|
24884
|
-
capabilities: [
|
|
25885
|
+
capabilities: [
|
|
25886
|
+
"agent:start",
|
|
25887
|
+
"agent:stop",
|
|
25888
|
+
"agent:deliver",
|
|
25889
|
+
"workspace:files",
|
|
25890
|
+
...this.options.computerControlViaSupervisor ? [COMPUTER_CAPABILITY_SUPERVISOR_MUTATIONS] : []
|
|
25891
|
+
],
|
|
24885
25892
|
runtimes,
|
|
24886
25893
|
runningAgents: runningAgentIds,
|
|
24887
25894
|
hostname: this.options.hostname ?? os8.hostname(),
|
|
24888
25895
|
os: this.options.osDescription ?? `${os8.platform()} ${os8.arch()}`,
|
|
24889
25896
|
daemonVersion: this.daemonVersion,
|
|
24890
25897
|
...this.computerVersion ? { computerVersion: this.computerVersion } : {},
|
|
24891
|
-
migrationTransport: this.getMigrationTransportReady()
|
|
25898
|
+
migrationTransport: this.getMigrationTransportReady(),
|
|
25899
|
+
...this.options.getComputerLifecycleAcks ? { lifecycleAcks: this.options.getComputerLifecycleAcks() } : {}
|
|
24892
25900
|
});
|
|
24893
25901
|
this.recordDaemonTrace("daemon.ready.sent", {
|
|
24894
25902
|
runtimes_count: runtimes.length,
|
|
@@ -24929,6 +25937,21 @@ var DaemonCore = class {
|
|
|
24929
25937
|
);
|
|
24930
25938
|
});
|
|
24931
25939
|
}
|
|
25940
|
+
if (this.options.onComputerRestartReconcile) {
|
|
25941
|
+
void Promise.resolve().then(
|
|
25942
|
+
() => this.options.onComputerRestartReconcile((done) => {
|
|
25943
|
+
this.connection.send({ type: "computer:restart:done", ...done });
|
|
25944
|
+
this.recordDaemonTrace("daemon.computer_restart.reconciled", {
|
|
25945
|
+
request_id: done.requestId,
|
|
25946
|
+
ok: done.ok
|
|
25947
|
+
});
|
|
25948
|
+
})
|
|
25949
|
+
).catch((err) => {
|
|
25950
|
+
logger.error(
|
|
25951
|
+
`[Daemon] computer restart reconcile failed: ${err instanceof Error ? err.message : String(err)}`
|
|
25952
|
+
);
|
|
25953
|
+
});
|
|
25954
|
+
}
|
|
24932
25955
|
for (const agentId of runningAgentIds) {
|
|
24933
25956
|
const sessionId = this.agentManager.getAgentSessionId(agentId);
|
|
24934
25957
|
const launchId = this.agentManager.getAgentLaunchId(agentId);
|
|
@@ -24990,6 +26013,9 @@ export {
|
|
|
24990
26013
|
resolveWorkspaceDirectoryPath,
|
|
24991
26014
|
scanWorkspaceDirectories,
|
|
24992
26015
|
deleteWorkspaceDirectory,
|
|
26016
|
+
detectLegacyDaemonSupervisor,
|
|
26017
|
+
detectLegacyDaemonSupervisorWithProbe,
|
|
26018
|
+
legacyDaemonSupervisorFallbackCommands,
|
|
24993
26019
|
AGENT_MIGRATION_TRANSPORT_HOST_ENV,
|
|
24994
26020
|
AGENT_MIGRATION_TRANSPORT_PORT_ENV,
|
|
24995
26021
|
AGENT_MIGRATION_TRANSPORT_PUBLIC_URL_ENV,
|
|
@@ -25002,8 +26028,10 @@ export {
|
|
|
25002
26028
|
buildAgentMigrationExportManifest,
|
|
25003
26029
|
AGENT_MIGRATION_OBJECT_STORE_BUNDLE_SCHEMA_VERSION,
|
|
25004
26030
|
AGENT_MIGRATION_OBJECT_STORE_CONTENT_TYPE,
|
|
26031
|
+
AgentMigrationObjectStoreBundleTooLargeError,
|
|
25005
26032
|
buildAgentMigrationObjectStoreBundle,
|
|
25006
26033
|
stageAgentMigrationObjectStoreBundle,
|
|
26034
|
+
assertAgentMigrationObjectStoreBundleSize,
|
|
25007
26035
|
buildAgentMigrationAdoptPlan,
|
|
25008
26036
|
verifyAgentMigrationAdoptPlan,
|
|
25009
26037
|
executeAgentMigrationAdoptPlan,
|