@autohq/cli 0.1.683 → 0.1.684
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/agent-bridge.js +3624 -86
- package/dist/index.js +3109 -2785
- package/package.json +1 -1
package/dist/agent-bridge.js
CHANGED
|
@@ -3729,7 +3729,7 @@ var require_identity = __commonJS({
|
|
|
3729
3729
|
var NODE_TYPE = /* @__PURE__ */ Symbol.for("yaml.node.type");
|
|
3730
3730
|
var isAlias = (node) => !!node && typeof node === "object" && node[NODE_TYPE] === ALIAS;
|
|
3731
3731
|
var isDocument = (node) => !!node && typeof node === "object" && node[NODE_TYPE] === DOC;
|
|
3732
|
-
var
|
|
3732
|
+
var isMap2 = (node) => !!node && typeof node === "object" && node[NODE_TYPE] === MAP;
|
|
3733
3733
|
var isPair = (node) => !!node && typeof node === "object" && node[NODE_TYPE] === PAIR;
|
|
3734
3734
|
var isScalar = (node) => !!node && typeof node === "object" && node[NODE_TYPE] === SCALAR;
|
|
3735
3735
|
var isSeq = (node) => !!node && typeof node === "object" && node[NODE_TYPE] === SEQ;
|
|
@@ -3765,7 +3765,7 @@ var require_identity = __commonJS({
|
|
|
3765
3765
|
exports.isAlias = isAlias;
|
|
3766
3766
|
exports.isCollection = isCollection;
|
|
3767
3767
|
exports.isDocument = isDocument;
|
|
3768
|
-
exports.isMap =
|
|
3768
|
+
exports.isMap = isMap2;
|
|
3769
3769
|
exports.isNode = isNode;
|
|
3770
3770
|
exports.isPair = isPair;
|
|
3771
3771
|
exports.isScalar = isScalar;
|
|
@@ -7875,9 +7875,9 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
7875
7875
|
var blockMsg = "Block collections are not allowed within flow collections";
|
|
7876
7876
|
var isBlock = (token) => token && (token.type === "block-map" || token.type === "block-seq");
|
|
7877
7877
|
function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc2, onError, tag) {
|
|
7878
|
-
const
|
|
7879
|
-
const fcName =
|
|
7880
|
-
const NodeClass = tag?.nodeClass ?? (
|
|
7878
|
+
const isMap2 = fc2.start.source === "{";
|
|
7879
|
+
const fcName = isMap2 ? "flow map" : "flow sequence";
|
|
7880
|
+
const NodeClass = tag?.nodeClass ?? (isMap2 ? YAMLMap.YAMLMap : YAMLSeq.YAMLSeq);
|
|
7881
7881
|
const coll = new NodeClass(ctx.schema);
|
|
7882
7882
|
coll.flow = true;
|
|
7883
7883
|
const atRoot = ctx.atRoot;
|
|
@@ -7913,7 +7913,7 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
7913
7913
|
offset = props.end;
|
|
7914
7914
|
continue;
|
|
7915
7915
|
}
|
|
7916
|
-
if (!
|
|
7916
|
+
if (!isMap2 && ctx.options.strict && utilContainsNewline.containsNewline(key))
|
|
7917
7917
|
onError(
|
|
7918
7918
|
key,
|
|
7919
7919
|
// checked by containsNewline()
|
|
@@ -7953,7 +7953,7 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
7953
7953
|
}
|
|
7954
7954
|
}
|
|
7955
7955
|
}
|
|
7956
|
-
if (!
|
|
7956
|
+
if (!isMap2 && !sep6 && !props.found) {
|
|
7957
7957
|
const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, sep6, null, props, onError);
|
|
7958
7958
|
coll.items.push(valueNode);
|
|
7959
7959
|
offset = valueNode.range[2];
|
|
@@ -7976,7 +7976,7 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
7976
7976
|
startOnNewline: false
|
|
7977
7977
|
});
|
|
7978
7978
|
if (valueProps.found) {
|
|
7979
|
-
if (!
|
|
7979
|
+
if (!isMap2 && !props.found && ctx.options.strict) {
|
|
7980
7980
|
if (sep6)
|
|
7981
7981
|
for (const st2 of sep6) {
|
|
7982
7982
|
if (st2 === valueProps.found)
|
|
@@ -8008,7 +8008,7 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
8008
8008
|
const pair = new Pair.Pair(keyNode, valueNode);
|
|
8009
8009
|
if (ctx.options.keepSourceTokens)
|
|
8010
8010
|
pair.srcToken = collItem;
|
|
8011
|
-
if (
|
|
8011
|
+
if (isMap2) {
|
|
8012
8012
|
const map2 = coll;
|
|
8013
8013
|
if (utilMapIncludes.mapIncludes(ctx, map2.items, keyNode))
|
|
8014
8014
|
onError(keyStart, "DUPLICATE_KEY", "Map keys must be unique");
|
|
@@ -8024,7 +8024,7 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
8024
8024
|
offset = valueNode ? valueNode.range[2] : valueProps.end;
|
|
8025
8025
|
}
|
|
8026
8026
|
}
|
|
8027
|
-
const expectedEnd =
|
|
8027
|
+
const expectedEnd = isMap2 ? "}" : "]";
|
|
8028
8028
|
const [ce2, ...ee2] = fc2.end;
|
|
8029
8029
|
let cePos = offset;
|
|
8030
8030
|
if (ce2?.source === expectedEnd)
|
|
@@ -9993,7 +9993,7 @@ var require_lexer = __commonJS({
|
|
|
9993
9993
|
var require_line_counter = __commonJS({
|
|
9994
9994
|
"../../node_modules/yaml/dist/parse/line-counter.js"(exports) {
|
|
9995
9995
|
"use strict";
|
|
9996
|
-
var
|
|
9996
|
+
var LineCounter2 = class {
|
|
9997
9997
|
constructor() {
|
|
9998
9998
|
this.lineStarts = [];
|
|
9999
9999
|
this.addNewLine = (offset) => this.lineStarts.push(offset);
|
|
@@ -10016,7 +10016,7 @@ var require_line_counter = __commonJS({
|
|
|
10016
10016
|
};
|
|
10017
10017
|
}
|
|
10018
10018
|
};
|
|
10019
|
-
exports.LineCounter =
|
|
10019
|
+
exports.LineCounter = LineCounter2;
|
|
10020
10020
|
}
|
|
10021
10021
|
});
|
|
10022
10022
|
|
|
@@ -10910,7 +10910,7 @@ var require_public_api = __commonJS({
|
|
|
10910
10910
|
const lineCounter$1 = options.lineCounter || prettyErrors && new lineCounter.LineCounter() || null;
|
|
10911
10911
|
return { lineCounter: lineCounter$1, prettyErrors };
|
|
10912
10912
|
}
|
|
10913
|
-
function
|
|
10913
|
+
function parseAllDocuments(source, options = {}) {
|
|
10914
10914
|
const { lineCounter: lineCounter2, prettyErrors } = parseOptions(options);
|
|
10915
10915
|
const parser$1 = new parser.Parser(lineCounter2?.addNewLine);
|
|
10916
10916
|
const composer$1 = new composer.Composer(options);
|
|
@@ -10985,7 +10985,7 @@ var require_public_api = __commonJS({
|
|
|
10985
10985
|
return new Document.Document(value, _replacer, options).toString(options);
|
|
10986
10986
|
}
|
|
10987
10987
|
exports.parse = parse5;
|
|
10988
|
-
exports.parseAllDocuments =
|
|
10988
|
+
exports.parseAllDocuments = parseAllDocuments;
|
|
10989
10989
|
exports.parseDocument = parseDocument;
|
|
10990
10990
|
exports.stringify = stringify;
|
|
10991
10991
|
}
|
|
@@ -33191,11 +33191,11 @@ function decryptRuntimeBridgeBootstrap(input) {
|
|
|
33191
33191
|
return { bootstrap, ignoredKeys: ignoredPlaintextKeys(raw) };
|
|
33192
33192
|
}
|
|
33193
33193
|
function ignoredPlaintextKeys(raw) {
|
|
33194
|
-
const
|
|
33194
|
+
const record3 = external_exports.record(external_exports.string(), external_exports.unknown()).parse(raw);
|
|
33195
33195
|
const knownKeys = new Set(
|
|
33196
33196
|
Object.keys(RuntimeBridgeBootstrapPlaintextSchema.shape)
|
|
33197
33197
|
);
|
|
33198
|
-
return Object.keys(
|
|
33198
|
+
return Object.keys(record3).filter((key) => !knownKeys.has(key));
|
|
33199
33199
|
}
|
|
33200
33200
|
function deriveBootstrapKey(accessToken, salt) {
|
|
33201
33201
|
return Buffer.from(
|
|
@@ -33218,7 +33218,7 @@ function bootstrapAdditionalData(input) {
|
|
|
33218
33218
|
// package.json
|
|
33219
33219
|
var package_default = {
|
|
33220
33220
|
name: "@autohq/cli",
|
|
33221
|
-
version: "0.1.
|
|
33221
|
+
version: "0.1.684",
|
|
33222
33222
|
license: "SEE LICENSE IN README.md",
|
|
33223
33223
|
publishConfig: {
|
|
33224
33224
|
access: "public"
|
|
@@ -34751,6 +34751,20 @@ var SERVICE_ACCOUNT_SCOPE_PRESETS = {
|
|
|
34751
34751
|
};
|
|
34752
34752
|
var ServiceAccountScopePresetSchema = external_exports.enum(["read-only", "applier"]);
|
|
34753
34753
|
|
|
34754
|
+
// ../../packages/schemas/src/capability-attenuation.ts
|
|
34755
|
+
function grantedCapabilityLevel(capability) {
|
|
34756
|
+
return typeof capability === "string" ? capability : capability.level;
|
|
34757
|
+
}
|
|
34758
|
+
function unattributedCapabilityLevel(capability) {
|
|
34759
|
+
return typeof capability === "string" ? void 0 : capability.unattributed;
|
|
34760
|
+
}
|
|
34761
|
+
function effectiveCapabilityLevel(capability, requesterEligible) {
|
|
34762
|
+
return requesterEligible ? grantedCapabilityLevel(capability) : unattributedCapabilityLevel(capability) ?? grantedCapabilityLevel(capability);
|
|
34763
|
+
}
|
|
34764
|
+
function capabilityLevelAtMost(input) {
|
|
34765
|
+
return input.levels.indexOf(input.floor) <= input.levels.indexOf(input.grant);
|
|
34766
|
+
}
|
|
34767
|
+
|
|
34754
34768
|
// ../../packages/schemas/src/conversation.ts
|
|
34755
34769
|
var CONVERSATION_ROLES = [
|
|
34756
34770
|
"system",
|
|
@@ -35125,25 +35139,25 @@ var ClaudeCodeStreamRecordSchema = external_exports.discriminatedUnion("type", [
|
|
|
35125
35139
|
ClaudeCodeResultRecordSchema
|
|
35126
35140
|
]);
|
|
35127
35141
|
function parseClaudeCodeStreamRecord(parsed) {
|
|
35128
|
-
const
|
|
35129
|
-
if (
|
|
35130
|
-
const projection = systemProjection(
|
|
35142
|
+
const record3 = ClaudeCodeStreamRecordSchema.parse(parsed);
|
|
35143
|
+
if (record3.type === "system") {
|
|
35144
|
+
const projection = systemProjection(record3);
|
|
35131
35145
|
return {
|
|
35132
35146
|
projections: projection ? [projection] : []
|
|
35133
35147
|
};
|
|
35134
35148
|
}
|
|
35135
|
-
if (
|
|
35149
|
+
if (record3.type === "assistant" || record3.type === "user") {
|
|
35136
35150
|
return {
|
|
35137
|
-
projections:
|
|
35138
|
-
|
|
35139
|
-
|
|
35140
|
-
) : userContentProjections(
|
|
35151
|
+
projections: record3.type === "assistant" ? assistantContentProjections(
|
|
35152
|
+
record3.message,
|
|
35153
|
+
record3.message.id ?? UNKNOWN_MESSAGE_ID
|
|
35154
|
+
) : userContentProjections(record3.message)
|
|
35141
35155
|
};
|
|
35142
35156
|
}
|
|
35143
|
-
const isError =
|
|
35144
|
-
const sdkErrorMessage =
|
|
35145
|
-
const errorMessage10 = isError ?
|
|
35146
|
-
const usage = claudeCodeUsageFromRecord(
|
|
35157
|
+
const isError = record3.is_error === true || record3.subtype === "error";
|
|
35158
|
+
const sdkErrorMessage = record3.errors?.map((error51) => error51.trim()).filter(Boolean).join("\n");
|
|
35159
|
+
const errorMessage10 = isError ? record3.error ?? record3.result ?? (sdkErrorMessage || void 0) ?? "claude-code reported an error" : void 0;
|
|
35160
|
+
const usage = claudeCodeUsageFromRecord(record3);
|
|
35147
35161
|
return {
|
|
35148
35162
|
projections: [],
|
|
35149
35163
|
result: {
|
|
@@ -35153,8 +35167,8 @@ function parseClaudeCodeStreamRecord(parsed) {
|
|
|
35153
35167
|
}
|
|
35154
35168
|
};
|
|
35155
35169
|
}
|
|
35156
|
-
function isClaudeCodeInterruptMarker(
|
|
35157
|
-
const parsed = ClaudeCodeInterruptMarkerRecordSchema.safeParse(
|
|
35170
|
+
function isClaudeCodeInterruptMarker(record3) {
|
|
35171
|
+
const parsed = ClaudeCodeInterruptMarkerRecordSchema.safeParse(record3);
|
|
35158
35172
|
if (!parsed.success) {
|
|
35159
35173
|
return false;
|
|
35160
35174
|
}
|
|
@@ -35205,19 +35219,19 @@ function textContent(text) {
|
|
|
35205
35219
|
]
|
|
35206
35220
|
};
|
|
35207
35221
|
}
|
|
35208
|
-
function systemProjection(
|
|
35209
|
-
if (
|
|
35222
|
+
function systemProjection(record3) {
|
|
35223
|
+
if (record3.subtype === "init") {
|
|
35210
35224
|
return {
|
|
35211
35225
|
role: "system",
|
|
35212
35226
|
kind: "status",
|
|
35213
35227
|
content: textContent(
|
|
35214
|
-
`claude-code session started${
|
|
35228
|
+
`claude-code session started${record3.model ? ` (${record3.model})` : ""}`
|
|
35215
35229
|
)
|
|
35216
35230
|
};
|
|
35217
35231
|
}
|
|
35218
|
-
if (
|
|
35219
|
-
const attempt =
|
|
35220
|
-
const maxRetries =
|
|
35232
|
+
if (record3.subtype === "api_retry") {
|
|
35233
|
+
const attempt = record3.attempt;
|
|
35234
|
+
const maxRetries = record3.max_retries;
|
|
35221
35235
|
return {
|
|
35222
35236
|
role: "system",
|
|
35223
35237
|
kind: "status",
|
|
@@ -35343,9 +35357,9 @@ function userContentProjections(message) {
|
|
|
35343
35357
|
}
|
|
35344
35358
|
return projections;
|
|
35345
35359
|
}
|
|
35346
|
-
function claudeCodeUsageFromRecord(
|
|
35347
|
-
const aggregate =
|
|
35348
|
-
const modelUsage =
|
|
35360
|
+
function claudeCodeUsageFromRecord(record3) {
|
|
35361
|
+
const aggregate = record3.usage;
|
|
35362
|
+
const modelUsage = record3.modelUsage;
|
|
35349
35363
|
if (!aggregate && !modelUsage) {
|
|
35350
35364
|
return void 0;
|
|
35351
35365
|
}
|
|
@@ -35364,7 +35378,7 @@ function claudeCodeUsageFromRecord(record2) {
|
|
|
35364
35378
|
outputTokens: tokenCount(aggregate?.output_tokens),
|
|
35365
35379
|
cacheCreationTokens: tokenCount(aggregate?.cache_creation_input_tokens),
|
|
35366
35380
|
cacheReadTokens: tokenCount(aggregate?.cache_read_input_tokens),
|
|
35367
|
-
totalCostUsd: usdAmount(
|
|
35381
|
+
totalCostUsd: usdAmount(record3.total_cost_usd),
|
|
35368
35382
|
perModel
|
|
35369
35383
|
};
|
|
35370
35384
|
}
|
|
@@ -35817,6 +35831,193 @@ function parseApprovalRequest(method, requestId, params) {
|
|
|
35817
35831
|
}
|
|
35818
35832
|
}
|
|
35819
35833
|
|
|
35834
|
+
// ../../packages/schemas/src/pricing.ts
|
|
35835
|
+
var UnknownPricingVersionError = class extends Error {
|
|
35836
|
+
constructor(version2) {
|
|
35837
|
+
super(`Unknown pricing rate-card version: ${version2}`);
|
|
35838
|
+
this.name = "UnknownPricingVersionError";
|
|
35839
|
+
}
|
|
35840
|
+
};
|
|
35841
|
+
var UnknownPricingModelError = class extends Error {
|
|
35842
|
+
constructor(model, version2) {
|
|
35843
|
+
super(`No pricing for model "${model}" in rate card ${version2}`);
|
|
35844
|
+
this.name = "UnknownPricingModelError";
|
|
35845
|
+
}
|
|
35846
|
+
};
|
|
35847
|
+
var RATE_CARD_2026_06_23 = {
|
|
35848
|
+
version: "2026-06-23",
|
|
35849
|
+
effectiveAt: "2026-06-23T00:00:00.000Z",
|
|
35850
|
+
models: {
|
|
35851
|
+
"claude-opus-4-8": opusTier(),
|
|
35852
|
+
"claude-opus-4-7": opusTier(),
|
|
35853
|
+
"claude-opus-4-6": opusTier(),
|
|
35854
|
+
"claude-sonnet-4-6": tier(3, 15),
|
|
35855
|
+
"claude-haiku-4-5": tier(1, 5),
|
|
35856
|
+
"claude-haiku-4-5-20251001": tier(1, 5),
|
|
35857
|
+
"claude-fable-5": tier(10, 50),
|
|
35858
|
+
// OpenAI gpt-5.3-codex, standard tier: input $1.75/Mtok, cached input
|
|
35859
|
+
// $0.175/Mtok, output $14.00/Mtok. Source (verified 2026-06-23):
|
|
35860
|
+
// https://developers.openai.com/api/docs/models/gpt-5.3-codex and
|
|
35861
|
+
// https://developers.openai.com/api/docs/pricing (priority tier is 2x; we
|
|
35862
|
+
// bill standard).
|
|
35863
|
+
"gpt-5.3-codex": openAiTier({
|
|
35864
|
+
input: 1.75,
|
|
35865
|
+
cachedInput: 0.175,
|
|
35866
|
+
output: 14
|
|
35867
|
+
})
|
|
35868
|
+
}
|
|
35869
|
+
};
|
|
35870
|
+
var RATE_CARD_2026_07_04 = {
|
|
35871
|
+
version: "2026-07-04",
|
|
35872
|
+
effectiveAt: "2026-07-04T00:00:00.000Z",
|
|
35873
|
+
models: {
|
|
35874
|
+
...RATE_CARD_2026_06_23.models,
|
|
35875
|
+
// OpenAI gpt-5.5, standard tier: input $5.00/Mtok, cached input
|
|
35876
|
+
// $0.50/Mtok, output $30.00/Mtok. Source (verified 2026-07-04):
|
|
35877
|
+
// https://developers.openai.com/api/docs/models/gpt-5.5 and
|
|
35878
|
+
// https://developers.openai.com/api/docs/pricing (priority tier is 2x; we
|
|
35879
|
+
// bill standard).
|
|
35880
|
+
"gpt-5.5": openAiTier({
|
|
35881
|
+
input: 5,
|
|
35882
|
+
cachedInput: 0.5,
|
|
35883
|
+
output: 30
|
|
35884
|
+
}),
|
|
35885
|
+
// OpenAI may echo the dated snapshot id on responses even when callers send
|
|
35886
|
+
// the `gpt-5.5` alias. Price that dated id identically so usage enrichment
|
|
35887
|
+
// keeps recording codex-default spend instead of dropping unknown models.
|
|
35888
|
+
"gpt-5.5-2026-04-23": openAiTier({
|
|
35889
|
+
input: 5,
|
|
35890
|
+
cachedInput: 0.5,
|
|
35891
|
+
output: 30
|
|
35892
|
+
})
|
|
35893
|
+
}
|
|
35894
|
+
};
|
|
35895
|
+
var RATE_CARD_2026_07_07 = {
|
|
35896
|
+
version: "2026-07-07",
|
|
35897
|
+
effectiveAt: "2026-07-07T00:00:00.000Z",
|
|
35898
|
+
models: {
|
|
35899
|
+
...RATE_CARD_2026_07_04.models,
|
|
35900
|
+
// Anthropic Claude Sonnet 5 list price: input $3/Mtok, output $15/Mtok
|
|
35901
|
+
// (same tier as Sonnet 4.6). Anthropic runs an introductory $2/$10 rate
|
|
35902
|
+
// through 2026-08-31; we bill list, matching the rest of the card.
|
|
35903
|
+
"claude-sonnet-5": tier(3, 15)
|
|
35904
|
+
}
|
|
35905
|
+
};
|
|
35906
|
+
var RATE_CARD_2026_07_09 = {
|
|
35907
|
+
version: "2026-07-09",
|
|
35908
|
+
effectiveAt: "2026-07-09T00:00:00.000Z",
|
|
35909
|
+
models: {
|
|
35910
|
+
...RATE_CARD_2026_07_07.models,
|
|
35911
|
+
// OpenAI GPT-5.6 Sol preview price: input $5.00/Mtok, cache writes
|
|
35912
|
+
// $6.25/Mtok, cached reads $0.50/Mtok, and output $30.00/Mtok. Source
|
|
35913
|
+
// (verified 2026-07-09):
|
|
35914
|
+
// https://help.openai.com/en/articles/20001325-a-preview-of-gpt-5-6-sol-terra-and-luna
|
|
35915
|
+
"gpt-5.6-sol": openAiCacheWriteTier({
|
|
35916
|
+
input: 5,
|
|
35917
|
+
output: 30
|
|
35918
|
+
})
|
|
35919
|
+
}
|
|
35920
|
+
};
|
|
35921
|
+
var RATE_CARD_2026_07_30 = {
|
|
35922
|
+
version: "2026-07-30",
|
|
35923
|
+
effectiveAt: "2026-07-30T00:00:00.000Z",
|
|
35924
|
+
models: {
|
|
35925
|
+
...RATE_CARD_2026_07_09.models,
|
|
35926
|
+
"gpt-5.6-terra": openAiLongContextTier({
|
|
35927
|
+
input: 2,
|
|
35928
|
+
output: 12
|
|
35929
|
+
}),
|
|
35930
|
+
"gpt-5.6-luna": openAiLongContextTier({
|
|
35931
|
+
input: 0.2,
|
|
35932
|
+
output: 1.2
|
|
35933
|
+
})
|
|
35934
|
+
}
|
|
35935
|
+
};
|
|
35936
|
+
var RATE_CARD_2026_09_01 = {
|
|
35937
|
+
version: "2026-09-01",
|
|
35938
|
+
effectiveAt: "2026-09-01T00:00:00.000Z",
|
|
35939
|
+
models: {
|
|
35940
|
+
...RATE_CARD_2026_07_30.models,
|
|
35941
|
+
"claude-fable-5-1": fable51Tier(),
|
|
35942
|
+
"claude-mythos-5-1": fable51Tier()
|
|
35943
|
+
}
|
|
35944
|
+
};
|
|
35945
|
+
var RATE_CARD_2026_09_04 = {
|
|
35946
|
+
version: "2026-09-04",
|
|
35947
|
+
effectiveAt: "2026-09-04T00:00:00.000Z",
|
|
35948
|
+
models: {
|
|
35949
|
+
...RATE_CARD_2026_09_01.models,
|
|
35950
|
+
"gpt-6-astra": openAiLongContextTier({
|
|
35951
|
+
input: 10,
|
|
35952
|
+
output: 50
|
|
35953
|
+
})
|
|
35954
|
+
}
|
|
35955
|
+
};
|
|
35956
|
+
var PRICING_RATE_CARDS = {
|
|
35957
|
+
[RATE_CARD_2026_06_23.version]: RATE_CARD_2026_06_23,
|
|
35958
|
+
[RATE_CARD_2026_07_04.version]: RATE_CARD_2026_07_04,
|
|
35959
|
+
[RATE_CARD_2026_07_07.version]: RATE_CARD_2026_07_07,
|
|
35960
|
+
[RATE_CARD_2026_07_09.version]: RATE_CARD_2026_07_09,
|
|
35961
|
+
[RATE_CARD_2026_07_30.version]: RATE_CARD_2026_07_30,
|
|
35962
|
+
[RATE_CARD_2026_09_01.version]: RATE_CARD_2026_09_01,
|
|
35963
|
+
[RATE_CARD_2026_09_04.version]: RATE_CARD_2026_09_04
|
|
35964
|
+
};
|
|
35965
|
+
var CURRENT_PRICING_VERSION = RATE_CARD_2026_09_04.version;
|
|
35966
|
+
function getModelPricing(model, pricingVersion = CURRENT_PRICING_VERSION) {
|
|
35967
|
+
const card = PRICING_RATE_CARDS[pricingVersion];
|
|
35968
|
+
if (!card) {
|
|
35969
|
+
throw new UnknownPricingVersionError(pricingVersion);
|
|
35970
|
+
}
|
|
35971
|
+
const pricing = card.models[model];
|
|
35972
|
+
if (!pricing) {
|
|
35973
|
+
throw new UnknownPricingModelError(model, pricingVersion);
|
|
35974
|
+
}
|
|
35975
|
+
return pricing;
|
|
35976
|
+
}
|
|
35977
|
+
function tier(inputUsdPerMtok, outputUsdPerMtok) {
|
|
35978
|
+
return {
|
|
35979
|
+
inputUsdPerMtok,
|
|
35980
|
+
outputUsdPerMtok,
|
|
35981
|
+
cacheWrite5mUsdPerMtok: inputUsdPerMtok * 1.25,
|
|
35982
|
+
cacheReadUsdPerMtok: inputUsdPerMtok * 0.1
|
|
35983
|
+
};
|
|
35984
|
+
}
|
|
35985
|
+
function opusTier() {
|
|
35986
|
+
return tier(5, 25);
|
|
35987
|
+
}
|
|
35988
|
+
function fable51Tier() {
|
|
35989
|
+
return {
|
|
35990
|
+
...tier(10, 50),
|
|
35991
|
+
cacheReadUsdPerMtok: 0.25
|
|
35992
|
+
};
|
|
35993
|
+
}
|
|
35994
|
+
function openAiTier(rates) {
|
|
35995
|
+
return {
|
|
35996
|
+
inputUsdPerMtok: rates.input,
|
|
35997
|
+
outputUsdPerMtok: rates.output,
|
|
35998
|
+
cacheWrite5mUsdPerMtok: rates.input,
|
|
35999
|
+
cacheReadUsdPerMtok: rates.cachedInput
|
|
36000
|
+
};
|
|
36001
|
+
}
|
|
36002
|
+
function openAiCacheWriteTier(rates) {
|
|
36003
|
+
return {
|
|
36004
|
+
inputUsdPerMtok: rates.input,
|
|
36005
|
+
outputUsdPerMtok: rates.output,
|
|
36006
|
+
cacheWrite5mUsdPerMtok: rates.input * 1.25,
|
|
36007
|
+
cacheReadUsdPerMtok: rates.input * 0.1
|
|
36008
|
+
};
|
|
36009
|
+
}
|
|
36010
|
+
function openAiLongContextTier(rates) {
|
|
36011
|
+
return {
|
|
36012
|
+
...openAiCacheWriteTier(rates),
|
|
36013
|
+
longContext: {
|
|
36014
|
+
thresholdInputTokens: 272e3,
|
|
36015
|
+
inputMultiplier: 2,
|
|
36016
|
+
outputMultiplier: 1.5
|
|
36017
|
+
}
|
|
36018
|
+
};
|
|
36019
|
+
}
|
|
36020
|
+
|
|
35820
36021
|
// ../../packages/schemas/src/model-selection.ts
|
|
35821
36022
|
var MODEL_API_TOKEN_PROVIDERS = [
|
|
35822
36023
|
"anthropic",
|
|
@@ -35842,6 +36043,13 @@ var CODEX_MAX_REASONING_EFFORTS = [
|
|
|
35842
36043
|
...CODEX_REASONING_EFFORTS,
|
|
35843
36044
|
"max"
|
|
35844
36045
|
];
|
|
36046
|
+
var CODEX_ASTRA_REASONING_EFFORTS = [
|
|
36047
|
+
"low",
|
|
36048
|
+
"medium",
|
|
36049
|
+
"high",
|
|
36050
|
+
"xhigh",
|
|
36051
|
+
"max"
|
|
36052
|
+
];
|
|
35845
36053
|
var ClaudeCodeReasoningEffortSchema = external_exports.enum(
|
|
35846
36054
|
CLAUDE_CODE_REASONING_EFFORTS
|
|
35847
36055
|
);
|
|
@@ -35894,6 +36102,2994 @@ var ModelRoutingConfigSchema = external_exports.object({
|
|
|
35894
36102
|
// authored fields are mutually exclusive at validation).
|
|
35895
36103
|
fallbackModelIds: external_exports.array(external_exports.string().min(1)).min(1).max(2).optional()
|
|
35896
36104
|
}).strict();
|
|
36105
|
+
var InvalidModelSelectionError = class extends Error {
|
|
36106
|
+
constructor(message) {
|
|
36107
|
+
super(message);
|
|
36108
|
+
this.name = "InvalidModelSelectionError";
|
|
36109
|
+
}
|
|
36110
|
+
};
|
|
36111
|
+
var HARNESS_MODEL_RULES = {
|
|
36112
|
+
"claude-code": {
|
|
36113
|
+
defaultProvider: "anthropic",
|
|
36114
|
+
providers: ["anthropic"],
|
|
36115
|
+
defaultModel: "claude-opus-4-8",
|
|
36116
|
+
curatedModels: {
|
|
36117
|
+
anthropic: [
|
|
36118
|
+
"claude-opus-4-8",
|
|
36119
|
+
"fable",
|
|
36120
|
+
"claude-fable-5-1",
|
|
36121
|
+
"claude-mythos-5-1",
|
|
36122
|
+
"claude-fable-5",
|
|
36123
|
+
"claude-opus-4-7",
|
|
36124
|
+
"claude-opus-4-6",
|
|
36125
|
+
"claude-sonnet-5",
|
|
36126
|
+
"claude-sonnet-4-6",
|
|
36127
|
+
"claude-haiku-4-5",
|
|
36128
|
+
"claude-haiku-4-5-20251001"
|
|
36129
|
+
]
|
|
36130
|
+
},
|
|
36131
|
+
curatedModelMetadata: {
|
|
36132
|
+
anthropic: {
|
|
36133
|
+
fable: {
|
|
36134
|
+
displayName: "Claude Fable 5.1",
|
|
36135
|
+
availability: "generally_available"
|
|
36136
|
+
},
|
|
36137
|
+
"claude-fable-5-1": {
|
|
36138
|
+
displayName: "Claude Fable 5.1",
|
|
36139
|
+
availability: "generally_available"
|
|
36140
|
+
},
|
|
36141
|
+
"claude-mythos-5-1": {
|
|
36142
|
+
displayName: "Claude Mythos 5.1",
|
|
36143
|
+
availability: "limited_access",
|
|
36144
|
+
availabilityLabel: "Project Glasswing"
|
|
36145
|
+
}
|
|
36146
|
+
}
|
|
36147
|
+
},
|
|
36148
|
+
openProviderPatterns: {},
|
|
36149
|
+
// The pinned Claude Agent SDK applies "high" when the effort option is
|
|
36150
|
+
// omitted, so "high" is what default-effort sessions have always run at.
|
|
36151
|
+
defaultReasoningEffort: "high",
|
|
36152
|
+
reasoningEfforts: CLAUDE_CODE_REASONING_EFFORTS,
|
|
36153
|
+
reasoningEffortsByModel: {}
|
|
36154
|
+
},
|
|
36155
|
+
codex: {
|
|
36156
|
+
defaultProvider: "openai",
|
|
36157
|
+
providers: ["openai", "openrouter"],
|
|
36158
|
+
defaultModel: "gpt-5.6-sol",
|
|
36159
|
+
curatedModels: {
|
|
36160
|
+
openai: [
|
|
36161
|
+
"gpt-6-astra",
|
|
36162
|
+
"gpt-5.6-sol",
|
|
36163
|
+
"gpt-5.6-terra",
|
|
36164
|
+
"gpt-5.6-luna",
|
|
36165
|
+
"gpt-5.5",
|
|
36166
|
+
"gpt-5.3-codex"
|
|
36167
|
+
]
|
|
36168
|
+
},
|
|
36169
|
+
curatedModelMetadata: {
|
|
36170
|
+
openai: {
|
|
36171
|
+
"gpt-6-astra": {
|
|
36172
|
+
displayName: "GPT-6 Astra",
|
|
36173
|
+
availability: "limited_access",
|
|
36174
|
+
availabilityLabel: "Trusted Access Program"
|
|
36175
|
+
}
|
|
36176
|
+
}
|
|
36177
|
+
},
|
|
36178
|
+
openProviderPatterns: {
|
|
36179
|
+
openrouter: OPENROUTER_MODEL_SLUG_PATTERN
|
|
36180
|
+
},
|
|
36181
|
+
defaultReasoningEffort: "medium",
|
|
36182
|
+
reasoningEfforts: CODEX_REASONING_EFFORTS,
|
|
36183
|
+
reasoningEffortsByModel: {
|
|
36184
|
+
openai: {
|
|
36185
|
+
"gpt-6-astra": {
|
|
36186
|
+
defaultEffort: "medium",
|
|
36187
|
+
efforts: CODEX_ASTRA_REASONING_EFFORTS
|
|
36188
|
+
},
|
|
36189
|
+
"gpt-5.6-sol": {
|
|
36190
|
+
defaultEffort: "medium",
|
|
36191
|
+
efforts: CODEX_MAX_REASONING_EFFORTS
|
|
36192
|
+
},
|
|
36193
|
+
"gpt-5.6-terra": {
|
|
36194
|
+
defaultEffort: "medium",
|
|
36195
|
+
efforts: CODEX_MAX_REASONING_EFFORTS
|
|
36196
|
+
},
|
|
36197
|
+
"gpt-5.6-luna": {
|
|
36198
|
+
defaultEffort: "medium",
|
|
36199
|
+
efforts: CODEX_MAX_REASONING_EFFORTS
|
|
36200
|
+
},
|
|
36201
|
+
"gpt-5.5": {
|
|
36202
|
+
defaultEffort: "medium",
|
|
36203
|
+
efforts: CODEX_REASONING_EFFORTS
|
|
36204
|
+
},
|
|
36205
|
+
"gpt-5.3-codex": {
|
|
36206
|
+
defaultEffort: "medium",
|
|
36207
|
+
efforts: CODEX_REASONING_EFFORTS
|
|
36208
|
+
}
|
|
36209
|
+
},
|
|
36210
|
+
openrouter: {
|
|
36211
|
+
"moonshotai/kimi-k3": {
|
|
36212
|
+
defaultEffort: "high",
|
|
36213
|
+
efforts: ["high", "xhigh"]
|
|
36214
|
+
},
|
|
36215
|
+
"z-ai/glm-5.2": {
|
|
36216
|
+
defaultEffort: "high",
|
|
36217
|
+
efforts: ["high", "xhigh"]
|
|
36218
|
+
},
|
|
36219
|
+
"x-ai/grok-4.5": {
|
|
36220
|
+
defaultEffort: "high",
|
|
36221
|
+
efforts: ["medium", "high"]
|
|
36222
|
+
},
|
|
36223
|
+
"anthropic/claude-sonnet-5": {
|
|
36224
|
+
defaultEffort: "medium",
|
|
36225
|
+
efforts: ["low", "medium", "high", "xhigh"]
|
|
36226
|
+
},
|
|
36227
|
+
"moonshotai/kimi-k2.7-code": {
|
|
36228
|
+
defaultEffort: "high",
|
|
36229
|
+
efforts: ["high", "xhigh"]
|
|
36230
|
+
}
|
|
36231
|
+
}
|
|
36232
|
+
}
|
|
36233
|
+
}
|
|
36234
|
+
};
|
|
36235
|
+
function modelRulesForHarness(harness) {
|
|
36236
|
+
return HARNESS_MODEL_RULES[harness];
|
|
36237
|
+
}
|
|
36238
|
+
var MODEL_WIRE_ID_ALIASES = {
|
|
36239
|
+
fable: "claude-fable-5-1"
|
|
36240
|
+
};
|
|
36241
|
+
function resolveModelWireId(id) {
|
|
36242
|
+
return MODEL_WIRE_ID_ALIASES[id] ?? id;
|
|
36243
|
+
}
|
|
36244
|
+
function reasoningEffortRulesForModelSelection(input) {
|
|
36245
|
+
const rules = modelRulesForHarness(input.harness);
|
|
36246
|
+
const model = resolveModelSelectionForHarness(input.harness, input.model);
|
|
36247
|
+
return rules.reasoningEffortsByModel[model.provider]?.[model.id] ?? {
|
|
36248
|
+
defaultEffort: rules.defaultReasoningEffort,
|
|
36249
|
+
efforts: rules.reasoningEfforts
|
|
36250
|
+
};
|
|
36251
|
+
}
|
|
36252
|
+
function resolveModelSelectionForHarness(harness, selection) {
|
|
36253
|
+
const rules = modelRulesForHarness(harness);
|
|
36254
|
+
const provider = selection?.provider ?? rules.defaultProvider;
|
|
36255
|
+
const id = selection?.id ?? rules.defaultModel;
|
|
36256
|
+
validateModelProviderForHarness(harness, provider);
|
|
36257
|
+
validateModelIdForProvider({ harness, provider, id });
|
|
36258
|
+
return { provider, id };
|
|
36259
|
+
}
|
|
36260
|
+
function validateReasoningEffortForHarness(input) {
|
|
36261
|
+
if (!input.reasoningEffort) {
|
|
36262
|
+
return;
|
|
36263
|
+
}
|
|
36264
|
+
const rules = reasoningEffortRulesForModelSelection({
|
|
36265
|
+
harness: input.harness,
|
|
36266
|
+
model: input.model
|
|
36267
|
+
});
|
|
36268
|
+
if (!rules.efforts.includes(input.reasoningEffort)) {
|
|
36269
|
+
throw new InvalidModelSelectionError(
|
|
36270
|
+
`${input.harness} does not support reasoning effort "${input.reasoningEffort}"`
|
|
36271
|
+
);
|
|
36272
|
+
}
|
|
36273
|
+
}
|
|
36274
|
+
function validateAgentModelOpenRouterForHarness(spec, context) {
|
|
36275
|
+
const openrouter = spec.model?.openrouter;
|
|
36276
|
+
if (!openrouter) {
|
|
36277
|
+
return;
|
|
36278
|
+
}
|
|
36279
|
+
if (spec.resolvedModel?.provider !== "openrouter") {
|
|
36280
|
+
context.addIssue({
|
|
36281
|
+
code: external_exports.ZodIssueCode.custom,
|
|
36282
|
+
path: ["model", "openrouter"],
|
|
36283
|
+
message: `model.openrouter is only valid when the resolved provider is openrouter (got ${spec.resolvedModel?.provider ?? "none"})`
|
|
36284
|
+
});
|
|
36285
|
+
return;
|
|
36286
|
+
}
|
|
36287
|
+
const primaryId = spec.resolvedModel.id;
|
|
36288
|
+
const seen = /* @__PURE__ */ new Set();
|
|
36289
|
+
for (const [index, id] of openrouter.models.entries()) {
|
|
36290
|
+
if (id === primaryId) {
|
|
36291
|
+
context.addIssue({
|
|
36292
|
+
code: external_exports.ZodIssueCode.custom,
|
|
36293
|
+
path: ["model", "openrouter", "models", index],
|
|
36294
|
+
message: "model.openrouter.models must not include the primary model id (it is prepended automatically)"
|
|
36295
|
+
});
|
|
36296
|
+
return;
|
|
36297
|
+
}
|
|
36298
|
+
if (seen.has(id)) {
|
|
36299
|
+
context.addIssue({
|
|
36300
|
+
code: external_exports.ZodIssueCode.custom,
|
|
36301
|
+
path: ["model", "openrouter", "models", index],
|
|
36302
|
+
message: "model.openrouter.models must not contain duplicate entries"
|
|
36303
|
+
});
|
|
36304
|
+
return;
|
|
36305
|
+
}
|
|
36306
|
+
seen.add(id);
|
|
36307
|
+
}
|
|
36308
|
+
}
|
|
36309
|
+
function validateAgentModelFallbacksForHarness(spec, context) {
|
|
36310
|
+
const fallbacks = spec.model?.fallbacks;
|
|
36311
|
+
if (!fallbacks || fallbacks.length === 0) {
|
|
36312
|
+
return;
|
|
36313
|
+
}
|
|
36314
|
+
if (spec.model?.openrouter) {
|
|
36315
|
+
context.addIssue({
|
|
36316
|
+
code: external_exports.ZodIssueCode.custom,
|
|
36317
|
+
path: ["model", "fallbacks"],
|
|
36318
|
+
message: "model.fallbacks and model.openrouter cannot be combined"
|
|
36319
|
+
});
|
|
36320
|
+
return;
|
|
36321
|
+
}
|
|
36322
|
+
const primary = spec.resolvedModel;
|
|
36323
|
+
if (!primary) {
|
|
36324
|
+
return;
|
|
36325
|
+
}
|
|
36326
|
+
const seenIds = /* @__PURE__ */ new Set([primary.id]);
|
|
36327
|
+
for (const [index, fallback] of fallbacks.entries()) {
|
|
36328
|
+
let resolved;
|
|
36329
|
+
try {
|
|
36330
|
+
resolved = resolveModelSelectionForHarness(spec.harness, {
|
|
36331
|
+
provider: fallback.provider ?? primary.provider,
|
|
36332
|
+
id: fallback.id
|
|
36333
|
+
});
|
|
36334
|
+
} catch (error51) {
|
|
36335
|
+
context.addIssue({
|
|
36336
|
+
code: external_exports.ZodIssueCode.custom,
|
|
36337
|
+
path: ["model", "fallbacks", index],
|
|
36338
|
+
message: error51 instanceof Error ? error51.message : String(error51)
|
|
36339
|
+
});
|
|
36340
|
+
continue;
|
|
36341
|
+
}
|
|
36342
|
+
if (resolved.provider !== primary.provider) {
|
|
36343
|
+
context.addIssue({
|
|
36344
|
+
code: external_exports.ZodIssueCode.custom,
|
|
36345
|
+
path: ["model", "fallbacks", index, "provider"],
|
|
36346
|
+
message: `model.fallbacks entries must resolve to the primary's provider (${primary.provider}); got ${resolved.provider}`
|
|
36347
|
+
});
|
|
36348
|
+
continue;
|
|
36349
|
+
}
|
|
36350
|
+
if (seenIds.has(resolved.id)) {
|
|
36351
|
+
context.addIssue({
|
|
36352
|
+
code: external_exports.ZodIssueCode.custom,
|
|
36353
|
+
path: ["model", "fallbacks", index, "id"],
|
|
36354
|
+
message: "model.fallbacks ids must be distinct and must not repeat the primary model id"
|
|
36355
|
+
});
|
|
36356
|
+
continue;
|
|
36357
|
+
}
|
|
36358
|
+
seenIds.add(resolved.id);
|
|
36359
|
+
try {
|
|
36360
|
+
validateReasoningEffortForHarness({
|
|
36361
|
+
harness: spec.harness,
|
|
36362
|
+
model: resolved,
|
|
36363
|
+
reasoningEffort: spec.reasoningEffort
|
|
36364
|
+
});
|
|
36365
|
+
} catch (error51) {
|
|
36366
|
+
context.addIssue({
|
|
36367
|
+
code: external_exports.ZodIssueCode.custom,
|
|
36368
|
+
path: ["model", "fallbacks", index],
|
|
36369
|
+
message: error51 instanceof Error ? error51.message : String(error51)
|
|
36370
|
+
});
|
|
36371
|
+
}
|
|
36372
|
+
}
|
|
36373
|
+
}
|
|
36374
|
+
function validateAgentModelFieldsForHarness(spec, context) {
|
|
36375
|
+
const harness = spec.harness;
|
|
36376
|
+
if (harness !== "claude-code" && harness !== "codex") {
|
|
36377
|
+
return;
|
|
36378
|
+
}
|
|
36379
|
+
let resolvedModel;
|
|
36380
|
+
try {
|
|
36381
|
+
resolvedModel = resolveModelSelectionForHarness(harness, spec.model);
|
|
36382
|
+
} catch (error51) {
|
|
36383
|
+
context.addIssue({
|
|
36384
|
+
code: external_exports.ZodIssueCode.custom,
|
|
36385
|
+
path: ["model"],
|
|
36386
|
+
message: error51 instanceof Error ? error51.message : String(error51)
|
|
36387
|
+
});
|
|
36388
|
+
}
|
|
36389
|
+
try {
|
|
36390
|
+
validateReasoningEffortForHarness({
|
|
36391
|
+
harness,
|
|
36392
|
+
model: resolvedModel,
|
|
36393
|
+
reasoningEffort: spec.reasoningEffort
|
|
36394
|
+
});
|
|
36395
|
+
} catch (error51) {
|
|
36396
|
+
context.addIssue({
|
|
36397
|
+
code: external_exports.ZodIssueCode.custom,
|
|
36398
|
+
path: ["reasoningEffort"],
|
|
36399
|
+
message: error51 instanceof Error ? error51.message : String(error51)
|
|
36400
|
+
});
|
|
36401
|
+
}
|
|
36402
|
+
validateAgentModelOpenRouterForHarness(
|
|
36403
|
+
{ harness, model: spec.model, resolvedModel },
|
|
36404
|
+
context
|
|
36405
|
+
);
|
|
36406
|
+
validateAgentModelFallbacksForHarness(
|
|
36407
|
+
{
|
|
36408
|
+
harness,
|
|
36409
|
+
model: spec.model,
|
|
36410
|
+
reasoningEffort: spec.reasoningEffort,
|
|
36411
|
+
resolvedModel
|
|
36412
|
+
},
|
|
36413
|
+
context
|
|
36414
|
+
);
|
|
36415
|
+
}
|
|
36416
|
+
function validateModelProviderForHarness(harness, provider) {
|
|
36417
|
+
const rules = modelRulesForHarness(harness);
|
|
36418
|
+
if (!rules.providers.includes(provider)) {
|
|
36419
|
+
throw new InvalidModelSelectionError(
|
|
36420
|
+
`${harness} does not support ${provider} models`
|
|
36421
|
+
);
|
|
36422
|
+
}
|
|
36423
|
+
}
|
|
36424
|
+
function validateModelIdForProvider(input) {
|
|
36425
|
+
const rules = modelRulesForHarness(input.harness);
|
|
36426
|
+
const curated = rules.curatedModels[input.provider];
|
|
36427
|
+
if (curated?.includes(input.id)) {
|
|
36428
|
+
validatePricingForClosedProviderSelection(input);
|
|
36429
|
+
return;
|
|
36430
|
+
}
|
|
36431
|
+
const pattern = rules.openProviderPatterns[input.provider];
|
|
36432
|
+
if (pattern?.test(input.id)) {
|
|
36433
|
+
return;
|
|
36434
|
+
}
|
|
36435
|
+
if (curated) {
|
|
36436
|
+
throw new InvalidModelSelectionError(
|
|
36437
|
+
`${input.provider} model "${input.id}" is not available for ${input.harness}`
|
|
36438
|
+
);
|
|
36439
|
+
}
|
|
36440
|
+
throw new InvalidModelSelectionError(
|
|
36441
|
+
`${input.provider} model ids are not open for ${input.harness}`
|
|
36442
|
+
);
|
|
36443
|
+
}
|
|
36444
|
+
function validatePricingForClosedProviderSelection(input) {
|
|
36445
|
+
if (input.provider === "openrouter") {
|
|
36446
|
+
return;
|
|
36447
|
+
}
|
|
36448
|
+
try {
|
|
36449
|
+
getModelPricing(resolveModelWireId(input.id));
|
|
36450
|
+
} catch (error51) {
|
|
36451
|
+
if (error51 instanceof UnknownPricingModelError || error51 instanceof UnknownPricingVersionError) {
|
|
36452
|
+
throw new InvalidModelSelectionError(
|
|
36453
|
+
`${input.provider} model "${input.id}" cannot be scheduled for ${input.harness} without current pricing`
|
|
36454
|
+
);
|
|
36455
|
+
}
|
|
36456
|
+
throw error51;
|
|
36457
|
+
}
|
|
36458
|
+
}
|
|
36459
|
+
|
|
36460
|
+
// ../../packages/schemas/src/resources.ts
|
|
36461
|
+
var ResourceNameSchema = external_exports.string().trim().min(1).max(128).regex(/^[A-Za-z0-9_.-]+$/);
|
|
36462
|
+
var StringMapSchema = external_exports.record(external_exports.string().min(1), external_exports.string());
|
|
36463
|
+
var MetadataInputSchema = external_exports.object({
|
|
36464
|
+
name: ResourceNameSchema,
|
|
36465
|
+
labels: StringMapSchema.optional(),
|
|
36466
|
+
annotations: StringMapSchema.optional()
|
|
36467
|
+
});
|
|
36468
|
+
var MetadataSchema = MetadataInputSchema.extend({
|
|
36469
|
+
uid: OpaqueIdSchema2,
|
|
36470
|
+
generation: external_exports.number().int().positive(),
|
|
36471
|
+
resourceVersion: external_exports.string().min(1),
|
|
36472
|
+
createdAt: external_exports.string().datetime(),
|
|
36473
|
+
updatedAt: external_exports.string().datetime()
|
|
36474
|
+
});
|
|
36475
|
+
function resourceEnvelopeSchema(spec) {
|
|
36476
|
+
return external_exports.object({
|
|
36477
|
+
metadata: MetadataSchema,
|
|
36478
|
+
spec
|
|
36479
|
+
});
|
|
36480
|
+
}
|
|
36481
|
+
function resourceApplySchema(spec) {
|
|
36482
|
+
return external_exports.object({
|
|
36483
|
+
metadata: MetadataInputSchema,
|
|
36484
|
+
spec
|
|
36485
|
+
});
|
|
36486
|
+
}
|
|
36487
|
+
|
|
36488
|
+
// ../../packages/schemas/src/connections.ts
|
|
36489
|
+
var ConnectionNameSchema = ResourceNameSchema;
|
|
36490
|
+
var ProviderConnectionReferenceSchema = external_exports.object({
|
|
36491
|
+
provider: ProviderNameSchema,
|
|
36492
|
+
connection: ConnectionNameSchema
|
|
36493
|
+
});
|
|
36494
|
+
var ProjectConnectionAllocationSpecSchema = external_exports.object({
|
|
36495
|
+
provider: ProviderNameSchema
|
|
36496
|
+
});
|
|
36497
|
+
var ProjectConnectionAllocationResourceSchema = resourceEnvelopeSchema(
|
|
36498
|
+
ProjectConnectionAllocationSpecSchema
|
|
36499
|
+
);
|
|
36500
|
+
var GithubConnectionAccountSchema = external_exports.object({
|
|
36501
|
+
login: external_exports.string().trim().min(1),
|
|
36502
|
+
type: external_exports.enum(["User", "Organization"])
|
|
36503
|
+
});
|
|
36504
|
+
var GithubConnectionRepositorySchema = external_exports.object({
|
|
36505
|
+
id: external_exports.number().int().positive().optional(),
|
|
36506
|
+
fullName: external_exports.string().trim().min(1)
|
|
36507
|
+
});
|
|
36508
|
+
var GITHUB_CONNECTION_EVENTS = [
|
|
36509
|
+
"installation",
|
|
36510
|
+
"installation_repositories",
|
|
36511
|
+
"push",
|
|
36512
|
+
"pull_request",
|
|
36513
|
+
"check_run",
|
|
36514
|
+
"issues",
|
|
36515
|
+
"issue_comment",
|
|
36516
|
+
"pull_request_review",
|
|
36517
|
+
"pull_request_review_comment",
|
|
36518
|
+
"pull_request_review_thread",
|
|
36519
|
+
// `workflow_run` fires when a GitHub Actions run completes. Auto ingests
|
|
36520
|
+
// only `action=completed` as `github.workflow_run.completed` — the general
|
|
36521
|
+
// "CI on main finished" primitive that `check_run.completed` cannot cover
|
|
36522
|
+
// because check runs hard-require PR association.
|
|
36523
|
+
"workflow_run",
|
|
36524
|
+
// `commit_comment` fires on a new comment attached to a commit (the
|
|
36525
|
+
// quickstart deploy comment that carries the site URL). Auto ingests only
|
|
36526
|
+
// `action=created` as `github.commit_comment.created`.
|
|
36527
|
+
"commit_comment"
|
|
36528
|
+
];
|
|
36529
|
+
var GithubConnectionEventSchema = external_exports.enum(GITHUB_CONNECTION_EVENTS);
|
|
36530
|
+
var GithubConnectionSpecSchema = external_exports.object({
|
|
36531
|
+
provider: external_exports.literal("github"),
|
|
36532
|
+
installationId: external_exports.string().trim().min(1),
|
|
36533
|
+
account: GithubConnectionAccountSchema,
|
|
36534
|
+
repositorySelection: external_exports.enum(["all", "selected"]).default("all"),
|
|
36535
|
+
repositories: external_exports.array(GithubConnectionRepositorySchema).default([]),
|
|
36536
|
+
events: external_exports.array(GithubConnectionEventSchema).min(1).default(["pull_request"])
|
|
36537
|
+
});
|
|
36538
|
+
var ConnectionSpecSchema = GithubConnectionSpecSchema;
|
|
36539
|
+
var ConnectionResourceSchema = resourceEnvelopeSchema(ConnectionSpecSchema);
|
|
36540
|
+
var ConnectionApplyRequestSchema = resourceApplySchema(ConnectionSpecSchema);
|
|
36541
|
+
var ConnectionStartReturnToSchema = external_exports.enum([
|
|
36542
|
+
"onboarding",
|
|
36543
|
+
"connections"
|
|
36544
|
+
]);
|
|
36545
|
+
var GithubRepositoryPickerDestinationSchema = external_exports.enum([
|
|
36546
|
+
"settings",
|
|
36547
|
+
"onboarding",
|
|
36548
|
+
"sessions",
|
|
36549
|
+
"agents"
|
|
36550
|
+
]);
|
|
36551
|
+
var GithubRepositoryPickerContinuationSchema = external_exports.object({
|
|
36552
|
+
organizationId: OrganizationIdSchema,
|
|
36553
|
+
projectId: ProjectIdSchema,
|
|
36554
|
+
destination: GithubRepositoryPickerDestinationSchema
|
|
36555
|
+
});
|
|
36556
|
+
var ConnectionStartRequestSchema = external_exports.object({
|
|
36557
|
+
organizationId: OrganizationIdSchema.optional(),
|
|
36558
|
+
provider: ProviderNameSchema,
|
|
36559
|
+
allowProjectId: ProjectIdSchema.optional(),
|
|
36560
|
+
returnTo: ConnectionStartReturnToSchema.optional(),
|
|
36561
|
+
githubRepositoryPickerDestination: GithubRepositoryPickerDestinationSchema.optional(),
|
|
36562
|
+
replace: external_exports.object({
|
|
36563
|
+
connection: ConnectionNameSchema,
|
|
36564
|
+
removeFirst: external_exports.boolean().default(false)
|
|
36565
|
+
}).optional()
|
|
36566
|
+
}).superRefine((value, context) => {
|
|
36567
|
+
if (value.githubRepositoryPickerDestination && (value.provider !== "github" || !value.allowProjectId)) {
|
|
36568
|
+
context.addIssue({
|
|
36569
|
+
code: "custom",
|
|
36570
|
+
message: "GitHub repository picker continuations require a GitHub project connection",
|
|
36571
|
+
path: ["githubRepositoryPickerDestination"]
|
|
36572
|
+
});
|
|
36573
|
+
}
|
|
36574
|
+
});
|
|
36575
|
+
var ConnectionProviderDescriptorSchema = external_exports.object({
|
|
36576
|
+
provider: ProviderNameSchema,
|
|
36577
|
+
displayName: external_exports.string().trim().min(1),
|
|
36578
|
+
credentialKind: ProviderCredentialKindSchema,
|
|
36579
|
+
oauthManualRedirectSetup: external_exports.object({
|
|
36580
|
+
mode: external_exports.enum(["self_service", "provider_approval"]),
|
|
36581
|
+
explanation: external_exports.string().trim().min(1),
|
|
36582
|
+
instructions: external_exports.array(external_exports.string().trim().min(1)).min(1),
|
|
36583
|
+
callbackUrl: external_exports.string().trim().url(),
|
|
36584
|
+
documentationAction: external_exports.object({
|
|
36585
|
+
label: external_exports.string().trim().min(1),
|
|
36586
|
+
url: external_exports.string().trim().url()
|
|
36587
|
+
}),
|
|
36588
|
+
settingsAction: external_exports.object({
|
|
36589
|
+
label: external_exports.string().trim().min(1),
|
|
36590
|
+
url: external_exports.string().trim().url()
|
|
36591
|
+
}).optional()
|
|
36592
|
+
}).optional()
|
|
36593
|
+
});
|
|
36594
|
+
var ConnectionProviderListResponseSchema = external_exports.object({
|
|
36595
|
+
providers: external_exports.array(ConnectionProviderDescriptorSchema)
|
|
36596
|
+
});
|
|
36597
|
+
var ConnectionStartResponseSchema = external_exports.discriminatedUnion("status", [
|
|
36598
|
+
external_exports.object({
|
|
36599
|
+
status: external_exports.literal("authorization_required"),
|
|
36600
|
+
provider: ProviderNameSchema,
|
|
36601
|
+
authorizationUrl: external_exports.string().trim().url(),
|
|
36602
|
+
message: external_exports.string().trim().min(1)
|
|
36603
|
+
}),
|
|
36604
|
+
external_exports.object({
|
|
36605
|
+
status: external_exports.literal("not_implemented"),
|
|
36606
|
+
provider: ProviderNameSchema,
|
|
36607
|
+
message: external_exports.string().trim().min(1)
|
|
36608
|
+
}),
|
|
36609
|
+
// Providers with no OAuth (Telegram): the user completes manual provider-side
|
|
36610
|
+
// steps, then submits the resulting token to the provider's connection
|
|
36611
|
+
// endpoint. `steps` is ordered, human-readable wizard guidance.
|
|
36612
|
+
external_exports.object({
|
|
36613
|
+
status: external_exports.literal("token_required"),
|
|
36614
|
+
provider: ProviderNameSchema,
|
|
36615
|
+
message: external_exports.string().trim().min(1),
|
|
36616
|
+
steps: external_exports.array(external_exports.string().trim().min(1)).min(1)
|
|
36617
|
+
})
|
|
36618
|
+
]);
|
|
36619
|
+
var TelegramConnectionCreateRequestSchema = external_exports.object({
|
|
36620
|
+
organizationId: OrganizationIdSchema.optional(),
|
|
36621
|
+
token: external_exports.string().trim().min(1),
|
|
36622
|
+
name: ConnectionNameSchema.optional(),
|
|
36623
|
+
validateOnly: external_exports.boolean().default(false),
|
|
36624
|
+
/** Grant this project access to the connection once created. */
|
|
36625
|
+
allowProjectId: ProjectIdSchema.optional()
|
|
36626
|
+
});
|
|
36627
|
+
var TelegramManagerBotSummarySchema = external_exports.object({
|
|
36628
|
+
botUserId: external_exports.string().trim().min(1),
|
|
36629
|
+
botUsername: external_exports.string().trim().min(1),
|
|
36630
|
+
botName: external_exports.string().trim().min(1)
|
|
36631
|
+
});
|
|
36632
|
+
var TelegramConnectionCreateResponseSchema = external_exports.discriminatedUnion(
|
|
36633
|
+
"status",
|
|
36634
|
+
[
|
|
36635
|
+
external_exports.object({
|
|
36636
|
+
status: external_exports.literal("invalid_token"),
|
|
36637
|
+
message: external_exports.string().trim().min(1)
|
|
36638
|
+
}),
|
|
36639
|
+
external_exports.object({
|
|
36640
|
+
status: external_exports.literal("management_mode_disabled"),
|
|
36641
|
+
manager: TelegramManagerBotSummarySchema,
|
|
36642
|
+
message: external_exports.string().trim().min(1)
|
|
36643
|
+
}),
|
|
36644
|
+
external_exports.object({
|
|
36645
|
+
status: external_exports.literal("validated"),
|
|
36646
|
+
manager: TelegramManagerBotSummarySchema,
|
|
36647
|
+
message: external_exports.string().trim().min(1)
|
|
36648
|
+
}),
|
|
36649
|
+
external_exports.object({
|
|
36650
|
+
status: external_exports.literal("connected"),
|
|
36651
|
+
connection: ConnectionNameSchema,
|
|
36652
|
+
manager: TelegramManagerBotSummarySchema,
|
|
36653
|
+
organizationId: OrganizationIdSchema,
|
|
36654
|
+
message: external_exports.string().trim().min(1)
|
|
36655
|
+
})
|
|
36656
|
+
]
|
|
36657
|
+
);
|
|
36658
|
+
var ModelProviderConnectionCreateRequestSchema = external_exports.object({
|
|
36659
|
+
organizationId: OrganizationIdSchema.optional(),
|
|
36660
|
+
provider: ModelApiTokenProviderSchema,
|
|
36661
|
+
token: external_exports.string().trim().min(1),
|
|
36662
|
+
name: ConnectionNameSchema.default("default"),
|
|
36663
|
+
/** Grant this project access to the connection once created. */
|
|
36664
|
+
allowProjectId: ProjectIdSchema.optional()
|
|
36665
|
+
});
|
|
36666
|
+
var ModelProviderConnectionCreateResponseSchema = external_exports.object({
|
|
36667
|
+
status: external_exports.literal("connected"),
|
|
36668
|
+
provider: ModelApiTokenProviderSchema,
|
|
36669
|
+
connection: ConnectionNameSchema,
|
|
36670
|
+
providerGrantId: external_exports.string().trim().min(1),
|
|
36671
|
+
organizationId: OrganizationIdSchema,
|
|
36672
|
+
message: external_exports.string().trim().min(1)
|
|
36673
|
+
});
|
|
36674
|
+
var ConnectionAllowRequestSchema = external_exports.object({
|
|
36675
|
+
organizationId: OrganizationIdSchema.optional(),
|
|
36676
|
+
provider: ProviderNameSchema,
|
|
36677
|
+
projectId: ProjectIdSchema,
|
|
36678
|
+
connection: ConnectionNameSchema.optional()
|
|
36679
|
+
});
|
|
36680
|
+
var SlackConfigTokenRegisterRequestSchema = external_exports.object({
|
|
36681
|
+
connection: ConnectionNameSchema.optional(),
|
|
36682
|
+
workspace: external_exports.string().trim().min(1).optional(),
|
|
36683
|
+
refreshToken: external_exports.string().trim().min(1)
|
|
36684
|
+
});
|
|
36685
|
+
var SlackConfigTokenRegisterResponseSchema = external_exports.object({
|
|
36686
|
+
status: external_exports.literal("registered"),
|
|
36687
|
+
connection: ConnectionNameSchema,
|
|
36688
|
+
workspace: external_exports.string().trim().min(1),
|
|
36689
|
+
expiresAt: external_exports.string().datetime()
|
|
36690
|
+
});
|
|
36691
|
+
var ConnectionAllowResponseSchema = external_exports.object({
|
|
36692
|
+
status: external_exports.literal("allocated"),
|
|
36693
|
+
provider: ProviderNameSchema,
|
|
36694
|
+
projectId: ProjectIdSchema,
|
|
36695
|
+
connection: ConnectionNameSchema,
|
|
36696
|
+
providerGrantId: external_exports.string().trim().min(1),
|
|
36697
|
+
message: external_exports.string().trim().min(1)
|
|
36698
|
+
});
|
|
36699
|
+
var ConnectionRemoveRequestSchema = external_exports.object({
|
|
36700
|
+
organizationId: OrganizationIdSchema.optional(),
|
|
36701
|
+
provider: ProviderNameSchema,
|
|
36702
|
+
connection: ConnectionNameSchema
|
|
36703
|
+
});
|
|
36704
|
+
var ConnectionRemoveResponseSchema = external_exports.object({
|
|
36705
|
+
status: external_exports.literal("removed"),
|
|
36706
|
+
provider: ProviderNameSchema,
|
|
36707
|
+
connection: ConnectionNameSchema,
|
|
36708
|
+
providerGrantId: external_exports.string().trim().min(1),
|
|
36709
|
+
message: external_exports.string().trim().min(1)
|
|
36710
|
+
});
|
|
36711
|
+
|
|
36712
|
+
// ../../packages/schemas/src/mounts.ts
|
|
36713
|
+
var AbsoluteMountPathSchema = external_exports.string().trim().min(1).refine((value) => value.startsWith("/"), {
|
|
36714
|
+
message: "Mount paths must be absolute"
|
|
36715
|
+
});
|
|
36716
|
+
var GITHUB_MOUNT_CAPABILITY_LEVELS = [
|
|
36717
|
+
"none",
|
|
36718
|
+
"read",
|
|
36719
|
+
"write"
|
|
36720
|
+
];
|
|
36721
|
+
var GithubMountCapabilityLevelSchema = external_exports.enum(
|
|
36722
|
+
GITHUB_MOUNT_CAPABILITY_LEVELS
|
|
36723
|
+
);
|
|
36724
|
+
var GithubMountCapabilitySchema = external_exports.union([
|
|
36725
|
+
GithubMountCapabilityLevelSchema,
|
|
36726
|
+
external_exports.object({
|
|
36727
|
+
level: GithubMountCapabilityLevelSchema,
|
|
36728
|
+
unattributed: GithubMountCapabilityLevelSchema
|
|
36729
|
+
}).strict().superRefine((capability, context) => {
|
|
36730
|
+
if (!capabilityLevelAtMost({
|
|
36731
|
+
floor: capability.unattributed,
|
|
36732
|
+
grant: capability.level,
|
|
36733
|
+
levels: GITHUB_MOUNT_CAPABILITY_LEVELS
|
|
36734
|
+
})) {
|
|
36735
|
+
context.addIssue({
|
|
36736
|
+
code: external_exports.ZodIssueCode.custom,
|
|
36737
|
+
message: "unattributed capability level must not exceed level",
|
|
36738
|
+
path: ["unattributed"]
|
|
36739
|
+
});
|
|
36740
|
+
}
|
|
36741
|
+
})
|
|
36742
|
+
]);
|
|
36743
|
+
var GITHUB_MOUNT_MERGE_CAPABILITY_LEVELS = ["none", "write"];
|
|
36744
|
+
var GithubMountMergeCapabilityLevelSchema = external_exports.enum(
|
|
36745
|
+
GITHUB_MOUNT_MERGE_CAPABILITY_LEVELS
|
|
36746
|
+
);
|
|
36747
|
+
var GithubMountMergeCapabilitySchema = external_exports.union([
|
|
36748
|
+
GithubMountMergeCapabilityLevelSchema,
|
|
36749
|
+
external_exports.object({
|
|
36750
|
+
level: GithubMountMergeCapabilityLevelSchema,
|
|
36751
|
+
unattributed: GithubMountMergeCapabilityLevelSchema
|
|
36752
|
+
}).strict().superRefine((capability, context) => {
|
|
36753
|
+
if (!capabilityLevelAtMost({
|
|
36754
|
+
floor: capability.unattributed,
|
|
36755
|
+
grant: capability.level,
|
|
36756
|
+
levels: GITHUB_MOUNT_MERGE_CAPABILITY_LEVELS
|
|
36757
|
+
})) {
|
|
36758
|
+
context.addIssue({
|
|
36759
|
+
code: external_exports.ZodIssueCode.custom,
|
|
36760
|
+
message: "unattributed capability level must not exceed level",
|
|
36761
|
+
path: ["unattributed"]
|
|
36762
|
+
});
|
|
36763
|
+
}
|
|
36764
|
+
})
|
|
36765
|
+
]);
|
|
36766
|
+
var DEFAULT_GITHUB_MOUNT_CAPABILITIES = {
|
|
36767
|
+
contents: "write",
|
|
36768
|
+
pullRequests: "write",
|
|
36769
|
+
issues: "write",
|
|
36770
|
+
checks: "read",
|
|
36771
|
+
actions: "read",
|
|
36772
|
+
workflows: "none",
|
|
36773
|
+
secrets: "none",
|
|
36774
|
+
merge: "none"
|
|
36775
|
+
};
|
|
36776
|
+
var GitMountAuthSchema = external_exports.discriminatedUnion("kind", [
|
|
36777
|
+
external_exports.object({
|
|
36778
|
+
kind: external_exports.literal("none")
|
|
36779
|
+
}),
|
|
36780
|
+
external_exports.object({
|
|
36781
|
+
kind: external_exports.literal("githubApp"),
|
|
36782
|
+
installationId: external_exports.string().trim().min(1).optional(),
|
|
36783
|
+
commitAuthor: external_exports.object({
|
|
36784
|
+
name: external_exports.string().trim().min(1),
|
|
36785
|
+
email: external_exports.string().trim().min(1).refine((value) => value.includes("@"), {
|
|
36786
|
+
message: "Git commit author email must contain @"
|
|
36787
|
+
})
|
|
36788
|
+
}).optional(),
|
|
36789
|
+
capabilities: external_exports.object({
|
|
36790
|
+
contents: GithubMountCapabilitySchema.default("write"),
|
|
36791
|
+
pullRequests: GithubMountCapabilitySchema.default("write"),
|
|
36792
|
+
issues: GithubMountCapabilitySchema.default("write"),
|
|
36793
|
+
checks: GithubMountCapabilitySchema.default("read"),
|
|
36794
|
+
actions: GithubMountCapabilitySchema.default("read"),
|
|
36795
|
+
workflows: GithubMountCapabilitySchema.default("none"),
|
|
36796
|
+
// Grants the GitHub Actions secrets API (repository and environment
|
|
36797
|
+
// secrets). Secret values are write-only on GitHub's side; read grants
|
|
36798
|
+
// listing secret names, never values.
|
|
36799
|
+
secrets: GithubMountCapabilitySchema.default("none"),
|
|
36800
|
+
merge: GithubMountMergeCapabilitySchema.default("none")
|
|
36801
|
+
}).strict().superRefine((capabilities, context) => {
|
|
36802
|
+
if (grantedCapabilityLevel(capabilities.merge) === "write" && (grantedCapabilityLevel(capabilities.contents) !== "write" || grantedCapabilityLevel(capabilities.pullRequests) !== "write")) {
|
|
36803
|
+
context.addIssue({
|
|
36804
|
+
code: external_exports.ZodIssueCode.custom,
|
|
36805
|
+
message: "merge: write requires contents: write and pullRequests: write",
|
|
36806
|
+
path: ["merge"]
|
|
36807
|
+
});
|
|
36808
|
+
}
|
|
36809
|
+
const unattributed = effectiveGithubMountCapabilities(
|
|
36810
|
+
capabilities,
|
|
36811
|
+
false
|
|
36812
|
+
);
|
|
36813
|
+
if (unattributed.merge === "write" && (unattributed.contents !== "write" || unattributed.pullRequests !== "write")) {
|
|
36814
|
+
context.addIssue({
|
|
36815
|
+
code: external_exports.ZodIssueCode.custom,
|
|
36816
|
+
message: "unattributed merge: write requires unattributed contents: write and pullRequests: write",
|
|
36817
|
+
path: ["merge"]
|
|
36818
|
+
});
|
|
36819
|
+
}
|
|
36820
|
+
}).default({ ...DEFAULT_GITHUB_MOUNT_CAPABILITIES })
|
|
36821
|
+
})
|
|
36822
|
+
]);
|
|
36823
|
+
var GitMountSchema = external_exports.object({
|
|
36824
|
+
kind: external_exports.literal("git"),
|
|
36825
|
+
repository: external_exports.string().trim().min(1),
|
|
36826
|
+
mountPath: AbsoluteMountPathSchema,
|
|
36827
|
+
ref: external_exports.string().trim().min(1).optional(),
|
|
36828
|
+
depth: external_exports.number().int().positive().optional(),
|
|
36829
|
+
auth: GitMountAuthSchema.default({
|
|
36830
|
+
kind: "none"
|
|
36831
|
+
})
|
|
36832
|
+
});
|
|
36833
|
+
var AgentMountSchema = external_exports.discriminatedUnion("kind", [GitMountSchema]);
|
|
36834
|
+
function effectiveGithubMountCapabilities(capabilities, requesterEligible) {
|
|
36835
|
+
return {
|
|
36836
|
+
actions: effectiveCapabilityLevel(capabilities.actions, requesterEligible),
|
|
36837
|
+
checks: effectiveCapabilityLevel(capabilities.checks, requesterEligible),
|
|
36838
|
+
contents: effectiveCapabilityLevel(
|
|
36839
|
+
capabilities.contents,
|
|
36840
|
+
requesterEligible
|
|
36841
|
+
),
|
|
36842
|
+
issues: effectiveCapabilityLevel(capabilities.issues, requesterEligible),
|
|
36843
|
+
merge: effectiveCapabilityLevel(capabilities.merge, requesterEligible),
|
|
36844
|
+
pullRequests: effectiveCapabilityLevel(
|
|
36845
|
+
capabilities.pullRequests,
|
|
36846
|
+
requesterEligible
|
|
36847
|
+
),
|
|
36848
|
+
secrets: effectiveCapabilityLevel(capabilities.secrets, requesterEligible),
|
|
36849
|
+
workflows: effectiveCapabilityLevel(
|
|
36850
|
+
capabilities.workflows,
|
|
36851
|
+
requesterEligible
|
|
36852
|
+
)
|
|
36853
|
+
};
|
|
36854
|
+
}
|
|
36855
|
+
|
|
36856
|
+
// ../../packages/schemas/src/github-sync.ts
|
|
36857
|
+
var GITHUB_SYNC_AUTO_PATH = ".auto";
|
|
36858
|
+
var GITHUB_SYNC_CI_WATCHDOG_DEFAULT_DELAY_MS = 15e3;
|
|
36859
|
+
var GithubSyncRepositoryFullNameSchema = external_exports.string().trim().min(1).regex(/^[^/\s]+\/[^/\s]+$/, {
|
|
36860
|
+
message: "repository must be in owner/name form"
|
|
36861
|
+
});
|
|
36862
|
+
var GithubSyncProductionBranchSchema = external_exports.string().trim().min(1).max(255).refine((branch) => !branch.startsWith("/") && !branch.endsWith("/"), {
|
|
36863
|
+
message: "branch must not start or end with /"
|
|
36864
|
+
});
|
|
36865
|
+
var GithubSyncCiWatchdogWorkflowSchema = external_exports.object({
|
|
36866
|
+
workflowId: external_exports.string().trim().min(1).max(255)
|
|
36867
|
+
}).strict();
|
|
36868
|
+
var GithubSyncCiWatchdogSchema = external_exports.object({
|
|
36869
|
+
workflows: external_exports.array(GithubSyncCiWatchdogWorkflowSchema).max(10).default([]),
|
|
36870
|
+
checkDelayMs: external_exports.number().int().nonnegative().default(GITHUB_SYNC_CI_WATCHDOG_DEFAULT_DELAY_MS)
|
|
36871
|
+
}).strict();
|
|
36872
|
+
var GithubSyncBindingSchema = external_exports.object({
|
|
36873
|
+
id: external_exports.string().trim().min(1),
|
|
36874
|
+
organizationId: OrganizationIdSchema,
|
|
36875
|
+
projectId: ProjectIdSchema,
|
|
36876
|
+
providerGrantId: ProviderGrantIdSchema,
|
|
36877
|
+
installationId: external_exports.string().trim().min(1),
|
|
36878
|
+
repoFullName: GithubSyncRepositoryFullNameSchema,
|
|
36879
|
+
repoId: external_exports.string().trim().min(1).nullable(),
|
|
36880
|
+
productionBranch: GithubSyncProductionBranchSchema,
|
|
36881
|
+
autoPath: external_exports.literal(GITHUB_SYNC_AUTO_PATH),
|
|
36882
|
+
ciWatchdog: GithubSyncCiWatchdogSchema,
|
|
36883
|
+
enabled: external_exports.boolean(),
|
|
36884
|
+
lastPlannedSha: external_exports.string().trim().min(1).nullable(),
|
|
36885
|
+
lastAppliedSha: external_exports.string().trim().min(1).nullable(),
|
|
36886
|
+
createdAt: external_exports.string().datetime(),
|
|
36887
|
+
updatedAt: external_exports.string().datetime()
|
|
36888
|
+
});
|
|
36889
|
+
var GithubSyncBindingCreateRequestSchema = external_exports.object({
|
|
36890
|
+
connection: external_exports.string().trim().min(1).optional(),
|
|
36891
|
+
repo: GithubSyncRepositoryFullNameSchema,
|
|
36892
|
+
repoId: external_exports.string().trim().min(1).optional(),
|
|
36893
|
+
branch: GithubSyncProductionBranchSchema.optional(),
|
|
36894
|
+
ciWatchdog: GithubSyncCiWatchdogSchema.optional()
|
|
36895
|
+
});
|
|
36896
|
+
var GithubSyncInitialSyncSchema = external_exports.object({
|
|
36897
|
+
started: external_exports.boolean(),
|
|
36898
|
+
headSha: external_exports.string().trim().min(1).optional(),
|
|
36899
|
+
workflowId: external_exports.string().trim().min(1).optional(),
|
|
36900
|
+
reason: external_exports.enum([
|
|
36901
|
+
"no_auto_directory",
|
|
36902
|
+
"already_applied",
|
|
36903
|
+
"probe_failed",
|
|
36904
|
+
"start_failed"
|
|
36905
|
+
]).optional()
|
|
36906
|
+
});
|
|
36907
|
+
var GithubSyncBindingCreateResponseSchema = external_exports.object({
|
|
36908
|
+
binding: GithubSyncBindingSchema,
|
|
36909
|
+
created: external_exports.boolean(),
|
|
36910
|
+
initialSync: GithubSyncInitialSyncSchema.optional()
|
|
36911
|
+
});
|
|
36912
|
+
var GithubSyncBindingListResponseSchema = external_exports.object({
|
|
36913
|
+
bindings: external_exports.array(GithubSyncBindingSchema)
|
|
36914
|
+
});
|
|
36915
|
+
var GithubSyncBindingDisableResponseSchema = external_exports.object({
|
|
36916
|
+
binding: GithubSyncBindingSchema.nullable()
|
|
36917
|
+
});
|
|
36918
|
+
var GithubSyncTriggerArtifactSchema = external_exports.object({
|
|
36919
|
+
type: external_exports.string().trim().min(1),
|
|
36920
|
+
externalId: external_exports.string().trim().min(1),
|
|
36921
|
+
payload: JsonValueSchema2.optional()
|
|
36922
|
+
}).strict();
|
|
36923
|
+
var GithubSyncWorkflowInputSchema = external_exports.discriminatedUnion("kind", [
|
|
36924
|
+
external_exports.object({
|
|
36925
|
+
kind: external_exports.literal("pull_request"),
|
|
36926
|
+
bindingId: external_exports.string().trim().min(1),
|
|
36927
|
+
organizationId: OrganizationIdSchema,
|
|
36928
|
+
projectId: ProjectIdSchema,
|
|
36929
|
+
providerGrantId: ProviderGrantIdSchema,
|
|
36930
|
+
installationId: external_exports.string().trim().min(1),
|
|
36931
|
+
repoFullName: GithubSyncRepositoryFullNameSchema,
|
|
36932
|
+
repoId: external_exports.string().trim().min(1).optional(),
|
|
36933
|
+
productionBranch: GithubSyncProductionBranchSchema,
|
|
36934
|
+
autoPath: external_exports.literal(GITHUB_SYNC_AUTO_PATH),
|
|
36935
|
+
pullRequestNumber: external_exports.number().int().positive(),
|
|
36936
|
+
headSha: external_exports.string().trim().min(1),
|
|
36937
|
+
baseSha: external_exports.string().trim().min(1).optional(),
|
|
36938
|
+
baseRef: GithubSyncProductionBranchSchema,
|
|
36939
|
+
triggerArtifact: GithubSyncTriggerArtifactSchema.optional()
|
|
36940
|
+
}),
|
|
36941
|
+
external_exports.object({
|
|
36942
|
+
kind: external_exports.literal("push"),
|
|
36943
|
+
bindingId: external_exports.string().trim().min(1),
|
|
36944
|
+
organizationId: OrganizationIdSchema,
|
|
36945
|
+
projectId: ProjectIdSchema,
|
|
36946
|
+
providerGrantId: ProviderGrantIdSchema,
|
|
36947
|
+
installationId: external_exports.string().trim().min(1),
|
|
36948
|
+
repoFullName: GithubSyncRepositoryFullNameSchema,
|
|
36949
|
+
repoId: external_exports.string().trim().min(1).optional(),
|
|
36950
|
+
productionBranch: GithubSyncProductionBranchSchema,
|
|
36951
|
+
autoPath: external_exports.literal(GITHUB_SYNC_AUTO_PATH),
|
|
36952
|
+
ref: external_exports.string().trim().min(1),
|
|
36953
|
+
branch: GithubSyncProductionBranchSchema,
|
|
36954
|
+
before: external_exports.string().trim().min(1).optional(),
|
|
36955
|
+
after: external_exports.string().trim().min(1),
|
|
36956
|
+
triggerArtifact: GithubSyncTriggerArtifactSchema.optional()
|
|
36957
|
+
}),
|
|
36958
|
+
// Synthetic re-apply triggered by a managed-template version bump (not a
|
|
36959
|
+
// webhook). The tenant's `.auto` is unchanged — only our registry changed —
|
|
36960
|
+
// so this arm skips the `no_auto_changes` early-out and applies the production
|
|
36961
|
+
// branch HEAD (`after`, which the sweep resolves before starting the run).
|
|
36962
|
+
// It is otherwise push-shaped. New waves carry the complete bounded
|
|
36963
|
+
// `templates` set plus a deterministic `waveId`; legacy single-template
|
|
36964
|
+
// coordinates remain accepted only so in-flight workflows can replay.
|
|
36965
|
+
external_exports.object({
|
|
36966
|
+
kind: external_exports.literal("template_push"),
|
|
36967
|
+
bindingId: external_exports.string().trim().min(1),
|
|
36968
|
+
organizationId: OrganizationIdSchema,
|
|
36969
|
+
projectId: ProjectIdSchema,
|
|
36970
|
+
providerGrantId: ProviderGrantIdSchema,
|
|
36971
|
+
installationId: external_exports.string().trim().min(1),
|
|
36972
|
+
repoFullName: GithubSyncRepositoryFullNameSchema,
|
|
36973
|
+
repoId: external_exports.string().trim().min(1).optional(),
|
|
36974
|
+
productionBranch: GithubSyncProductionBranchSchema,
|
|
36975
|
+
autoPath: external_exports.literal(GITHUB_SYNC_AUTO_PATH),
|
|
36976
|
+
before: external_exports.string().trim().min(1).optional(),
|
|
36977
|
+
after: external_exports.string().trim().min(1),
|
|
36978
|
+
// Legacy single-template coordinates remain optional so in-flight
|
|
36979
|
+
// workflows started by a pre-wave worker can finish after deployment.
|
|
36980
|
+
templateName: external_exports.string().trim().min(1).optional(),
|
|
36981
|
+
version: external_exports.string().trim().min(1).optional(),
|
|
36982
|
+
waveId: external_exports.string().trim().min(1).optional(),
|
|
36983
|
+
// A bounded operator repair can re-run an already-terminal wave without
|
|
36984
|
+
// reusing its completed Temporal workflow or apply operation. Ordinary
|
|
36985
|
+
// subscription sweeps omit this field.
|
|
36986
|
+
retryAttempt: external_exports.number().int().positive().max(9).optional(),
|
|
36987
|
+
templates: external_exports.array(
|
|
36988
|
+
external_exports.object({
|
|
36989
|
+
name: external_exports.string().trim().min(1),
|
|
36990
|
+
version: external_exports.string().trim().min(1)
|
|
36991
|
+
})
|
|
36992
|
+
).min(1).max(50).optional(),
|
|
36993
|
+
triggerArtifact: GithubSyncTriggerArtifactSchema.optional()
|
|
36994
|
+
}).superRefine((input, context) => {
|
|
36995
|
+
const legacy = Boolean(input.templateName && input.version);
|
|
36996
|
+
const wave = Boolean(input.waveId && input.templates);
|
|
36997
|
+
if (legacy === wave) {
|
|
36998
|
+
context.addIssue({
|
|
36999
|
+
code: "custom",
|
|
37000
|
+
message: "template_push requires exactly one of legacy templateName/version or waveId/templates"
|
|
37001
|
+
});
|
|
37002
|
+
}
|
|
37003
|
+
if (input.retryAttempt && !wave) {
|
|
37004
|
+
context.addIssue({
|
|
37005
|
+
code: "custom",
|
|
37006
|
+
message: "template_push retryAttempt requires waveId/templates"
|
|
37007
|
+
});
|
|
37008
|
+
}
|
|
37009
|
+
}),
|
|
37010
|
+
// Synthetic authoritative re-apply triggered by one durable connection
|
|
37011
|
+
// lifecycle occurrence. The event id makes retries reuse the same workflow,
|
|
37012
|
+
// while a later remove/re-allow occurrence can re-run at the same git SHA.
|
|
37013
|
+
external_exports.object({
|
|
37014
|
+
kind: external_exports.literal("connection_push"),
|
|
37015
|
+
bindingId: external_exports.string().trim().min(1),
|
|
37016
|
+
organizationId: OrganizationIdSchema,
|
|
37017
|
+
projectId: ProjectIdSchema,
|
|
37018
|
+
providerGrantId: ProviderGrantIdSchema,
|
|
37019
|
+
installationId: external_exports.string().trim().min(1),
|
|
37020
|
+
repoFullName: GithubSyncRepositoryFullNameSchema,
|
|
37021
|
+
repoId: external_exports.string().trim().min(1).optional(),
|
|
37022
|
+
productionBranch: GithubSyncProductionBranchSchema,
|
|
37023
|
+
autoPath: external_exports.literal(GITHUB_SYNC_AUTO_PATH),
|
|
37024
|
+
before: external_exports.string().trim().min(1).optional(),
|
|
37025
|
+
after: external_exports.string().trim().min(1),
|
|
37026
|
+
connectionEventId: external_exports.string().trim().min(1),
|
|
37027
|
+
triggerArtifact: GithubSyncTriggerArtifactSchema.optional()
|
|
37028
|
+
})
|
|
37029
|
+
]);
|
|
37030
|
+
var GithubSyncWorkflowResultSchema = external_exports.discriminatedUnion("status", [
|
|
37031
|
+
external_exports.object({
|
|
37032
|
+
status: external_exports.literal("skipped"),
|
|
37033
|
+
reason: external_exports.string().trim().min(1)
|
|
37034
|
+
}),
|
|
37035
|
+
external_exports.object({
|
|
37036
|
+
status: external_exports.literal("planned"),
|
|
37037
|
+
changed: external_exports.boolean(),
|
|
37038
|
+
checkRunId: external_exports.number().int().positive().optional()
|
|
37039
|
+
}),
|
|
37040
|
+
external_exports.object({
|
|
37041
|
+
status: external_exports.literal("applied"),
|
|
37042
|
+
changed: external_exports.boolean(),
|
|
37043
|
+
checkRunId: external_exports.number().int().positive().optional()
|
|
37044
|
+
}),
|
|
37045
|
+
external_exports.object({
|
|
37046
|
+
status: external_exports.literal("failed"),
|
|
37047
|
+
message: external_exports.string().trim().min(1),
|
|
37048
|
+
checkRunId: external_exports.number().int().positive().optional()
|
|
37049
|
+
})
|
|
37050
|
+
]);
|
|
37051
|
+
|
|
37052
|
+
// ../../packages/schemas/src/github-mcp-catalog.ts
|
|
37053
|
+
var GITHUB_MCP_TOOL_NAMES = [
|
|
37054
|
+
"actions_get",
|
|
37055
|
+
"actions_list",
|
|
37056
|
+
"actions_run_trigger",
|
|
37057
|
+
"add_comment_to_pending_review",
|
|
37058
|
+
"add_issue_comment",
|
|
37059
|
+
"add_reply_to_pull_request_comment",
|
|
37060
|
+
"create_branch",
|
|
37061
|
+
"create_or_update_file",
|
|
37062
|
+
"create_pull_request",
|
|
37063
|
+
"create_repository",
|
|
37064
|
+
"delete_file",
|
|
37065
|
+
"fork_repository",
|
|
37066
|
+
"get_commit",
|
|
37067
|
+
"get_file_contents",
|
|
37068
|
+
"get_job_logs",
|
|
37069
|
+
"get_label",
|
|
37070
|
+
"get_latest_release",
|
|
37071
|
+
"get_release_by_tag",
|
|
37072
|
+
"get_tag",
|
|
37073
|
+
"issue_read",
|
|
37074
|
+
"issue_write",
|
|
37075
|
+
"list_branches",
|
|
37076
|
+
"list_commits",
|
|
37077
|
+
"list_issue_types",
|
|
37078
|
+
"list_issues",
|
|
37079
|
+
"list_pull_requests",
|
|
37080
|
+
"list_releases",
|
|
37081
|
+
"list_repository_collaborators",
|
|
37082
|
+
"list_tags",
|
|
37083
|
+
"merge_pull_request",
|
|
37084
|
+
"pull_request_read",
|
|
37085
|
+
"pull_request_review_write",
|
|
37086
|
+
"push_files",
|
|
37087
|
+
"search_code",
|
|
37088
|
+
"search_commits",
|
|
37089
|
+
"search_issues",
|
|
37090
|
+
"search_pull_requests",
|
|
37091
|
+
"search_repositories",
|
|
37092
|
+
"sub_issue_write",
|
|
37093
|
+
"update_pull_request",
|
|
37094
|
+
"update_pull_request_branch"
|
|
37095
|
+
];
|
|
37096
|
+
var GITHUB_MCP_PROXY_TOOL_NAMES = [
|
|
37097
|
+
"actions_secret_list",
|
|
37098
|
+
"actions_secret_write",
|
|
37099
|
+
"delete_issue_comment",
|
|
37100
|
+
"download_comment_attachment",
|
|
37101
|
+
"enable_pull_request_auto_merge",
|
|
37102
|
+
"enqueue_pull_request",
|
|
37103
|
+
"rerun_failed_jobs",
|
|
37104
|
+
"rerun_failed_jobs_for_pr_head",
|
|
37105
|
+
"upsert_issue_comment"
|
|
37106
|
+
];
|
|
37107
|
+
var GITHUB_MCP_SELECTABLE_TOOL_NAMES = [
|
|
37108
|
+
...GITHUB_MCP_TOOL_NAMES,
|
|
37109
|
+
...GITHUB_MCP_PROXY_TOOL_NAMES
|
|
37110
|
+
];
|
|
37111
|
+
var GITHUB_MCP_MERGE_TOOLS = [
|
|
37112
|
+
"merge_pull_request",
|
|
37113
|
+
"enable_pull_request_auto_merge",
|
|
37114
|
+
"enqueue_pull_request"
|
|
37115
|
+
];
|
|
37116
|
+
var GITHUB_MCP_SECRETS_TOOLS = [
|
|
37117
|
+
"actions_secret_list",
|
|
37118
|
+
"actions_secret_write"
|
|
37119
|
+
];
|
|
37120
|
+
var GITHUB_MCP_SECRETS_WRITE_TOOLS = [
|
|
37121
|
+
"actions_secret_write"
|
|
37122
|
+
];
|
|
37123
|
+
var GITHUB_MCP_ACTIONS_WRITE_TOOLS = [
|
|
37124
|
+
"rerun_failed_jobs",
|
|
37125
|
+
"rerun_failed_jobs_for_pr_head"
|
|
37126
|
+
];
|
|
37127
|
+
var GITHUB_MCP_WRITE_TOOLS = [
|
|
37128
|
+
"actions_run_trigger",
|
|
37129
|
+
"add_comment_to_pending_review",
|
|
37130
|
+
"add_issue_comment",
|
|
37131
|
+
"add_reply_to_pull_request_comment",
|
|
37132
|
+
"create_branch",
|
|
37133
|
+
"create_or_update_file",
|
|
37134
|
+
"create_pull_request",
|
|
37135
|
+
"create_repository",
|
|
37136
|
+
"delete_file",
|
|
37137
|
+
"fork_repository",
|
|
37138
|
+
"issue_write",
|
|
37139
|
+
"merge_pull_request",
|
|
37140
|
+
"pull_request_review_write",
|
|
37141
|
+
"push_files",
|
|
37142
|
+
"sub_issue_write",
|
|
37143
|
+
"update_pull_request",
|
|
37144
|
+
"update_pull_request_branch"
|
|
37145
|
+
];
|
|
37146
|
+
var githubMcpToolNameSet = new Set(
|
|
37147
|
+
GITHUB_MCP_TOOL_NAMES
|
|
37148
|
+
);
|
|
37149
|
+
var GITHUB_MCP_ATTRIBUTION_EXEMPT_PROXY_TOOLS = /* @__PURE__ */ new Set([
|
|
37150
|
+
"actions_secret_list",
|
|
37151
|
+
"download_comment_attachment",
|
|
37152
|
+
"delete_issue_comment"
|
|
37153
|
+
]);
|
|
37154
|
+
var githubMcpWriteToolSet = /* @__PURE__ */ new Set([
|
|
37155
|
+
...GITHUB_MCP_WRITE_TOOLS,
|
|
37156
|
+
...GITHUB_MCP_PROXY_TOOL_NAMES.filter(
|
|
37157
|
+
(name) => !GITHUB_MCP_ATTRIBUTION_EXEMPT_PROXY_TOOLS.has(name)
|
|
37158
|
+
)
|
|
37159
|
+
]);
|
|
37160
|
+
var githubMcpProxyToolSet = new Set(
|
|
37161
|
+
GITHUB_MCP_PROXY_TOOL_NAMES
|
|
37162
|
+
);
|
|
37163
|
+
var githubMcpMergeToolSet = new Set(
|
|
37164
|
+
GITHUB_MCP_MERGE_TOOLS
|
|
37165
|
+
);
|
|
37166
|
+
var githubMcpSecretsToolSet = new Set(
|
|
37167
|
+
GITHUB_MCP_SECRETS_TOOLS
|
|
37168
|
+
);
|
|
37169
|
+
var githubMcpSecretsWriteToolSet = new Set(
|
|
37170
|
+
GITHUB_MCP_SECRETS_WRITE_TOOLS
|
|
37171
|
+
);
|
|
37172
|
+
var githubMcpActionsWriteToolSet = new Set(
|
|
37173
|
+
GITHUB_MCP_ACTIONS_WRITE_TOOLS
|
|
37174
|
+
);
|
|
37175
|
+
|
|
37176
|
+
// ../../packages/schemas/src/secrets.ts
|
|
37177
|
+
var SECRET_ENCRYPTION_ALGORITHM = "AES-256-GCM";
|
|
37178
|
+
var SecretEnvNameSchema = external_exports.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/);
|
|
37179
|
+
var SecretCiphertextFieldSchema = external_exports.string().trim().min(1).regex(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/);
|
|
37180
|
+
var SecretAesGcmIvSchema = external_exports.string().trim().regex(/^[A-Za-z0-9+/]{16}$/);
|
|
37181
|
+
var SecretAesGcmAuthTagSchema = external_exports.string().trim().regex(/^[A-Za-z0-9+/]{22}==$/);
|
|
37182
|
+
var SecretEnvValueSchema = external_exports.union([
|
|
37183
|
+
external_exports.string(),
|
|
37184
|
+
external_exports.object({
|
|
37185
|
+
$secret: ResourceNameSchema,
|
|
37186
|
+
optional: external_exports.boolean().optional()
|
|
37187
|
+
})
|
|
37188
|
+
]);
|
|
37189
|
+
var SecretEnvSchema = external_exports.record(
|
|
37190
|
+
SecretEnvNameSchema,
|
|
37191
|
+
SecretEnvValueSchema
|
|
37192
|
+
);
|
|
37193
|
+
var EncryptedSecretValueSchema = external_exports.object({
|
|
37194
|
+
keyVersion: external_exports.string().trim().min(1),
|
|
37195
|
+
algorithm: external_exports.literal(SECRET_ENCRYPTION_ALGORITHM),
|
|
37196
|
+
ciphertext: SecretCiphertextFieldSchema,
|
|
37197
|
+
valueIv: SecretAesGcmIvSchema,
|
|
37198
|
+
valueAuthTag: SecretAesGcmAuthTagSchema,
|
|
37199
|
+
encryptedDek: SecretCiphertextFieldSchema,
|
|
37200
|
+
dekIv: SecretAesGcmIvSchema,
|
|
37201
|
+
dekAuthTag: SecretAesGcmAuthTagSchema
|
|
37202
|
+
});
|
|
37203
|
+
var SecretDescriptionSchema = external_exports.string().trim().max(1024);
|
|
37204
|
+
var SECRET_IDLE_EXPIRY_MAX_SECONDS = 10 * 365 * 24 * 60 * 60;
|
|
37205
|
+
var SecretExpiresAtSchema = external_exports.string().datetime({ offset: true });
|
|
37206
|
+
var SecretIdleExpirySecondsSchema = external_exports.number().int().min(1).max(SECRET_IDLE_EXPIRY_MAX_SECONDS);
|
|
37207
|
+
var SECRET_INJECTION_HOST_PATTERN = /^(?=.{1,253}$)([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]([a-z0-9-]{0,61}[a-z0-9])?$/;
|
|
37208
|
+
var SECRET_INJECTION_HEADER_PATTERN = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
|
|
37209
|
+
var SECRET_INJECTION_FORBIDDEN_HEADERS = /* @__PURE__ */ new Set([
|
|
37210
|
+
"connection",
|
|
37211
|
+
"content-length",
|
|
37212
|
+
"host",
|
|
37213
|
+
"transfer-encoding"
|
|
37214
|
+
]);
|
|
37215
|
+
var SecretInjectionHostSchema = external_exports.string().trim().toLowerCase().regex(
|
|
37216
|
+
SECRET_INJECTION_HOST_PATTERN,
|
|
37217
|
+
"Injection hosts must be exact lowercase hostnames (no wildcards, schemes, ports, or paths)"
|
|
37218
|
+
);
|
|
37219
|
+
var SecretInjectionHeaderSchema = external_exports.string().trim().min(1).max(128).regex(SECRET_INJECTION_HEADER_PATTERN, "Invalid HTTP header name").refine(
|
|
37220
|
+
(header) => !SECRET_INJECTION_FORBIDDEN_HEADERS.has(header.toLowerCase()),
|
|
37221
|
+
"This header cannot carry an injected secret"
|
|
37222
|
+
);
|
|
37223
|
+
var SecretInjectionSchema = external_exports.object({
|
|
37224
|
+
hosts: external_exports.array(SecretInjectionHostSchema).min(1).max(16),
|
|
37225
|
+
header: SecretInjectionHeaderSchema,
|
|
37226
|
+
format: external_exports.string().min(1).max(256).refine(
|
|
37227
|
+
(format) => format.includes("{value}"),
|
|
37228
|
+
"Injection format must contain the {value} placeholder"
|
|
37229
|
+
).optional()
|
|
37230
|
+
});
|
|
37231
|
+
var SecretSetRequestSchema = external_exports.object({
|
|
37232
|
+
value: external_exports.string(),
|
|
37233
|
+
description: SecretDescriptionSchema.nullable().optional(),
|
|
37234
|
+
protected: external_exports.boolean().optional(),
|
|
37235
|
+
injection: SecretInjectionSchema.nullable().optional(),
|
|
37236
|
+
expiresAt: SecretExpiresAtSchema.nullable().optional(),
|
|
37237
|
+
idleExpirySeconds: SecretIdleExpirySecondsSchema.nullable().optional()
|
|
37238
|
+
});
|
|
37239
|
+
var SecretExpiryUpdateRequestSchema = external_exports.object({
|
|
37240
|
+
expiresAt: SecretExpiresAtSchema.nullable().optional(),
|
|
37241
|
+
idleExpirySeconds: SecretIdleExpirySecondsSchema.nullable().optional()
|
|
37242
|
+
}).refine(
|
|
37243
|
+
(input) => input.expiresAt !== void 0 || input.idleExpirySeconds !== void 0,
|
|
37244
|
+
{ message: "Provide expiresAt and/or idleExpirySeconds" }
|
|
37245
|
+
);
|
|
37246
|
+
var SecretRotateRequestSchema = external_exports.object({
|
|
37247
|
+
value: external_exports.string()
|
|
37248
|
+
});
|
|
37249
|
+
var SecretMetadataSchema = external_exports.object({
|
|
37250
|
+
id: external_exports.string().trim().min(1),
|
|
37251
|
+
organizationId: external_exports.string().trim().min(1),
|
|
37252
|
+
projectId: external_exports.string().trim().min(1).nullable(),
|
|
37253
|
+
name: ResourceNameSchema,
|
|
37254
|
+
description: external_exports.string().nullable(),
|
|
37255
|
+
protected: external_exports.boolean(),
|
|
37256
|
+
// Defaulted rather than required so a newer client parsing an older
|
|
37257
|
+
// server's metadata (deploy skew) treats an absent injection as plain
|
|
37258
|
+
// env delivery.
|
|
37259
|
+
injection: SecretInjectionSchema.nullable().default(null),
|
|
37260
|
+
createdAt: external_exports.string().datetime(),
|
|
37261
|
+
updatedAt: external_exports.string().datetime(),
|
|
37262
|
+
lastRotatedAt: external_exports.string().datetime().nullable(),
|
|
37263
|
+
lastAccessedAt: external_exports.string().datetime().nullable(),
|
|
37264
|
+
// Like injection, defaulted for deploy skew: an older server that never sends
|
|
37265
|
+
// expiry fields parses as a secret that never expires.
|
|
37266
|
+
expiresAt: external_exports.string().datetime().nullable().default(null),
|
|
37267
|
+
idleExpirySeconds: external_exports.number().int().nullable().default(null),
|
|
37268
|
+
// Computed server-side: true when expiresAt has passed or the secret has
|
|
37269
|
+
// been unused past idleExpirySeconds. Expired secrets resolve as absent
|
|
37270
|
+
// everywhere but stay listed so operators can see and delete them.
|
|
37271
|
+
expired: external_exports.boolean().default(false)
|
|
37272
|
+
});
|
|
37273
|
+
var SecretSetResponseSchema = external_exports.object({
|
|
37274
|
+
secret: SecretMetadataSchema
|
|
37275
|
+
});
|
|
37276
|
+
var SecretListResponseSchema = external_exports.object({
|
|
37277
|
+
secrets: external_exports.array(SecretMetadataSchema)
|
|
37278
|
+
});
|
|
37279
|
+
var SecretDeleteResponseSchema = external_exports.object({
|
|
37280
|
+
secret: SecretMetadataSchema
|
|
37281
|
+
});
|
|
37282
|
+
var SecretExpiryUpdateResponseSchema = external_exports.object({
|
|
37283
|
+
secret: SecretMetadataSchema
|
|
37284
|
+
});
|
|
37285
|
+
var SecretRevealResponseSchema = external_exports.object({
|
|
37286
|
+
secret: SecretMetadataSchema,
|
|
37287
|
+
value: external_exports.string()
|
|
37288
|
+
});
|
|
37289
|
+
|
|
37290
|
+
// ../../packages/schemas/src/persisted-agent-grammar.ts
|
|
37291
|
+
function normalizePersistedAgentGrammar(spec) {
|
|
37292
|
+
const triggers = Array.isArray(spec.triggers) ? spec.triggers : [];
|
|
37293
|
+
const session = record2(spec.session);
|
|
37294
|
+
const legacyGrammar = triggers.some(triggerUsesLegacyGrammar) || bindingsUseLegacyGrammar(spec.bindings) || session?.observeSpawnedSessions !== void 0;
|
|
37295
|
+
if (!legacyGrammar) {
|
|
37296
|
+
return spec;
|
|
37297
|
+
}
|
|
37298
|
+
const bindings = normalizePersistedBindings({
|
|
37299
|
+
bindings: spec.bindings,
|
|
37300
|
+
observeSpawnedSessions: session?.observeSpawnedSessions !== false,
|
|
37301
|
+
triggers
|
|
37302
|
+
});
|
|
37303
|
+
const normalizedSession = session ? Object.fromEntries(
|
|
37304
|
+
Object.entries(session).filter(
|
|
37305
|
+
([key]) => key !== "observeSpawnedSessions"
|
|
37306
|
+
)
|
|
37307
|
+
) : spec.session;
|
|
37308
|
+
return {
|
|
37309
|
+
...spec,
|
|
37310
|
+
bindings,
|
|
37311
|
+
triggers: normalizePersistedTriggers(triggers, spec.bindings),
|
|
37312
|
+
...session ? { session: normalizedSession } : {}
|
|
37313
|
+
};
|
|
37314
|
+
}
|
|
37315
|
+
function normalizePersistedBindings(input) {
|
|
37316
|
+
const policies = /* @__PURE__ */ new Map();
|
|
37317
|
+
const bindings = record2(input.bindings) ?? {};
|
|
37318
|
+
for (const [storedTarget, value] of Object.entries(bindings)) {
|
|
37319
|
+
const entry = record2(value);
|
|
37320
|
+
const target = finalTarget(storedTarget);
|
|
37321
|
+
if (!entry || !target) continue;
|
|
37322
|
+
mergePolicy(policies, target, {
|
|
37323
|
+
lifecycle: entry.lifecycle === "held" || entry.lifecycle === "agent" || entry.continuity === "agent" ? "agent" : "session",
|
|
37324
|
+
bindOn: [
|
|
37325
|
+
...Array.isArray(entry.bindOn) ? entry.bindOn.filter(
|
|
37326
|
+
(action) => typeof action === "string"
|
|
37327
|
+
) : [],
|
|
37328
|
+
...entry.bind === "onAttributedEvent" ? ["attribution"] : []
|
|
37329
|
+
]
|
|
37330
|
+
});
|
|
37331
|
+
}
|
|
37332
|
+
for (const trigger of input.triggers) {
|
|
37333
|
+
const candidate = record2(trigger);
|
|
37334
|
+
const routing = record2(candidate?.routing);
|
|
37335
|
+
if (!routing) continue;
|
|
37336
|
+
const inline = record2(routing.bind);
|
|
37337
|
+
const storedTarget = typeof inline?.target === "string" ? inline.target : typeof routing.target === "string" ? routing.target : null;
|
|
37338
|
+
const target = storedTarget ? finalTarget(storedTarget) : null;
|
|
37339
|
+
if (!target) continue;
|
|
37340
|
+
const lifecycleSource = inline ?? routing;
|
|
37341
|
+
mergePolicy(policies, target, {
|
|
37342
|
+
lifecycle: lifecycleSource.lifecycle === "held" || lifecycleSource.lifecycle === "agent" || lifecycleSource.continuity === "agent" ? "agent" : "session",
|
|
37343
|
+
bindOn: []
|
|
37344
|
+
});
|
|
37345
|
+
}
|
|
37346
|
+
mergePolicy(policies, "chat.thread", {
|
|
37347
|
+
lifecycle: "session",
|
|
37348
|
+
bindOn: ["send"]
|
|
37349
|
+
});
|
|
37350
|
+
mergePolicy(policies, "auto.connection.authorization_attempt", {
|
|
37351
|
+
lifecycle: "agent",
|
|
37352
|
+
bindOn: ["authorization"]
|
|
37353
|
+
});
|
|
37354
|
+
if (input.observeSpawnedSessions) {
|
|
37355
|
+
mergePolicy(policies, "auto.session", {
|
|
37356
|
+
lifecycle: "session",
|
|
37357
|
+
bindOn: ["spawn"]
|
|
37358
|
+
});
|
|
37359
|
+
}
|
|
37360
|
+
return Object.fromEntries(
|
|
37361
|
+
[...policies.entries()].map(([target, policy]) => [
|
|
37362
|
+
target,
|
|
37363
|
+
{
|
|
37364
|
+
lifecycle: policy.lifecycle,
|
|
37365
|
+
...policy.bindOn.size > 0 ? { bindOn: [...policy.bindOn].sort() } : {}
|
|
37366
|
+
}
|
|
37367
|
+
])
|
|
37368
|
+
);
|
|
37369
|
+
}
|
|
37370
|
+
function normalizePersistedTriggers(triggers, bindings) {
|
|
37371
|
+
const legacyMentionBinding = Object.entries(record2(bindings) ?? {}).some(
|
|
37372
|
+
([target, value]) => (target === "slack.thread" || target === "chat.thread") && record2(value)?.bind === "onMention"
|
|
37373
|
+
);
|
|
37374
|
+
return triggers.flatMap((trigger) => {
|
|
37375
|
+
const candidate = record2(trigger);
|
|
37376
|
+
const routing = record2(candidate?.routing);
|
|
37377
|
+
if (!candidate || !routing) return [trigger];
|
|
37378
|
+
if (routing.target === "auto.task" || record2(routing.bind)?.target === "auto.task") {
|
|
37379
|
+
return [];
|
|
37380
|
+
}
|
|
37381
|
+
const events = triggerEvents(candidate);
|
|
37382
|
+
const inlineMentionBinding = routing.kind === "deliver" && record2(routing.bind) !== null;
|
|
37383
|
+
if (events.includes("chat.message.mentioned") && events.some((event) => event !== "chat.message.mentioned") && (legacyMentionBinding || inlineMentionBinding)) {
|
|
37384
|
+
const mention = { ...candidate };
|
|
37385
|
+
delete mention.events;
|
|
37386
|
+
mention.event = "chat.message.mentioned";
|
|
37387
|
+
const remaining = { ...candidate };
|
|
37388
|
+
delete remaining.event;
|
|
37389
|
+
remaining.events = events.filter(
|
|
37390
|
+
(event) => event !== "chat.message.mentioned"
|
|
37391
|
+
);
|
|
37392
|
+
remaining.routing = inlineMentionBinding ? Object.fromEntries(
|
|
37393
|
+
Object.entries(routing).filter(([key]) => key !== "bind")
|
|
37394
|
+
) : routing;
|
|
37395
|
+
return [
|
|
37396
|
+
normalizePersistedTrigger(mention, true),
|
|
37397
|
+
normalizePersistedTrigger(remaining, false)
|
|
37398
|
+
];
|
|
37399
|
+
}
|
|
37400
|
+
return [
|
|
37401
|
+
normalizePersistedTrigger(
|
|
37402
|
+
candidate,
|
|
37403
|
+
events.length === 1 && events[0] === "chat.message.mentioned" && (legacyMentionBinding || inlineMentionBinding)
|
|
37404
|
+
)
|
|
37405
|
+
];
|
|
37406
|
+
});
|
|
37407
|
+
}
|
|
37408
|
+
function normalizePersistedTrigger(trigger, mentionBinding) {
|
|
37409
|
+
const routing = record2(trigger.routing);
|
|
37410
|
+
if (!routing) return trigger;
|
|
37411
|
+
if (routing.kind !== "spawn" && routing.kind !== "bind" && routing.kind !== "deliver" && routing.kind !== "deliverOrSpawn") {
|
|
37412
|
+
return trigger;
|
|
37413
|
+
}
|
|
37414
|
+
const routeBy = record2(routing.routeBy);
|
|
37415
|
+
if (routing.routeBy !== void 0 && (!routeBy || routeBy.kind !== "singleton" && routeBy.kind !== "ownedArtifact" && routeBy.kind !== "allLiveSessions" && routeBy.kind !== "allLiveRuns" && routeBy.kind !== "attributedSessions" && routeBy.kind !== "attributedRuns")) {
|
|
37416
|
+
return trigger;
|
|
37417
|
+
}
|
|
37418
|
+
const { routing: _routing, ...normalized } = trigger;
|
|
37419
|
+
const onUnmatched = onUnmatchedPolicy(routing.onUnmatched);
|
|
37420
|
+
const events = triggerEvents(trigger);
|
|
37421
|
+
const inlineBind = record2(routing.bind);
|
|
37422
|
+
let route;
|
|
37423
|
+
if (inlineBind && routing.kind !== "deliver") {
|
|
37424
|
+
route = targetRoute(inlineBind.target, "spawn");
|
|
37425
|
+
} else if (routing.kind === "spawn" && events.length > 0 && events.every((event) => event.startsWith("chat.message."))) {
|
|
37426
|
+
route = targetRoute("chat.thread", "spawn");
|
|
37427
|
+
} else if (routing.kind === "spawn") {
|
|
37428
|
+
route = { to: "new" };
|
|
37429
|
+
} else if (routing.kind === "bind") {
|
|
37430
|
+
route = targetRoute(routing.target, onUnmatched);
|
|
37431
|
+
} else {
|
|
37432
|
+
if (routeBy?.kind === "allLiveSessions" || routeBy?.kind === "allLiveRuns") {
|
|
37433
|
+
route = { to: "all" };
|
|
37434
|
+
} else if (routeBy?.kind === "attributedSessions" || routeBy?.kind === "attributedRuns") {
|
|
37435
|
+
route = targetRoute("chat.thread", onUnmatched);
|
|
37436
|
+
} else if (routeBy?.kind === "ownedArtifact") {
|
|
37437
|
+
route = targetRoute(routeBy.artifactType, onUnmatched);
|
|
37438
|
+
} else if (mentionBinding && onUnmatched === "spawn") {
|
|
37439
|
+
route = targetRoute("chat.thread", "spawn");
|
|
37440
|
+
} else {
|
|
37441
|
+
route = {
|
|
37442
|
+
to: "slot",
|
|
37443
|
+
onUnmatched: routing.kind === "deliverOrSpawn" ? "spawn" : onUnmatched
|
|
37444
|
+
};
|
|
37445
|
+
}
|
|
37446
|
+
}
|
|
37447
|
+
const effects = {};
|
|
37448
|
+
if (routing.kind === "bind" && routing.release) {
|
|
37449
|
+
effects.release = {
|
|
37450
|
+
target: typeof routing.target === "string" ? finalTarget(routing.target) : routing.target
|
|
37451
|
+
};
|
|
37452
|
+
}
|
|
37453
|
+
if (mentionBinding && !(record2(route.to)?.target === "chat.thread" && route.onUnmatched === "spawn")) {
|
|
37454
|
+
effects.bind = { target: "chat.thread" };
|
|
37455
|
+
}
|
|
37456
|
+
const deliveryGuard = record2(routing.deliveryGuard);
|
|
37457
|
+
const where = record2(normalized.where);
|
|
37458
|
+
const persistedWhere = record2(route.to)?.target === "chat.thread" && where?.["$.auto.authored"] === void 0 ? { ...where ?? {}, "$.auto.authored": false } : normalized.where;
|
|
37459
|
+
return {
|
|
37460
|
+
...normalized,
|
|
37461
|
+
...persistedWhere === void 0 ? {} : { where: persistedWhere },
|
|
37462
|
+
route,
|
|
37463
|
+
...deliveryGuard?.kind === "managedCheckSuccess" && typeof deliveryGuard.check === "string" ? { guard: { managedCheckSuccess: deliveryGuard.check } } : {},
|
|
37464
|
+
...Object.keys(effects).length > 0 ? { effects } : {}
|
|
37465
|
+
};
|
|
37466
|
+
}
|
|
37467
|
+
function targetRoute(target, onUnmatched) {
|
|
37468
|
+
return {
|
|
37469
|
+
to: { target: typeof target === "string" ? finalTarget(target) : target },
|
|
37470
|
+
onUnmatched
|
|
37471
|
+
};
|
|
37472
|
+
}
|
|
37473
|
+
function mergePolicy(policies, target, incoming) {
|
|
37474
|
+
const current = policies.get(target);
|
|
37475
|
+
policies.set(target, {
|
|
37476
|
+
lifecycle: current?.lifecycle === "agent" || incoming.lifecycle === "agent" ? "agent" : "session",
|
|
37477
|
+
bindOn: /* @__PURE__ */ new Set([...current?.bindOn ?? [], ...incoming.bindOn])
|
|
37478
|
+
});
|
|
37479
|
+
}
|
|
37480
|
+
function triggerUsesLegacyGrammar(value) {
|
|
37481
|
+
return record2(value)?.routing !== void 0;
|
|
37482
|
+
}
|
|
37483
|
+
function bindingsUseLegacyGrammar(value) {
|
|
37484
|
+
const bindings = record2(value);
|
|
37485
|
+
if (!bindings) return false;
|
|
37486
|
+
return Object.entries(bindings).some(([target, value2]) => {
|
|
37487
|
+
const entry = record2(value2);
|
|
37488
|
+
return target === "slack.thread" || entry?.continuity !== void 0 || entry?.bind !== void 0 || entry?.context !== void 0 || entry?.eventContext !== void 0 || entry?.lifecycle === "manual" || entry?.lifecycle === "held";
|
|
37489
|
+
});
|
|
37490
|
+
}
|
|
37491
|
+
function triggerEvents(trigger) {
|
|
37492
|
+
if (Array.isArray(trigger.events)) {
|
|
37493
|
+
return trigger.events.filter(
|
|
37494
|
+
(event) => typeof event === "string"
|
|
37495
|
+
);
|
|
37496
|
+
}
|
|
37497
|
+
return typeof trigger.event === "string" ? [trigger.event] : [];
|
|
37498
|
+
}
|
|
37499
|
+
function finalTarget(target) {
|
|
37500
|
+
if (target === "auto.task" || target === "agent.singleton" || target === "chat.message") {
|
|
37501
|
+
return null;
|
|
37502
|
+
}
|
|
37503
|
+
return target === "slack.thread" ? "chat.thread" : target;
|
|
37504
|
+
}
|
|
37505
|
+
function onUnmatchedPolicy(value) {
|
|
37506
|
+
return value === "warn" || value === "error" || value === "spawn" || value === "drop" ? value : "drop";
|
|
37507
|
+
}
|
|
37508
|
+
function record2(value) {
|
|
37509
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : null;
|
|
37510
|
+
}
|
|
37511
|
+
|
|
37512
|
+
// ../../packages/schemas/src/session-bindings.ts
|
|
37513
|
+
var BINDING_TARGET_TYPES = [
|
|
37514
|
+
"github.pull_request",
|
|
37515
|
+
"github.issue",
|
|
37516
|
+
"chat.thread",
|
|
37517
|
+
"linear.issue",
|
|
37518
|
+
"webhook.key",
|
|
37519
|
+
"provider.entity",
|
|
37520
|
+
"auto.connection.authorization_attempt",
|
|
37521
|
+
"auto.session"
|
|
37522
|
+
];
|
|
37523
|
+
var PERSISTED_BINDING_TARGET_TYPES = [
|
|
37524
|
+
"github.pull_request",
|
|
37525
|
+
"github.issue",
|
|
37526
|
+
"slack.thread",
|
|
37527
|
+
"chat.thread",
|
|
37528
|
+
"chat.message",
|
|
37529
|
+
"agent.singleton",
|
|
37530
|
+
"linear.issue",
|
|
37531
|
+
"webhook.key",
|
|
37532
|
+
"provider.entity",
|
|
37533
|
+
"auto.connection.authorization_attempt",
|
|
37534
|
+
"auto.session",
|
|
37535
|
+
"auto.task"
|
|
37536
|
+
];
|
|
37537
|
+
var TRIGGER_BINDING_TARGET_TYPES = [
|
|
37538
|
+
...BINDING_TARGET_TYPES
|
|
37539
|
+
];
|
|
37540
|
+
var OWNER_RELEASABLE_HELD_BINDING_TARGET_TYPES = [
|
|
37541
|
+
"auto.connection.authorization_attempt"
|
|
37542
|
+
];
|
|
37543
|
+
var SESSION_BINDING_SOURCES = [
|
|
37544
|
+
"trigger_spawn",
|
|
37545
|
+
"agent_tool",
|
|
37546
|
+
"chat_send",
|
|
37547
|
+
"system"
|
|
37548
|
+
];
|
|
37549
|
+
var SESSION_BINDING_STATUSES = ["active", "released"];
|
|
37550
|
+
var BINDING_LIFECYCLES = ["session", "agent"];
|
|
37551
|
+
var BINDING_BOUND_CAUSES = [
|
|
37552
|
+
"spawn",
|
|
37553
|
+
"trigger",
|
|
37554
|
+
"attribution",
|
|
37555
|
+
"holder",
|
|
37556
|
+
"chat",
|
|
37557
|
+
"authorization",
|
|
37558
|
+
"system",
|
|
37559
|
+
"takeover",
|
|
37560
|
+
"legacy"
|
|
37561
|
+
];
|
|
37562
|
+
var BINDING_RELEASED_CAUSES = [
|
|
37563
|
+
"session_terminal",
|
|
37564
|
+
"target_terminal",
|
|
37565
|
+
"holder",
|
|
37566
|
+
"operator",
|
|
37567
|
+
"takeover",
|
|
37568
|
+
"legacy"
|
|
37569
|
+
];
|
|
37570
|
+
var SESSION_BINDING_RELEASE_POLICIES = ["manual", "held"];
|
|
37571
|
+
var SESSION_BINDING_CONTINUITIES = ["session", "agent"];
|
|
37572
|
+
var SESSION_BINDING_RELEASED_BY = [
|
|
37573
|
+
"agent_tool",
|
|
37574
|
+
"archive",
|
|
37575
|
+
"complete",
|
|
37576
|
+
"trigger_release",
|
|
37577
|
+
"operator",
|
|
37578
|
+
"takeover"
|
|
37579
|
+
];
|
|
37580
|
+
var PERSISTED_SESSION_BINDING_RELEASED_BY = [
|
|
37581
|
+
...SESSION_BINDING_RELEASED_BY,
|
|
37582
|
+
"task_terminal"
|
|
37583
|
+
];
|
|
37584
|
+
var BindingTargetTypeSchema = external_exports.enum(BINDING_TARGET_TYPES);
|
|
37585
|
+
var PersistedBindingTargetTypeSchema = external_exports.enum(
|
|
37586
|
+
PERSISTED_BINDING_TARGET_TYPES
|
|
37587
|
+
);
|
|
37588
|
+
var TriggerBindingTargetTypeSchema = external_exports.enum(
|
|
37589
|
+
TRIGGER_BINDING_TARGET_TYPES
|
|
37590
|
+
);
|
|
37591
|
+
var OwnerReleasableHeldBindingTargetTypeSchema = external_exports.enum(
|
|
37592
|
+
OWNER_RELEASABLE_HELD_BINDING_TARGET_TYPES
|
|
37593
|
+
);
|
|
37594
|
+
var SessionBindingSourceSchema = external_exports.enum(SESSION_BINDING_SOURCES);
|
|
37595
|
+
var SessionBindingStatusSchema = external_exports.enum(SESSION_BINDING_STATUSES);
|
|
37596
|
+
var BindingLifecycleSchema = external_exports.enum(BINDING_LIFECYCLES);
|
|
37597
|
+
var BindingBoundCauseSchema = external_exports.enum(BINDING_BOUND_CAUSES);
|
|
37598
|
+
var BindingReleasedCauseSchema = external_exports.enum(BINDING_RELEASED_CAUSES);
|
|
37599
|
+
var SessionBindingReleasePolicySchema = external_exports.enum(
|
|
37600
|
+
SESSION_BINDING_RELEASE_POLICIES
|
|
37601
|
+
);
|
|
37602
|
+
var SessionBindingContinuitySchema = external_exports.enum(
|
|
37603
|
+
SESSION_BINDING_CONTINUITIES
|
|
37604
|
+
);
|
|
37605
|
+
var SessionBindingReleasedBySchema = external_exports.enum(
|
|
37606
|
+
SESSION_BINDING_RELEASED_BY
|
|
37607
|
+
);
|
|
37608
|
+
var PersistedSessionBindingReleasedBySchema = external_exports.enum(
|
|
37609
|
+
PERSISTED_SESSION_BINDING_RELEASED_BY
|
|
37610
|
+
);
|
|
37611
|
+
var BindingTargetSchema = external_exports.object({
|
|
37612
|
+
type: BindingTargetTypeSchema,
|
|
37613
|
+
externalId: external_exports.string().min(1)
|
|
37614
|
+
});
|
|
37615
|
+
var BINDING_ACTIONS = [
|
|
37616
|
+
"send",
|
|
37617
|
+
"attribution",
|
|
37618
|
+
"spawn",
|
|
37619
|
+
"authorization"
|
|
37620
|
+
];
|
|
37621
|
+
var BindingActionSchema = external_exports.enum(BINDING_ACTIONS);
|
|
37622
|
+
var BINDING_ACTION_LEGAL_TARGETS = {
|
|
37623
|
+
send: /* @__PURE__ */ new Set(["chat.thread"]),
|
|
37624
|
+
attribution: /* @__PURE__ */ new Set(["github.pull_request"]),
|
|
37625
|
+
spawn: /* @__PURE__ */ new Set(["auto.session"]),
|
|
37626
|
+
authorization: /* @__PURE__ */ new Set([
|
|
37627
|
+
"auto.connection.authorization_attempt"
|
|
37628
|
+
])
|
|
37629
|
+
};
|
|
37630
|
+
|
|
37631
|
+
// ../../packages/schemas/src/work-provenance.ts
|
|
37632
|
+
var StableKeySchema = external_exports.string().trim().min(1).max(512);
|
|
37633
|
+
var SnapshotNameSchema = external_exports.string().trim().min(1).max(256);
|
|
37634
|
+
var SourceIdSchema = external_exports.string().trim().min(1).max(512);
|
|
37635
|
+
var principalBase = {
|
|
37636
|
+
stableKey: StableKeySchema,
|
|
37637
|
+
displayName: SnapshotNameSchema
|
|
37638
|
+
};
|
|
37639
|
+
var schedulePrincipalSchema = external_exports.object({
|
|
37640
|
+
kind: external_exports.literal("schedule"),
|
|
37641
|
+
...principalBase,
|
|
37642
|
+
scheduleId: SourceIdSchema,
|
|
37643
|
+
agentResourceId: SourceIdSchema,
|
|
37644
|
+
agentName: SnapshotNameSchema,
|
|
37645
|
+
triggerId: SourceIdSchema.nullable().default(null),
|
|
37646
|
+
triggerName: SnapshotNameSchema.nullable().default(null),
|
|
37647
|
+
triggerOrdinal: external_exports.number().int().nonnegative(),
|
|
37648
|
+
cron: external_exports.string().trim().min(1).max(512).nullable().default(null),
|
|
37649
|
+
timezone: external_exports.string().trim().min(1).max(128).nullable().default(null)
|
|
37650
|
+
});
|
|
37651
|
+
var webhookPrincipalSchema = external_exports.object({
|
|
37652
|
+
kind: external_exports.literal("webhook"),
|
|
37653
|
+
...principalBase,
|
|
37654
|
+
endpointId: SourceIdSchema,
|
|
37655
|
+
endpointName: SnapshotNameSchema.nullable().default(null)
|
|
37656
|
+
});
|
|
37657
|
+
var serviceAccountPrincipalSchema = external_exports.object({
|
|
37658
|
+
kind: external_exports.literal("service_account"),
|
|
37659
|
+
...principalBase,
|
|
37660
|
+
serviceAccountId: SourceIdSchema
|
|
37661
|
+
});
|
|
37662
|
+
var providerIntegrationPrincipalSchema = external_exports.object({
|
|
37663
|
+
kind: external_exports.literal("provider_integration"),
|
|
37664
|
+
...principalBase,
|
|
37665
|
+
provider: ProviderNameSchema,
|
|
37666
|
+
connectionId: SourceIdSchema.nullable().default(null)
|
|
37667
|
+
});
|
|
37668
|
+
var systemPrincipalSchema = external_exports.object({
|
|
37669
|
+
kind: external_exports.literal("system"),
|
|
37670
|
+
...principalBase,
|
|
37671
|
+
systemId: SourceIdSchema
|
|
37672
|
+
});
|
|
37673
|
+
var agentPrincipalSchema = external_exports.object({
|
|
37674
|
+
kind: external_exports.literal("agent"),
|
|
37675
|
+
...principalBase,
|
|
37676
|
+
agentResourceId: SourceIdSchema,
|
|
37677
|
+
agentName: SnapshotNameSchema,
|
|
37678
|
+
sessionId: SessionIdSchema2
|
|
37679
|
+
});
|
|
37680
|
+
var AutomationPrincipalSchema = external_exports.discriminatedUnion("kind", [
|
|
37681
|
+
schedulePrincipalSchema,
|
|
37682
|
+
webhookPrincipalSchema,
|
|
37683
|
+
serviceAccountPrincipalSchema,
|
|
37684
|
+
providerIntegrationPrincipalSchema,
|
|
37685
|
+
systemPrincipalSchema,
|
|
37686
|
+
agentPrincipalSchema
|
|
37687
|
+
]);
|
|
37688
|
+
var AutomationPrincipalAuthoringSchema = external_exports.discriminatedUnion("kind", [
|
|
37689
|
+
schedulePrincipalSchema.strict(),
|
|
37690
|
+
webhookPrincipalSchema.strict(),
|
|
37691
|
+
serviceAccountPrincipalSchema.strict(),
|
|
37692
|
+
providerIntegrationPrincipalSchema.strict(),
|
|
37693
|
+
systemPrincipalSchema.strict(),
|
|
37694
|
+
agentPrincipalSchema.strict()
|
|
37695
|
+
]);
|
|
37696
|
+
var scheduleCauseSchema = external_exports.object({
|
|
37697
|
+
kind: external_exports.literal("schedule"),
|
|
37698
|
+
sourceEventId: SourceIdSchema,
|
|
37699
|
+
scheduledAt: external_exports.string().datetime()
|
|
37700
|
+
});
|
|
37701
|
+
var childSessionCauseSchema = external_exports.object({
|
|
37702
|
+
kind: external_exports.literal("child_session"),
|
|
37703
|
+
sourceSessionId: SessionIdSchema2
|
|
37704
|
+
});
|
|
37705
|
+
var githubArtifactCauseSchema = external_exports.object({
|
|
37706
|
+
kind: external_exports.literal("github_artifact"),
|
|
37707
|
+
sourceEventId: SourceIdSchema,
|
|
37708
|
+
sourceSessionId: SessionIdSchema2,
|
|
37709
|
+
sourceBindingId: SourceIdSchema,
|
|
37710
|
+
sourceArtifactAttributionId: SourceIdSchema
|
|
37711
|
+
});
|
|
37712
|
+
var WorkProvenanceCauseSchema = external_exports.discriminatedUnion("kind", [
|
|
37713
|
+
scheduleCauseSchema,
|
|
37714
|
+
childSessionCauseSchema,
|
|
37715
|
+
githubArtifactCauseSchema
|
|
37716
|
+
]);
|
|
37717
|
+
var WorkProvenanceCauseAuthoringSchema = external_exports.discriminatedUnion("kind", [
|
|
37718
|
+
scheduleCauseSchema.strict(),
|
|
37719
|
+
childSessionCauseSchema.strict(),
|
|
37720
|
+
githubArtifactCauseSchema.strict()
|
|
37721
|
+
]);
|
|
37722
|
+
var WorkProvenanceFields = {
|
|
37723
|
+
version: external_exports.literal(1),
|
|
37724
|
+
root: AutomationPrincipalSchema,
|
|
37725
|
+
actor: AutomationPrincipalSchema,
|
|
37726
|
+
cause: WorkProvenanceCauseSchema
|
|
37727
|
+
};
|
|
37728
|
+
var WorkProvenanceSchema = external_exports.object(WorkProvenanceFields);
|
|
37729
|
+
var WorkProvenanceAuthoringSchema = external_exports.object({
|
|
37730
|
+
version: external_exports.literal(1),
|
|
37731
|
+
root: AutomationPrincipalAuthoringSchema,
|
|
37732
|
+
actor: AutomationPrincipalAuthoringSchema,
|
|
37733
|
+
cause: WorkProvenanceCauseAuthoringSchema
|
|
37734
|
+
}).strict();
|
|
37735
|
+
|
|
37736
|
+
// ../../packages/schemas/src/requester-spend.ts
|
|
37737
|
+
var ExactUsdSchema = external_exports.string().regex(
|
|
37738
|
+
/^(0|[1-9]\d*)(\.\d{1,10})?$/,
|
|
37739
|
+
"Expected an exact non-negative USD decimal"
|
|
37740
|
+
);
|
|
37741
|
+
var RequesterSpendOverrideInputSchema = external_exports.object({
|
|
37742
|
+
active: external_exports.boolean(),
|
|
37743
|
+
reason: external_exports.string().trim().min(1).max(500).nullable(),
|
|
37744
|
+
expiresAt: external_exports.string().datetime().nullable()
|
|
37745
|
+
});
|
|
37746
|
+
var RequesterSpendUpdateRequestSchema = external_exports.object({
|
|
37747
|
+
expectedVersion: external_exports.number().int().nonnegative().nullable(),
|
|
37748
|
+
dailyLimitUsd: ExactUsdSchema.nullable(),
|
|
37749
|
+
monthlyLimitUsd: ExactUsdSchema.nullable(),
|
|
37750
|
+
override: RequesterSpendOverrideInputSchema
|
|
37751
|
+
});
|
|
37752
|
+
var RequesterSpendSourceSchema = external_exports.object({
|
|
37753
|
+
sourceKey: external_exports.string().min(1),
|
|
37754
|
+
provider: external_exports.string().min(1).nullable(),
|
|
37755
|
+
externalId: external_exports.string().min(1).nullable(),
|
|
37756
|
+
accountRef: external_exports.string().min(1).nullable(),
|
|
37757
|
+
displayName: external_exports.string().min(1).nullable(),
|
|
37758
|
+
avatarUrl: external_exports.string().url().nullable(),
|
|
37759
|
+
automationActor: AutomationPrincipalSchema.nullable().optional(),
|
|
37760
|
+
automationCauseKind: external_exports.enum(["schedule", "child_session", "github_artifact"]).nullable().optional(),
|
|
37761
|
+
totalUsd: ExactUsdSchema,
|
|
37762
|
+
dailyUsd: ExactUsdSchema,
|
|
37763
|
+
monthlyUsd: ExactUsdSchema
|
|
37764
|
+
});
|
|
37765
|
+
var RequesterSpendOverrideStateSchema = external_exports.object({
|
|
37766
|
+
active: external_exports.boolean(),
|
|
37767
|
+
effective: external_exports.boolean(),
|
|
37768
|
+
reason: external_exports.string().nullable(),
|
|
37769
|
+
expiresAt: external_exports.string().datetime().nullable(),
|
|
37770
|
+
setByUserId: external_exports.string().min(1).nullable(),
|
|
37771
|
+
setAt: external_exports.string().datetime().nullable()
|
|
37772
|
+
});
|
|
37773
|
+
var RequesterSpendPeriodSchema = external_exports.object({
|
|
37774
|
+
usageUsd: ExactUsdSchema,
|
|
37775
|
+
limitUsd: ExactUsdSchema.nullable(),
|
|
37776
|
+
resetsAt: external_exports.string().datetime(),
|
|
37777
|
+
capped: external_exports.boolean()
|
|
37778
|
+
});
|
|
37779
|
+
var RequesterSpendRowSchema = external_exports.object({
|
|
37780
|
+
kind: external_exports.enum(["user", "automation", "unattributed"]),
|
|
37781
|
+
requesterKey: external_exports.string().min(1),
|
|
37782
|
+
requesterUserId: external_exports.string().min(1).nullable(),
|
|
37783
|
+
displayName: external_exports.string().min(1).nullable(),
|
|
37784
|
+
avatarUrl: external_exports.string().url().nullable(),
|
|
37785
|
+
automationRoot: AutomationPrincipalSchema.nullable().optional(),
|
|
37786
|
+
totalUsd: ExactUsdSchema,
|
|
37787
|
+
daily: RequesterSpendPeriodSchema,
|
|
37788
|
+
monthly: RequesterSpendPeriodSchema,
|
|
37789
|
+
override: RequesterSpendOverrideStateSchema,
|
|
37790
|
+
capped: external_exports.boolean(),
|
|
37791
|
+
controlVersion: external_exports.number().int().nonnegative().nullable(),
|
|
37792
|
+
manageable: external_exports.boolean(),
|
|
37793
|
+
sources: external_exports.array(RequesterSpendSourceSchema)
|
|
37794
|
+
});
|
|
37795
|
+
var RequesterSpendListResponseSchema = external_exports.object({
|
|
37796
|
+
asOf: external_exports.string().datetime(),
|
|
37797
|
+
timezone: external_exports.literal("UTC"),
|
|
37798
|
+
canManage: external_exports.boolean(),
|
|
37799
|
+
requesters: external_exports.array(RequesterSpendRowSchema)
|
|
37800
|
+
});
|
|
37801
|
+
var RequesterSpendUpdateResponseSchema = external_exports.object({
|
|
37802
|
+
requester: RequesterSpendRowSchema
|
|
37803
|
+
});
|
|
37804
|
+
var REQUESTER_SPEND_ERROR_CODES = [
|
|
37805
|
+
"invalid_request",
|
|
37806
|
+
"requester_not_found",
|
|
37807
|
+
"version_conflict",
|
|
37808
|
+
"unauthorized",
|
|
37809
|
+
"forbidden"
|
|
37810
|
+
];
|
|
37811
|
+
var RequesterSpendErrorCodeSchema = external_exports.enum(
|
|
37812
|
+
REQUESTER_SPEND_ERROR_CODES
|
|
37813
|
+
);
|
|
37814
|
+
var RequesterSpendErrorResponseSchema = external_exports.object({
|
|
37815
|
+
error: external_exports.string(),
|
|
37816
|
+
code: RequesterSpendErrorCodeSchema,
|
|
37817
|
+
issues: external_exports.array(external_exports.unknown()).optional(),
|
|
37818
|
+
currentVersion: external_exports.number().int().nonnegative().nullable().optional()
|
|
37819
|
+
});
|
|
37820
|
+
|
|
37821
|
+
// ../../packages/schemas/src/spend-caps.ts
|
|
37822
|
+
var USD_DECIMAL_ERROR = "must be a nonnegative decimal string with at most 10 integer and 10 fractional digits";
|
|
37823
|
+
function canonicalUsdDecimal(value) {
|
|
37824
|
+
const [integer2, fraction] = value.split(".");
|
|
37825
|
+
const trimmedFraction = fraction?.replace(/0+$/, "");
|
|
37826
|
+
return trimmedFraction ? `${integer2}.${trimmedFraction}` : integer2 ?? "0";
|
|
37827
|
+
}
|
|
37828
|
+
var SpendCapUsdSchema = ExactUsdSchema.refine(
|
|
37829
|
+
(value) => (value.split(".")[0]?.length ?? 0) <= 10,
|
|
37830
|
+
USD_DECIMAL_ERROR
|
|
37831
|
+
).transform(canonicalUsdDecimal);
|
|
37832
|
+
var AgentSpendCapsFields = {
|
|
37833
|
+
dailyUsd: SpendCapUsdSchema.optional(),
|
|
37834
|
+
monthlyUsd: SpendCapUsdSchema.optional(),
|
|
37835
|
+
maxPerSessionUsd: SpendCapUsdSchema.optional()
|
|
37836
|
+
};
|
|
37837
|
+
var AgentSpendCapsSchema = external_exports.object(AgentSpendCapsFields);
|
|
37838
|
+
var AgentSpendCapsAuthoringSchema = external_exports.object(AgentSpendCapsFields).strict();
|
|
37839
|
+
var SessionSpendCapSnapshotSchema = external_exports.object({
|
|
37840
|
+
configuredMaxUsd: SpendCapUsdSchema.nullable()
|
|
37841
|
+
});
|
|
37842
|
+
var AgentSpendCapWindowStatusSchema = external_exports.object({
|
|
37843
|
+
usageUsd: ExactUsdSchema,
|
|
37844
|
+
configuredLimitUsd: SpendCapUsdSchema.nullable(),
|
|
37845
|
+
hit: external_exports.boolean(),
|
|
37846
|
+
resetsAt: external_exports.string().datetime()
|
|
37847
|
+
});
|
|
37848
|
+
var AgentSpendCapStatusSchema = external_exports.object({
|
|
37849
|
+
daily: AgentSpendCapWindowStatusSchema,
|
|
37850
|
+
monthly: AgentSpendCapWindowStatusSchema
|
|
37851
|
+
});
|
|
37852
|
+
var SessionSpendCapStatusSchema = external_exports.object({
|
|
37853
|
+
usageUsd: ExactUsdSchema,
|
|
37854
|
+
configuredMaxUsd: SpendCapUsdSchema.nullable(),
|
|
37855
|
+
hit: external_exports.boolean()
|
|
37856
|
+
});
|
|
37857
|
+
|
|
37858
|
+
// ../../packages/schemas/src/tools.ts
|
|
37859
|
+
var REMOTE_MCP_TRANSPORTS = ["streamable_http"];
|
|
37860
|
+
var LOCAL_TOOL_IMPLEMENTATIONS = ["auto", "chat", "ping"];
|
|
37861
|
+
var BILLING_CAPABILITY_LEVELS = ["none", "read", "write"];
|
|
37862
|
+
var BillingCapabilityLevelSchema = external_exports.enum(BILLING_CAPABILITY_LEVELS);
|
|
37863
|
+
var PROJECT_MEMBER_CAPABILITY_LEVELS = ["none", "read"];
|
|
37864
|
+
var ProjectMemberCapabilityLevelSchema = external_exports.enum(
|
|
37865
|
+
PROJECT_MEMBER_CAPABILITY_LEVELS
|
|
37866
|
+
);
|
|
37867
|
+
var WAITLIST_REPORTING_CAPABILITY_LEVELS = ["none", "read"];
|
|
37868
|
+
var WaitlistReportingCapabilityLevelSchema = external_exports.enum(
|
|
37869
|
+
WAITLIST_REPORTING_CAPABILITY_LEVELS
|
|
37870
|
+
);
|
|
37871
|
+
var RUNTIME_CAPABILITY_LEVELS = ["none", "read", "write"];
|
|
37872
|
+
var RuntimeCapabilityLevelSchema = external_exports.enum(RUNTIME_CAPABILITY_LEVELS);
|
|
37873
|
+
var CONNECTION_CAPABILITY_LEVELS = ["none", "read", "write"];
|
|
37874
|
+
var ConnectionCapabilityLevelSchema = external_exports.enum(
|
|
37875
|
+
CONNECTION_CAPABILITY_LEVELS
|
|
37876
|
+
);
|
|
37877
|
+
var SECRET_CAPABILITY_LEVELS = ["none", "read", "write"];
|
|
37878
|
+
var SecretCapabilityLevelSchema = external_exports.enum(SECRET_CAPABILITY_LEVELS);
|
|
37879
|
+
var WEBHOOK_CAPABILITY_LEVELS = ["none", "write"];
|
|
37880
|
+
var WebhookCapabilityLevelSchema = external_exports.enum(WEBHOOK_CAPABILITY_LEVELS);
|
|
37881
|
+
function attenuatedCapabilitySchema(input) {
|
|
37882
|
+
return external_exports.union([
|
|
37883
|
+
input.levelSchema,
|
|
37884
|
+
external_exports.object({
|
|
37885
|
+
level: input.levelSchema,
|
|
37886
|
+
unattributed: input.levelSchema
|
|
37887
|
+
}).strict().superRefine((capability, context) => {
|
|
37888
|
+
if (!capabilityLevelAtMost({
|
|
37889
|
+
floor: capability.unattributed,
|
|
37890
|
+
grant: capability.level,
|
|
37891
|
+
levels: input.levels
|
|
37892
|
+
})) {
|
|
37893
|
+
context.addIssue({
|
|
37894
|
+
code: external_exports.ZodIssueCode.custom,
|
|
37895
|
+
message: "unattributed capability level must not exceed level",
|
|
37896
|
+
path: ["unattributed"]
|
|
37897
|
+
});
|
|
37898
|
+
}
|
|
37899
|
+
})
|
|
37900
|
+
]);
|
|
37901
|
+
}
|
|
37902
|
+
var BillingCapabilitySchema = attenuatedCapabilitySchema({
|
|
37903
|
+
levelSchema: BillingCapabilityLevelSchema,
|
|
37904
|
+
levels: BILLING_CAPABILITY_LEVELS
|
|
37905
|
+
});
|
|
37906
|
+
var ProjectMemberCapabilitySchema = attenuatedCapabilitySchema({
|
|
37907
|
+
levelSchema: ProjectMemberCapabilityLevelSchema,
|
|
37908
|
+
levels: PROJECT_MEMBER_CAPABILITY_LEVELS
|
|
37909
|
+
});
|
|
37910
|
+
var WaitlistReportingCapabilitySchema = external_exports.literal("read");
|
|
37911
|
+
var RuntimeCapabilitySchema = attenuatedCapabilitySchema({
|
|
37912
|
+
levelSchema: RuntimeCapabilityLevelSchema,
|
|
37913
|
+
levels: RUNTIME_CAPABILITY_LEVELS
|
|
37914
|
+
});
|
|
37915
|
+
var ConnectionCapabilitySchema = attenuatedCapabilitySchema({
|
|
37916
|
+
levelSchema: ConnectionCapabilityLevelSchema,
|
|
37917
|
+
levels: CONNECTION_CAPABILITY_LEVELS
|
|
37918
|
+
});
|
|
37919
|
+
var SecretCapabilitySchema = attenuatedCapabilitySchema({
|
|
37920
|
+
levelSchema: SecretCapabilityLevelSchema,
|
|
37921
|
+
levels: SECRET_CAPABILITY_LEVELS
|
|
37922
|
+
});
|
|
37923
|
+
var WebhookCapabilitySchema = attenuatedCapabilitySchema({
|
|
37924
|
+
levelSchema: WebhookCapabilityLevelSchema,
|
|
37925
|
+
levels: WEBHOOK_CAPABILITY_LEVELS
|
|
37926
|
+
});
|
|
37927
|
+
var LocalAutoToolCapabilitiesSchema = external_exports.object({
|
|
37928
|
+
billing: BillingCapabilitySchema.default("none"),
|
|
37929
|
+
projectMembers: ProjectMemberCapabilitySchema.default("none"),
|
|
37930
|
+
// Optional preserves legacy persisted tool snapshots byte-for-byte while
|
|
37931
|
+
// making absence an explicit deny at every read site.
|
|
37932
|
+
waitlistReporting: WaitlistReportingCapabilitySchema.optional(),
|
|
37933
|
+
runtimes: RuntimeCapabilitySchema.default("none"),
|
|
37934
|
+
connections: ConnectionCapabilitySchema.optional(),
|
|
37935
|
+
secrets: SecretCapabilitySchema.optional(),
|
|
37936
|
+
webhooks: WebhookCapabilitySchema.optional()
|
|
37937
|
+
}).strict().default({
|
|
37938
|
+
billing: "none",
|
|
37939
|
+
projectMembers: "none",
|
|
37940
|
+
runtimes: "none"
|
|
37941
|
+
});
|
|
37942
|
+
var SecretReferenceSchema = external_exports.object({
|
|
37943
|
+
$secret: ResourceNameSchema
|
|
37944
|
+
});
|
|
37945
|
+
var NoToolAuthSchema = external_exports.object({
|
|
37946
|
+
kind: external_exports.literal("none")
|
|
37947
|
+
});
|
|
37948
|
+
var OptionalConnectionField = {
|
|
37949
|
+
optional: external_exports.boolean().optional()
|
|
37950
|
+
};
|
|
37951
|
+
var McpOAuthToolAuthSchema = external_exports.object({
|
|
37952
|
+
kind: external_exports.literal("mcp_oauth"),
|
|
37953
|
+
connection: ResourceNameSchema,
|
|
37954
|
+
...OptionalConnectionField
|
|
37955
|
+
});
|
|
37956
|
+
var ConnectionToolAuthSchema = ProviderConnectionReferenceSchema.extend({
|
|
37957
|
+
kind: external_exports.literal("connection"),
|
|
37958
|
+
...OptionalConnectionField
|
|
37959
|
+
});
|
|
37960
|
+
var ConnectionsToolAuthSchema = external_exports.object({
|
|
37961
|
+
kind: external_exports.literal("connections"),
|
|
37962
|
+
connections: external_exports.array(ProviderConnectionReferenceSchema).min(1),
|
|
37963
|
+
...OptionalConnectionField
|
|
37964
|
+
});
|
|
37965
|
+
var ConnectionMcpToolNameSchema = external_exports.string().trim().min(1, "Connection-backed MCP tool names must not be empty");
|
|
37966
|
+
var ConnectionMcpToolAllowlistSchema = external_exports.array(ConnectionMcpToolNameSchema).min(1, "Connection-backed MCP tool allowlists must name at least one tool").superRefine((tools, context) => {
|
|
37967
|
+
const seen = /* @__PURE__ */ new Set();
|
|
37968
|
+
for (const [index, tool] of tools.entries()) {
|
|
37969
|
+
if (seen.has(tool)) {
|
|
37970
|
+
context.addIssue({
|
|
37971
|
+
code: external_exports.ZodIssueCode.custom,
|
|
37972
|
+
message: "Connection-backed MCP tool names must be unique after trimming",
|
|
37973
|
+
path: [index]
|
|
37974
|
+
});
|
|
37975
|
+
}
|
|
37976
|
+
seen.add(tool);
|
|
37977
|
+
}
|
|
37978
|
+
});
|
|
37979
|
+
var ConnectionBackedToolSchema = ProviderConnectionReferenceSchema.extend({
|
|
37980
|
+
kind: external_exports.literal("connection"),
|
|
37981
|
+
description: external_exports.string().trim().min(1).optional(),
|
|
37982
|
+
tools: ConnectionMcpToolAllowlistSchema.optional(),
|
|
37983
|
+
...OptionalConnectionField
|
|
37984
|
+
});
|
|
37985
|
+
var ToolAliasSchema = ResourceNameSchema.refine(
|
|
37986
|
+
(value) => value !== "workspace",
|
|
37987
|
+
{
|
|
37988
|
+
message: 'Tool alias "workspace" is reserved by Claude Code'
|
|
37989
|
+
}
|
|
37990
|
+
);
|
|
37991
|
+
function remoteMcpUrlSchema(input) {
|
|
37992
|
+
return external_exports.string().trim().url().refine(
|
|
37993
|
+
(value) => {
|
|
37994
|
+
const url2 = new URL(value);
|
|
37995
|
+
if (url2.protocol === "https:") {
|
|
37996
|
+
return true;
|
|
37997
|
+
}
|
|
37998
|
+
if (!input?.allowInsecureLocal || url2.protocol !== "http:") {
|
|
37999
|
+
return false;
|
|
38000
|
+
}
|
|
38001
|
+
return url2.hostname === "localhost" || url2.hostname === "127.0.0.1";
|
|
38002
|
+
},
|
|
38003
|
+
{
|
|
38004
|
+
message: "Remote MCP URLs must use https; http is only allowed for explicit local development parsing"
|
|
38005
|
+
}
|
|
38006
|
+
);
|
|
38007
|
+
}
|
|
38008
|
+
function remoteMcpToolSchema(input) {
|
|
38009
|
+
return external_exports.object({
|
|
38010
|
+
kind: external_exports.literal("mcp_remote"),
|
|
38011
|
+
description: external_exports.string().trim().min(1).optional(),
|
|
38012
|
+
url: remoteMcpUrlSchema(input),
|
|
38013
|
+
transport: external_exports.enum(REMOTE_MCP_TRANSPORTS).default("streamable_http"),
|
|
38014
|
+
auth: external_exports.discriminatedUnion("kind", [
|
|
38015
|
+
NoToolAuthSchema,
|
|
38016
|
+
external_exports.object({
|
|
38017
|
+
kind: external_exports.literal("bearer"),
|
|
38018
|
+
token: SecretReferenceSchema
|
|
38019
|
+
}),
|
|
38020
|
+
McpOAuthToolAuthSchema,
|
|
38021
|
+
ProviderConnectionReferenceSchema.extend({
|
|
38022
|
+
kind: external_exports.literal("provider_oauth"),
|
|
38023
|
+
...OptionalConnectionField
|
|
38024
|
+
})
|
|
38025
|
+
]).default({ kind: "none" })
|
|
38026
|
+
});
|
|
38027
|
+
}
|
|
38028
|
+
var RemoteMcpToolSchema = remoteMcpToolSchema();
|
|
38029
|
+
var LocalAutoToolSchema = external_exports.object({
|
|
38030
|
+
kind: external_exports.literal("local"),
|
|
38031
|
+
implementation: external_exports.literal("auto"),
|
|
38032
|
+
description: external_exports.string().trim().min(1).optional(),
|
|
38033
|
+
capabilities: LocalAutoToolCapabilitiesSchema,
|
|
38034
|
+
auth: NoToolAuthSchema.default({ kind: "none" })
|
|
38035
|
+
});
|
|
38036
|
+
var LocalPingToolSchema = external_exports.object({
|
|
38037
|
+
kind: external_exports.literal("local"),
|
|
38038
|
+
implementation: external_exports.literal("ping"),
|
|
38039
|
+
description: external_exports.string().trim().min(1).optional(),
|
|
38040
|
+
auth: NoToolAuthSchema.default({ kind: "none" })
|
|
38041
|
+
});
|
|
38042
|
+
var LocalChatToolSchema = external_exports.object({
|
|
38043
|
+
kind: external_exports.literal("local"),
|
|
38044
|
+
implementation: external_exports.literal("chat"),
|
|
38045
|
+
description: external_exports.string().trim().min(1).optional(),
|
|
38046
|
+
auth: external_exports.discriminatedUnion("kind", [
|
|
38047
|
+
ConnectionToolAuthSchema,
|
|
38048
|
+
ConnectionsToolAuthSchema
|
|
38049
|
+
])
|
|
38050
|
+
});
|
|
38051
|
+
var LocalToolSchema = external_exports.discriminatedUnion(
|
|
38052
|
+
"implementation",
|
|
38053
|
+
[LocalAutoToolSchema, LocalChatToolSchema, LocalPingToolSchema],
|
|
38054
|
+
{
|
|
38055
|
+
error: `Unsupported local tool implementation. Supported implementations: ${LOCAL_TOOL_IMPLEMENTATIONS.join(", ")}`
|
|
38056
|
+
}
|
|
38057
|
+
);
|
|
38058
|
+
var PersistedLocalToolSchema = external_exports.preprocess(
|
|
38059
|
+
normalizePersistedTaskEraLocalAutoTool,
|
|
38060
|
+
LocalToolSchema
|
|
38061
|
+
);
|
|
38062
|
+
function normalizePersistedTaskEraLocalAutoTool(value) {
|
|
38063
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
38064
|
+
return value;
|
|
38065
|
+
}
|
|
38066
|
+
const tool = value;
|
|
38067
|
+
if (tool.kind !== "local" || tool.implementation !== "auto" || typeof tool.capabilities !== "object" || tool.capabilities === null || Array.isArray(tool.capabilities)) {
|
|
38068
|
+
return value;
|
|
38069
|
+
}
|
|
38070
|
+
const {
|
|
38071
|
+
tasks: _tasks,
|
|
38072
|
+
taskManagement: _taskManagement,
|
|
38073
|
+
...capabilities
|
|
38074
|
+
} = tool.capabilities;
|
|
38075
|
+
return { ...tool, capabilities };
|
|
38076
|
+
}
|
|
38077
|
+
var GithubToolSchema = external_exports.object({
|
|
38078
|
+
kind: external_exports.literal("github"),
|
|
38079
|
+
description: external_exports.string().trim().min(1).optional(),
|
|
38080
|
+
tools: external_exports.array(external_exports.enum(GITHUB_MCP_SELECTABLE_TOOL_NAMES)).min(1).optional()
|
|
38081
|
+
});
|
|
38082
|
+
var ToolSpecSchema = external_exports.discriminatedUnion("kind", [
|
|
38083
|
+
RemoteMcpToolSchema,
|
|
38084
|
+
ConnectionBackedToolSchema,
|
|
38085
|
+
LocalToolSchema
|
|
38086
|
+
]);
|
|
38087
|
+
var AgentToolConnectRequestSchema = external_exports.object({
|
|
38088
|
+
redirectUri: external_exports.string().trim().url().refine(
|
|
38089
|
+
(value) => {
|
|
38090
|
+
const url2 = new URL(value);
|
|
38091
|
+
if (url2.protocol === "https:") {
|
|
38092
|
+
return true;
|
|
38093
|
+
}
|
|
38094
|
+
return url2.protocol === "http:" && (url2.hostname === "localhost" || url2.hostname === "127.0.0.1");
|
|
38095
|
+
},
|
|
38096
|
+
{
|
|
38097
|
+
message: "Agent tool OAuth redirect URIs must use https, except localhost loopback callbacks may use http"
|
|
38098
|
+
}
|
|
38099
|
+
).optional()
|
|
38100
|
+
});
|
|
38101
|
+
var AgentToolConnectResponseSchema = external_exports.discriminatedUnion("status", [
|
|
38102
|
+
external_exports.object({
|
|
38103
|
+
status: external_exports.literal("authorization_required"),
|
|
38104
|
+
agent: ResourceNameSchema.optional(),
|
|
38105
|
+
tool: ResourceNameSchema,
|
|
38106
|
+
connection: ResourceNameSchema,
|
|
38107
|
+
authorizationUrl: external_exports.string().trim().url(),
|
|
38108
|
+
message: external_exports.string().trim().min(1)
|
|
38109
|
+
}),
|
|
38110
|
+
external_exports.object({
|
|
38111
|
+
status: external_exports.literal("connected"),
|
|
38112
|
+
agent: ResourceNameSchema.optional(),
|
|
38113
|
+
tool: ResourceNameSchema,
|
|
38114
|
+
connection: ResourceNameSchema,
|
|
38115
|
+
message: external_exports.string().trim().min(1)
|
|
38116
|
+
})
|
|
38117
|
+
]);
|
|
38118
|
+
var AgentToolConnectCompleteResponseSchema = external_exports.object({
|
|
38119
|
+
status: external_exports.literal("connected"),
|
|
38120
|
+
agent: ResourceNameSchema.optional(),
|
|
38121
|
+
tool: ResourceNameSchema,
|
|
38122
|
+
connection: ResourceNameSchema,
|
|
38123
|
+
projectId: ProjectIdSchema
|
|
38124
|
+
});
|
|
38125
|
+
var InlineAgentToolSchema = RemoteMcpToolSchema.extend({
|
|
38126
|
+
disabled: external_exports.boolean().optional()
|
|
38127
|
+
}).or(
|
|
38128
|
+
ConnectionBackedToolSchema.extend({
|
|
38129
|
+
disabled: external_exports.boolean().optional()
|
|
38130
|
+
})
|
|
38131
|
+
).or(
|
|
38132
|
+
LocalToolSchema.and(
|
|
38133
|
+
external_exports.object({
|
|
38134
|
+
disabled: external_exports.boolean().optional()
|
|
38135
|
+
})
|
|
38136
|
+
)
|
|
38137
|
+
).or(
|
|
38138
|
+
GithubToolSchema.extend({
|
|
38139
|
+
disabled: external_exports.boolean().optional()
|
|
38140
|
+
})
|
|
38141
|
+
);
|
|
38142
|
+
var AgentToolRefSchema = InlineAgentToolSchema;
|
|
38143
|
+
var AgentToolsSchema = external_exports.record(ToolAliasSchema, AgentToolRefSchema);
|
|
38144
|
+
|
|
38145
|
+
// ../../packages/schemas/src/trigger-filters.ts
|
|
38146
|
+
var TriggerFilterScalarSchema = external_exports.union([
|
|
38147
|
+
external_exports.null(),
|
|
38148
|
+
external_exports.string(),
|
|
38149
|
+
external_exports.number(),
|
|
38150
|
+
external_exports.boolean()
|
|
38151
|
+
]);
|
|
38152
|
+
var TriggerFilterPathSchema = external_exports.string().refine(
|
|
38153
|
+
(path2) => {
|
|
38154
|
+
if (path2.length === 0 || path2.trim() !== path2) {
|
|
38155
|
+
return false;
|
|
38156
|
+
}
|
|
38157
|
+
if (path2.startsWith("$.")) {
|
|
38158
|
+
const segments = path2.slice(2).split(".");
|
|
38159
|
+
return segments.length > 0 && segments.every(
|
|
38160
|
+
(segment) => segment.length > 0 && segment.trim() === segment
|
|
38161
|
+
);
|
|
38162
|
+
}
|
|
38163
|
+
return !path2.includes(".");
|
|
38164
|
+
},
|
|
38165
|
+
{
|
|
38166
|
+
message: "Trigger filter paths must be a single bare key or use $.path.segments"
|
|
38167
|
+
}
|
|
38168
|
+
);
|
|
38169
|
+
var TriggerFilterClauseSchema = external_exports.union([
|
|
38170
|
+
TriggerFilterScalarSchema,
|
|
38171
|
+
external_exports.object({ contains: TriggerFilterScalarSchema }).strict(),
|
|
38172
|
+
external_exports.object({ exists: external_exports.boolean() }).strict(),
|
|
38173
|
+
external_exports.object({ in: external_exports.array(TriggerFilterScalarSchema).min(1) }).strict(),
|
|
38174
|
+
external_exports.object({ notIn: external_exports.array(TriggerFilterScalarSchema).min(1) }).strict(),
|
|
38175
|
+
external_exports.object({ changedTo: TriggerFilterScalarSchema }).strict()
|
|
38176
|
+
]);
|
|
38177
|
+
var TriggerFilterRecordSchema = external_exports.record(
|
|
38178
|
+
TriggerFilterPathSchema,
|
|
38179
|
+
TriggerFilterClauseSchema
|
|
38180
|
+
);
|
|
38181
|
+
var TriggerFilterSchema = TriggerFilterRecordSchema.default({});
|
|
38182
|
+
|
|
38183
|
+
// ../../packages/schemas/src/trigger-router.ts
|
|
38184
|
+
var TRIGGER_ON_UNMATCHED_POLICIES = [
|
|
38185
|
+
"drop",
|
|
38186
|
+
"warn",
|
|
38187
|
+
"error",
|
|
38188
|
+
"spawn"
|
|
38189
|
+
];
|
|
38190
|
+
var OnUnmatchedSchema = external_exports.enum(TRIGGER_ON_UNMATCHED_POLICIES);
|
|
38191
|
+
var RouteSchema = external_exports.union([
|
|
38192
|
+
external_exports.object({ to: external_exports.literal("new") }).strict(),
|
|
38193
|
+
external_exports.object({
|
|
38194
|
+
to: external_exports.literal("slot"),
|
|
38195
|
+
onUnmatched: OnUnmatchedSchema
|
|
38196
|
+
}).strict(),
|
|
38197
|
+
external_exports.object({ to: external_exports.literal("all") }).strict(),
|
|
38198
|
+
external_exports.object({
|
|
38199
|
+
to: external_exports.object({ target: BindingTargetTypeSchema }).strict(),
|
|
38200
|
+
onUnmatched: OnUnmatchedSchema
|
|
38201
|
+
}).strict()
|
|
38202
|
+
]);
|
|
38203
|
+
var TriggerEffectTargetSchema = external_exports.object({ target: BindingTargetTypeSchema }).strict();
|
|
38204
|
+
var TriggerEffectsSchema = external_exports.object({
|
|
38205
|
+
bind: TriggerEffectTargetSchema.optional(),
|
|
38206
|
+
release: TriggerEffectTargetSchema.optional(),
|
|
38207
|
+
complete: external_exports.literal(true).optional()
|
|
38208
|
+
}).strict();
|
|
38209
|
+
var TriggerGuardSchema = external_exports.object({ managedCheckSuccess: ResourceNameSchema }).strict();
|
|
38210
|
+
var SourceEventRequestSchema = external_exports.object({
|
|
38211
|
+
organizationId: external_exports.string().trim().min(1),
|
|
38212
|
+
projectId: external_exports.string().trim().min(1).nullable().optional(),
|
|
38213
|
+
providerGrantId: external_exports.string().trim().min(1).nullable().optional(),
|
|
38214
|
+
webhookEndpointId: external_exports.string().trim().min(1).nullable().optional(),
|
|
38215
|
+
/** Address the event to one agent; only its triggers may match. */
|
|
38216
|
+
targetAgentResourceId: external_exports.string().trim().min(1).nullable().optional(),
|
|
38217
|
+
event: external_exports.string().trim().min(1),
|
|
38218
|
+
payload: JsonValueSchema2.default({}),
|
|
38219
|
+
dedupKey: external_exports.string().trim().min(1),
|
|
38220
|
+
occurredAt: external_exports.string().datetime().optional()
|
|
38221
|
+
});
|
|
38222
|
+
var EventRoutingWorkflowInputSchema = external_exports.discriminatedUnion("kind", [
|
|
38223
|
+
external_exports.object({
|
|
38224
|
+
kind: external_exports.literal("trigger"),
|
|
38225
|
+
eventRecordId: external_exports.string().uuid()
|
|
38226
|
+
}).strict(),
|
|
38227
|
+
external_exports.object({
|
|
38228
|
+
kind: external_exports.literal("command"),
|
|
38229
|
+
commandId: SessionCommandIdSchema2
|
|
38230
|
+
}).strict()
|
|
38231
|
+
]);
|
|
38232
|
+
var HeartbeatTickWorkflowInputSchema = external_exports.preprocess(
|
|
38233
|
+
normalizeLegacyHeartbeatTickWorkflowInput,
|
|
38234
|
+
external_exports.object({
|
|
38235
|
+
scheduleId: external_exports.string().trim().min(1),
|
|
38236
|
+
organizationId: external_exports.string().trim().min(1),
|
|
38237
|
+
projectId: external_exports.string().trim().min(1).nullable(),
|
|
38238
|
+
agentResourceId: external_exports.string().trim().min(1),
|
|
38239
|
+
agentName: external_exports.string().trim().min(1).max(256).nullable().default(null),
|
|
38240
|
+
triggerId: external_exports.string().trim().min(1).max(512).nullable().default(null),
|
|
38241
|
+
triggerOrdinal: external_exports.number().int().nonnegative(),
|
|
38242
|
+
cron: external_exports.string().trim().min(1).max(512).nullable().default(null),
|
|
38243
|
+
timezone: external_exports.string().trim().min(1).max(128).nullable().default(null),
|
|
38244
|
+
event: external_exports.string().trim().min(1)
|
|
38245
|
+
}).strict()
|
|
38246
|
+
);
|
|
38247
|
+
var GithubPullRequestMergeabilityWorkflowInputSchema = external_exports.object({
|
|
38248
|
+
organizationId: external_exports.string().trim().min(1),
|
|
38249
|
+
providerGrantId: external_exports.string().trim().min(1),
|
|
38250
|
+
source: external_exports.string().trim().min(1),
|
|
38251
|
+
eventPayload: JsonValueSchema2,
|
|
38252
|
+
artifactExternalId: external_exports.string().trim().min(1),
|
|
38253
|
+
installationId: external_exports.string().trim().min(1),
|
|
38254
|
+
repoFullName: external_exports.string().trim().min(1),
|
|
38255
|
+
pullRequestNumber: external_exports.number().int().positive(),
|
|
38256
|
+
headSha: external_exports.string().trim().min(1),
|
|
38257
|
+
headRef: external_exports.string().trim().min(1).optional(),
|
|
38258
|
+
baseSha: external_exports.string().trim().min(1).optional(),
|
|
38259
|
+
ciWatchdogWorkflows: external_exports.array(GithubSyncCiWatchdogWorkflowSchema).max(10).default([]),
|
|
38260
|
+
retryDelaysMs: external_exports.array(external_exports.number().int().nonnegative()).default([1e3, 2e3, 5e3, 1e4, 15e3]),
|
|
38261
|
+
ciWorkflowRunCheckDelayMs: external_exports.number().int().nonnegative().default(GITHUB_SYNC_CI_WATCHDOG_DEFAULT_DELAY_MS)
|
|
38262
|
+
}).strict();
|
|
38263
|
+
var GithubPullRequestMergeabilityWorkflowResultSchema = external_exports.union([
|
|
38264
|
+
external_exports.object({
|
|
38265
|
+
kind: external_exports.literal("conflict"),
|
|
38266
|
+
eventRecordId: external_exports.string().uuid(),
|
|
38267
|
+
created: external_exports.boolean(),
|
|
38268
|
+
dispatch: external_exports.literal("started"),
|
|
38269
|
+
workflowId: external_exports.string().min(1)
|
|
38270
|
+
}),
|
|
38271
|
+
external_exports.object({
|
|
38272
|
+
kind: external_exports.literal("not_conflict"),
|
|
38273
|
+
mergeable: external_exports.boolean().nullable(),
|
|
38274
|
+
mergeableState: external_exports.string().optional(),
|
|
38275
|
+
// Present when the pull request was behind its base with auto-merge
|
|
38276
|
+
// enabled: "updated" if a branch update was requested, "skipped" if
|
|
38277
|
+
// GitHub rejected it (e.g. the head moved since lookup).
|
|
38278
|
+
branchUpdate: external_exports.enum(["updated", "skipped"]).optional(),
|
|
38279
|
+
ciWorkflowDispatch: external_exports.enum(["dispatched", "present", "skipped"]).optional()
|
|
38280
|
+
})
|
|
38281
|
+
]);
|
|
38282
|
+
var EventRoutingTriggerResultSchema = external_exports.object({
|
|
38283
|
+
eventRecordId: external_exports.string().uuid(),
|
|
38284
|
+
matchedTriggers: external_exports.number().int().nonnegative(),
|
|
38285
|
+
deliveries: external_exports.number().int().nonnegative()
|
|
38286
|
+
});
|
|
38287
|
+
function normalizeLegacyHeartbeatTickWorkflowInput(input) {
|
|
38288
|
+
if (!input || typeof input !== "object" || Array.isArray(input)) {
|
|
38289
|
+
return input;
|
|
38290
|
+
}
|
|
38291
|
+
if ("agentResourceId" in input || !("sessionResourceId" in input)) {
|
|
38292
|
+
return input;
|
|
38293
|
+
}
|
|
38294
|
+
const { sessionResourceId, ...rest } = input;
|
|
38295
|
+
return {
|
|
38296
|
+
...rest,
|
|
38297
|
+
agentResourceId: sessionResourceId
|
|
38298
|
+
};
|
|
38299
|
+
}
|
|
38300
|
+
|
|
38301
|
+
// ../../packages/schemas/src/agents.ts
|
|
38302
|
+
var RESOURCE_KIND_AGENT = "agent";
|
|
38303
|
+
var AGENT_HARNESSES = ["claude-code", "codex"];
|
|
38304
|
+
var AgentHarnessSchema = external_exports.enum(AGENT_HARNESSES);
|
|
38305
|
+
var TriggerCheckTimeoutSchema = external_exports.object({
|
|
38306
|
+
seconds: external_exports.number().int().min(1).max(7 * 24 * 60 * 60),
|
|
38307
|
+
conclusion: external_exports.enum(["success", "failure", "skipped"])
|
|
38308
|
+
}).strict();
|
|
38309
|
+
var AgentArchiveAfterInactiveSchema = external_exports.object({
|
|
38310
|
+
seconds: external_exports.number().int().min(60).max(365 * 24 * 60 * 60)
|
|
38311
|
+
}).strict();
|
|
38312
|
+
var AgentSessionPolicySchema = external_exports.object({
|
|
38313
|
+
archiveAfterInactive: AgentArchiveAfterInactiveSchema.optional()
|
|
38314
|
+
}).strict().default({});
|
|
38315
|
+
var AgentConcurrencySchema = external_exports.number().int().refine((value) => value === 1, {
|
|
38316
|
+
message: "Only `concurrency: 1` is supported; larger pools are a deliberate non-goal for now (see docs/agent-concurrency.md)"
|
|
38317
|
+
});
|
|
38318
|
+
var AgentReplacePolicySchema = external_exports.literal("auto");
|
|
38319
|
+
var AgentManagesSchema = external_exports.array(ResourceNameSchema).max(64);
|
|
38320
|
+
var AgentConnectionsSchema = external_exports.union([
|
|
38321
|
+
external_exports.literal("all"),
|
|
38322
|
+
external_exports.literal("none"),
|
|
38323
|
+
external_exports.array(ConnectionNameSchema),
|
|
38324
|
+
external_exports.object({
|
|
38325
|
+
exclude: external_exports.array(ConnectionNameSchema)
|
|
38326
|
+
}).strict()
|
|
38327
|
+
]);
|
|
38328
|
+
var TriggerEventSchema = external_exports.string().trim().min(1);
|
|
38329
|
+
var TriggerEventsSchema = external_exports.array(TriggerEventSchema).min(1).superRefine((events, context) => {
|
|
38330
|
+
const seen = /* @__PURE__ */ new Set();
|
|
38331
|
+
for (const [index, event] of events.entries()) {
|
|
38332
|
+
if (seen.has(event)) {
|
|
38333
|
+
context.addIssue({
|
|
38334
|
+
code: external_exports.ZodIssueCode.custom,
|
|
38335
|
+
path: [index],
|
|
38336
|
+
message: "Trigger events must be unique"
|
|
38337
|
+
});
|
|
38338
|
+
}
|
|
38339
|
+
seen.add(event);
|
|
38340
|
+
}
|
|
38341
|
+
});
|
|
38342
|
+
var PAYLOAD_PREFIXED_TEMPLATE_TOKEN = /\{\{\s*(payload(?:\.[A-Za-z0-9_.-]+)?)\s*\}\}/g;
|
|
38343
|
+
function refineNoPayloadPrefixedTemplateTokens(value, context) {
|
|
38344
|
+
if (value === void 0) {
|
|
38345
|
+
return;
|
|
38346
|
+
}
|
|
38347
|
+
const offending = new Set(
|
|
38348
|
+
[...value.matchAll(PAYLOAD_PREFIXED_TEMPLATE_TOKEN)].map(
|
|
38349
|
+
(match) => match[0]
|
|
38350
|
+
)
|
|
38351
|
+
);
|
|
38352
|
+
if (offending.size > 0) {
|
|
38353
|
+
context.addIssue({
|
|
38354
|
+
code: external_exports.ZodIssueCode.custom,
|
|
38355
|
+
message: `Template renders against the event payload; drop the "payload." prefix (use "{{github.\u2026}}", not "{{payload.github.\u2026}}"). Offending tokens: ${[...offending].join(", ")}`
|
|
38356
|
+
});
|
|
38357
|
+
}
|
|
38358
|
+
}
|
|
38359
|
+
function templateField(guard) {
|
|
38360
|
+
const field = external_exports.string().trim().min(1).max(2e4).optional();
|
|
38361
|
+
return guard === "authoring" ? field.superRefine(refineNoPayloadPrefixedTemplateTokens) : field;
|
|
38362
|
+
}
|
|
38363
|
+
function attachedUserPromptField() {
|
|
38364
|
+
return external_exports.string().min(1).max(2e4).refine((value) => value.trim().length > 0, {
|
|
38365
|
+
message: "Attached user prompt must contain non-whitespace text"
|
|
38366
|
+
}).optional();
|
|
38367
|
+
}
|
|
38368
|
+
function displayTitleField(guard) {
|
|
38369
|
+
const field = external_exports.union([
|
|
38370
|
+
external_exports.literal("infer"),
|
|
38371
|
+
external_exports.string().trim().min(1).max(2e4)
|
|
38372
|
+
]);
|
|
38373
|
+
return (guard === "authoring" ? field.superRefine((value, context) => {
|
|
38374
|
+
if (value !== "infer") {
|
|
38375
|
+
refineNoPayloadPrefixedTemplateTokens(value, context);
|
|
38376
|
+
}
|
|
38377
|
+
}) : field).optional();
|
|
38378
|
+
}
|
|
38379
|
+
var TriggerChecksField = external_exports.array(
|
|
38380
|
+
external_exports.object({
|
|
38381
|
+
name: ResourceNameSchema,
|
|
38382
|
+
displayName: external_exports.string().trim().min(1).max(256),
|
|
38383
|
+
description: external_exports.string().trim().min(1).max(65535),
|
|
38384
|
+
instructions: external_exports.string().trim().min(1).max(2e4).optional(),
|
|
38385
|
+
timeout: TriggerCheckTimeoutSchema.optional(),
|
|
38386
|
+
beginTimeout: TriggerCheckTimeoutSchema.optional(),
|
|
38387
|
+
completeTimeout: TriggerCheckTimeoutSchema.optional()
|
|
38388
|
+
}).strict().superRefine((check2, context) => {
|
|
38389
|
+
if (check2.timeout && check2.beginTimeout) {
|
|
38390
|
+
context.addIssue({
|
|
38391
|
+
code: external_exports.ZodIssueCode.custom,
|
|
38392
|
+
path: ["beginTimeout"],
|
|
38393
|
+
message: "Use either timeout or beginTimeout for the creation-to-begin timeout, not both"
|
|
38394
|
+
});
|
|
38395
|
+
}
|
|
38396
|
+
})
|
|
38397
|
+
).optional();
|
|
38398
|
+
function triggerSharedFields(guard) {
|
|
38399
|
+
return {
|
|
38400
|
+
message: templateField(guard),
|
|
38401
|
+
attachedUserPrompt: attachedUserPromptField(),
|
|
38402
|
+
checks: TriggerChecksField,
|
|
38403
|
+
// Catch-all flag: a `fallback` trigger fires only when no normal (non-
|
|
38404
|
+
// fallback) trigger on the same endpoint + eventKey matched its `where`.
|
|
38405
|
+
// It is the one cross-trigger negation the per-payload matcher cannot
|
|
38406
|
+
// express, so it must be an explicit flag rather than overloaded empty
|
|
38407
|
+
// `where` (which already means match-all). See the trigger-router partition
|
|
38408
|
+
// in packages/db/src/trigger-router/triggers.ts.
|
|
38409
|
+
fallback: external_exports.boolean().default(false),
|
|
38410
|
+
route: RouteSchema,
|
|
38411
|
+
effects: TriggerEffectsSchema.optional(),
|
|
38412
|
+
guard: TriggerGuardSchema.optional()
|
|
38413
|
+
};
|
|
38414
|
+
}
|
|
38415
|
+
var TriggerEventSourceFields = {
|
|
38416
|
+
connection: ConnectionNameSchema.optional(),
|
|
38417
|
+
// Mark a connection-bound trigger optional so apply silently skips it (rather
|
|
38418
|
+
// than failing) when the referenced connection has no active grant. The
|
|
38419
|
+
// skipped trigger is omitted from the applied agent and re-activates on the
|
|
38420
|
+
// next apply/sync once the connection is set up.
|
|
38421
|
+
optional: external_exports.boolean().optional(),
|
|
38422
|
+
endpoint: external_exports.string().trim().min(1).optional(),
|
|
38423
|
+
auth: external_exports.discriminatedUnion("kind", [
|
|
38424
|
+
external_exports.object({
|
|
38425
|
+
kind: external_exports.literal("hmac_sha256"),
|
|
38426
|
+
secretRef: external_exports.string().trim().min(1)
|
|
38427
|
+
}),
|
|
38428
|
+
external_exports.object({
|
|
38429
|
+
kind: external_exports.literal("bearer_token"),
|
|
38430
|
+
secretRef: external_exports.string().trim().min(1)
|
|
38431
|
+
}),
|
|
38432
|
+
external_exports.object({
|
|
38433
|
+
kind: external_exports.literal("none")
|
|
38434
|
+
})
|
|
38435
|
+
]).optional()
|
|
38436
|
+
};
|
|
38437
|
+
function triggerBaseSchema(guard) {
|
|
38438
|
+
return external_exports.object({
|
|
38439
|
+
event: TriggerEventSchema,
|
|
38440
|
+
...triggerSharedFields(guard),
|
|
38441
|
+
...TriggerEventSourceFields
|
|
38442
|
+
}).strict().superRefine((trigger, context) => {
|
|
38443
|
+
validateTriggerChecks(trigger, context, [trigger.event]);
|
|
38444
|
+
validateAttachedUserPrompt(trigger, context, guard);
|
|
38445
|
+
});
|
|
38446
|
+
}
|
|
38447
|
+
function triggerDefinitionBaseSchema(guard) {
|
|
38448
|
+
return external_exports.object({
|
|
38449
|
+
event: TriggerEventSchema.optional(),
|
|
38450
|
+
events: TriggerEventsSchema.optional(),
|
|
38451
|
+
...triggerSharedFields(guard),
|
|
38452
|
+
...TriggerEventSourceFields
|
|
38453
|
+
}).strict().superRefine((trigger, context) => {
|
|
38454
|
+
if (trigger.event && trigger.events) {
|
|
38455
|
+
context.addIssue({
|
|
38456
|
+
code: external_exports.ZodIssueCode.custom,
|
|
38457
|
+
path: ["events"],
|
|
38458
|
+
message: "Use either event or events, not both"
|
|
38459
|
+
});
|
|
38460
|
+
}
|
|
38461
|
+
if (!trigger.event && !trigger.events) {
|
|
38462
|
+
context.addIssue({
|
|
38463
|
+
code: external_exports.ZodIssueCode.custom,
|
|
38464
|
+
path: ["event"],
|
|
38465
|
+
message: "Trigger requires event or events"
|
|
38466
|
+
});
|
|
38467
|
+
}
|
|
38468
|
+
validateTriggerChecks(
|
|
38469
|
+
trigger,
|
|
38470
|
+
context,
|
|
38471
|
+
trigger.event ? [trigger.event] : trigger.events ?? []
|
|
38472
|
+
);
|
|
38473
|
+
validateAttachedUserPrompt(trigger, context, guard);
|
|
38474
|
+
});
|
|
38475
|
+
}
|
|
38476
|
+
function heartbeatTriggerBaseSchema(guard) {
|
|
38477
|
+
return external_exports.object({
|
|
38478
|
+
kind: external_exports.literal("heartbeat"),
|
|
38479
|
+
event: external_exports.never().optional(),
|
|
38480
|
+
connection: external_exports.never().optional(),
|
|
38481
|
+
optional: external_exports.never().optional(),
|
|
38482
|
+
endpoint: external_exports.never().optional(),
|
|
38483
|
+
auth: external_exports.never().optional(),
|
|
38484
|
+
cron: external_exports.string().trim().min(1).max(512),
|
|
38485
|
+
timezone: external_exports.string().trim().min(1).max(128).default("UTC"),
|
|
38486
|
+
...triggerSharedFields(guard)
|
|
38487
|
+
}).strict().superRefine((trigger, context) => {
|
|
38488
|
+
validateTriggerChecks(trigger, context, ["heartbeat"]);
|
|
38489
|
+
validateAttachedUserPrompt(trigger, context, guard);
|
|
38490
|
+
});
|
|
38491
|
+
}
|
|
38492
|
+
var TriggerSchema = triggerBaseSchema("stored").extend({
|
|
38493
|
+
where: external_exports.record(external_exports.string(), JsonValueSchema2).default({})
|
|
38494
|
+
});
|
|
38495
|
+
var ApplyTriggerSchema = triggerBaseSchema("authoring").extend({
|
|
38496
|
+
where: TriggerFilterSchema
|
|
38497
|
+
});
|
|
38498
|
+
var HeartbeatTriggerSchema = heartbeatTriggerBaseSchema(
|
|
38499
|
+
"stored"
|
|
38500
|
+
).extend({
|
|
38501
|
+
where: external_exports.record(external_exports.string(), JsonValueSchema2).default({})
|
|
38502
|
+
});
|
|
38503
|
+
var ApplyHeartbeatTriggerSchema = heartbeatTriggerBaseSchema(
|
|
38504
|
+
"authoring"
|
|
38505
|
+
).extend({
|
|
38506
|
+
where: TriggerFilterSchema
|
|
38507
|
+
});
|
|
38508
|
+
var TriggerDefinitionSchema = triggerDefinitionBaseSchema("stored").extend({
|
|
38509
|
+
where: external_exports.record(external_exports.string(), JsonValueSchema2).default({})
|
|
38510
|
+
});
|
|
38511
|
+
var ApplyTriggerDefinitionSchema = triggerDefinitionBaseSchema(
|
|
38512
|
+
"authoring"
|
|
38513
|
+
).extend({
|
|
38514
|
+
where: TriggerFilterSchema
|
|
38515
|
+
});
|
|
38516
|
+
var TriggersSchema = external_exports.array(external_exports.union([TriggerDefinitionSchema, HeartbeatTriggerSchema])).transform(expandTriggerDefinitions).superRefine(validateAttributedRunsTriggerPairing);
|
|
38517
|
+
var ApplyTriggersSchema = external_exports.array(external_exports.union([ApplyTriggerDefinitionSchema, ApplyHeartbeatTriggerSchema])).transform(expandApplyTriggerDefinitions).superRefine(validateAttributedRunsTriggerPairing);
|
|
38518
|
+
var AVATAR_ASSET_EXTENSIONS = [".png", ".jpg", ".jpeg"];
|
|
38519
|
+
var MAX_AVATAR_ASSET_BYTES = 2 * 1024 * 1024;
|
|
38520
|
+
var AGENT_IDENTITY_DESCRIPTION_MAX_LENGTH = 140;
|
|
38521
|
+
function agentIdentityDescriptionLength(value) {
|
|
38522
|
+
let length = 0;
|
|
38523
|
+
for (const char of value) {
|
|
38524
|
+
const codePoint = char.codePointAt(0) ?? 0;
|
|
38525
|
+
if (codePoint < 32 || codePoint > 126) {
|
|
38526
|
+
length += 6 * char.length;
|
|
38527
|
+
} else if (char === '"' || char === "\\" || char === "/") {
|
|
38528
|
+
length += 2;
|
|
38529
|
+
} else {
|
|
38530
|
+
length += 1;
|
|
38531
|
+
}
|
|
38532
|
+
}
|
|
38533
|
+
return length;
|
|
38534
|
+
}
|
|
38535
|
+
function clampAgentIdentityDescription(value) {
|
|
38536
|
+
if (agentIdentityDescriptionLength(value) <= AGENT_IDENTITY_DESCRIPTION_MAX_LENGTH) {
|
|
38537
|
+
return value;
|
|
38538
|
+
}
|
|
38539
|
+
let clamped = "";
|
|
38540
|
+
let length = 0;
|
|
38541
|
+
for (const char of value) {
|
|
38542
|
+
const charLength = agentIdentityDescriptionLength(char);
|
|
38543
|
+
if (length + charLength > AGENT_IDENTITY_DESCRIPTION_MAX_LENGTH) break;
|
|
38544
|
+
clamped += char;
|
|
38545
|
+
length += charLength;
|
|
38546
|
+
}
|
|
38547
|
+
return clamped.trimEnd();
|
|
38548
|
+
}
|
|
38549
|
+
var SHA256_HEX_PATTERN = /^[a-f0-9]{64}$/;
|
|
38550
|
+
function isAvatarAssetPathShapeValid(asset) {
|
|
38551
|
+
const normalized = asset.trim().replaceAll("\\", "/");
|
|
38552
|
+
if (normalized.length === 0) return false;
|
|
38553
|
+
if (normalized.startsWith("/")) return false;
|
|
38554
|
+
if (/^[A-Za-z]:\//.test(normalized)) return false;
|
|
38555
|
+
if (normalized.split("/").includes("..")) return false;
|
|
38556
|
+
if (!normalized.startsWith(".auto/assets/")) return false;
|
|
38557
|
+
const lower = normalized.toLowerCase();
|
|
38558
|
+
return AVATAR_ASSET_EXTENSIONS.some((ext) => lower.endsWith(ext));
|
|
38559
|
+
}
|
|
38560
|
+
var AgentIdentitySchema = external_exports.object({
|
|
38561
|
+
displayName: external_exports.string().trim().min(1).max(80).optional(),
|
|
38562
|
+
username: external_exports.string().trim().min(1).max(80).optional(),
|
|
38563
|
+
avatar: external_exports.object({
|
|
38564
|
+
asset: external_exports.string().trim().min(1).max(1024).refine(isAvatarAssetPathShapeValid, {
|
|
38565
|
+
message: "avatar.asset must be a relative path under .auto/assets with a .png, .jpg, or .jpeg extension"
|
|
38566
|
+
}),
|
|
38567
|
+
// Content hash of the stored asset bytes. When the apply carries the
|
|
38568
|
+
// asset's bytes, the server re-derives and overwrites this value. When
|
|
38569
|
+
// it does not, a declared hash resolves only an already-stored or
|
|
38570
|
+
// built-in catalog avatar (managed templates bake references this
|
|
38571
|
+
// way); it can never attach arbitrary bytes.
|
|
38572
|
+
sha256: external_exports.string().regex(SHA256_HEX_PATTERN).optional()
|
|
38573
|
+
}).strict().optional(),
|
|
38574
|
+
description: external_exports.string().trim().min(1).refine(
|
|
38575
|
+
(value) => agentIdentityDescriptionLength(value) <= AGENT_IDENTITY_DESCRIPTION_MAX_LENGTH,
|
|
38576
|
+
{
|
|
38577
|
+
message: `description must be at most ${AGENT_IDENTITY_DESCRIPTION_MAX_LENGTH} characters as Slack counts them (a non-ASCII character like "\u2014" counts as 6)`
|
|
38578
|
+
}
|
|
38579
|
+
).optional()
|
|
38580
|
+
}).strict().refine((identity) => Object.keys(identity).length > 0, {
|
|
38581
|
+
message: "Identity requires at least one field"
|
|
38582
|
+
});
|
|
38583
|
+
var PersistedAgentIdentitySchema = external_exports.preprocess(
|
|
38584
|
+
normalizePersistedAgentIdentity,
|
|
38585
|
+
AgentIdentitySchema.optional()
|
|
38586
|
+
);
|
|
38587
|
+
function normalizePersistedAgentIdentity(value) {
|
|
38588
|
+
if (typeof value !== "object" || value === null) return value;
|
|
38589
|
+
const identity = value;
|
|
38590
|
+
if (typeof identity.description !== "string") return value;
|
|
38591
|
+
if (agentIdentityDescriptionLength(identity.description) <= AGENT_IDENTITY_DESCRIPTION_MAX_LENGTH) {
|
|
38592
|
+
return value;
|
|
38593
|
+
}
|
|
38594
|
+
const clamped = clampAgentIdentityDescription(identity.description);
|
|
38595
|
+
const normalizedIdentity = { ...identity };
|
|
38596
|
+
if (clamped.length > 0) normalizedIdentity.description = clamped;
|
|
38597
|
+
else delete normalizedIdentity.description;
|
|
38598
|
+
return Object.keys(normalizedIdentity).length > 0 ? normalizedIdentity : void 0;
|
|
38599
|
+
}
|
|
38600
|
+
var BindingLifecycleSpecSchema = external_exports.object({
|
|
38601
|
+
lifecycle: external_exports.enum(["session", "agent"]).default("session"),
|
|
38602
|
+
bindOn: external_exports.array(BindingActionSchema).optional()
|
|
38603
|
+
}).strict();
|
|
38604
|
+
var AgentBindingsSchema = external_exports.record(external_exports.string(), BindingLifecycleSpecSchema).superRefine((bindings, context) => {
|
|
38605
|
+
for (const key of Object.keys(bindings)) {
|
|
38606
|
+
const parsed = BindingTargetTypeSchema.safeParse(key);
|
|
38607
|
+
if (!parsed.success) {
|
|
38608
|
+
context.addIssue({
|
|
38609
|
+
code: external_exports.ZodIssueCode.custom,
|
|
38610
|
+
path: [key],
|
|
38611
|
+
message: `\`${key}\` is not a valid binding target type`
|
|
38612
|
+
});
|
|
38613
|
+
}
|
|
38614
|
+
}
|
|
38615
|
+
});
|
|
38616
|
+
var AgentSpecFieldsSchema = external_exports.object({
|
|
38617
|
+
harness: external_exports.enum(AGENT_HARNESSES).optional(),
|
|
38618
|
+
model: AgentModelSelectionSchema.optional(),
|
|
38619
|
+
reasoningEffort: AgentReasoningEffortSchema.optional(),
|
|
38620
|
+
systemPrompt: external_exports.string().trim().min(1).max(1e5).optional(),
|
|
38621
|
+
environment: ResourceNameSchema.optional(),
|
|
38622
|
+
identity: external_exports.union([ResourceNameSchema, AgentIdentitySchema]).optional(),
|
|
38623
|
+
initialPrompt: templateField("stored"),
|
|
38624
|
+
displayTitle: displayTitleField("stored"),
|
|
38625
|
+
env: SecretEnvSchema.default({}),
|
|
38626
|
+
mounts: external_exports.array(AgentMountSchema).default([]),
|
|
38627
|
+
triggers: TriggersSchema.default([]),
|
|
38628
|
+
session: AgentSessionPolicySchema,
|
|
38629
|
+
spendCaps: AgentSpendCapsSchema.optional(),
|
|
38630
|
+
concurrency: AgentConcurrencySchema.optional(),
|
|
38631
|
+
replace: AgentReplacePolicySchema.optional(),
|
|
38632
|
+
onReplace: external_exports.string().trim().min(1).max(2e4).optional(),
|
|
38633
|
+
manages: AgentManagesSchema.optional(),
|
|
38634
|
+
bindings: AgentBindingsSchema.default({}),
|
|
38635
|
+
workingDirectory: external_exports.string().trim().min(1).optional(),
|
|
38636
|
+
connections: AgentConnectionsSchema.optional(),
|
|
38637
|
+
tools: AgentToolsSchema.default({})
|
|
38638
|
+
});
|
|
38639
|
+
function validateRunnableConfig(spec, context) {
|
|
38640
|
+
if (!spec.harness) {
|
|
38641
|
+
context.addIssue({
|
|
38642
|
+
code: external_exports.ZodIssueCode.custom,
|
|
38643
|
+
path: ["harness"],
|
|
38644
|
+
message: "Agent requires harness"
|
|
38645
|
+
});
|
|
38646
|
+
}
|
|
38647
|
+
if (!spec.environment) {
|
|
38648
|
+
context.addIssue({
|
|
38649
|
+
code: external_exports.ZodIssueCode.custom,
|
|
38650
|
+
path: ["environment"],
|
|
38651
|
+
message: "Agent requires environment"
|
|
38652
|
+
});
|
|
38653
|
+
}
|
|
38654
|
+
}
|
|
38655
|
+
var AgentSpecSchema = AgentSpecFieldsSchema.superRefine(
|
|
38656
|
+
(spec, context) => {
|
|
38657
|
+
validateRunnableConfig(spec, context);
|
|
38658
|
+
validateAgentModelFieldsForHarness(spec, context);
|
|
38659
|
+
}
|
|
38660
|
+
);
|
|
38661
|
+
var AgentApplySpecFieldsSchema = AgentSpecFieldsSchema.extend({
|
|
38662
|
+
initialPrompt: templateField("authoring"),
|
|
38663
|
+
displayTitle: displayTitleField("authoring"),
|
|
38664
|
+
triggers: ApplyTriggersSchema.default([]),
|
|
38665
|
+
spendCaps: AgentSpendCapsAuthoringSchema.optional()
|
|
38666
|
+
});
|
|
38667
|
+
var AgentApplySpecSchema = AgentApplySpecFieldsSchema.superRefine(
|
|
38668
|
+
(spec, context) => {
|
|
38669
|
+
validateRunnableConfig(spec, context);
|
|
38670
|
+
validateAgentModelFieldsForHarness(spec, context);
|
|
38671
|
+
validateConcurrencyConfig(spec, context);
|
|
38672
|
+
validateBindingsConfig(spec, context);
|
|
38673
|
+
validateTriggerGuardConfig(spec, context);
|
|
38674
|
+
validateTriggerEffectsConfig(spec, context);
|
|
38675
|
+
}
|
|
38676
|
+
);
|
|
38677
|
+
function validateTriggerEffectsConfig(spec, context) {
|
|
38678
|
+
for (const [index, trigger] of spec.triggers.entries()) {
|
|
38679
|
+
if (!trigger.effects?.bind || typeof trigger.route.to !== "object" || trigger.route.onUnmatched !== "spawn" || trigger.effects.bind.target !== trigger.route.to.target) {
|
|
38680
|
+
continue;
|
|
38681
|
+
}
|
|
38682
|
+
context.addIssue({
|
|
38683
|
+
code: external_exports.ZodIssueCode.custom,
|
|
38684
|
+
path: ["triggers", index, "effects", "bind"],
|
|
38685
|
+
message: "`effects.bind` cannot duplicate a target route with `onUnmatched: spawn`; that route claims its target atomically during session creation"
|
|
38686
|
+
});
|
|
38687
|
+
}
|
|
38688
|
+
}
|
|
38689
|
+
function validateTriggerGuardConfig(spec, context) {
|
|
38690
|
+
const managedCheckNames = new Set(
|
|
38691
|
+
spec.triggers.flatMap(
|
|
38692
|
+
(trigger) => (trigger.checks ?? []).map((check2) => check2.name)
|
|
38693
|
+
)
|
|
38694
|
+
);
|
|
38695
|
+
for (const [index, trigger] of spec.triggers.entries()) {
|
|
38696
|
+
if (!trigger.guard) {
|
|
38697
|
+
continue;
|
|
38698
|
+
}
|
|
38699
|
+
if (typeof trigger.route.to !== "object" || trigger.route.to.target !== "github.pull_request") {
|
|
38700
|
+
context.addIssue({
|
|
38701
|
+
code: external_exports.ZodIssueCode.custom,
|
|
38702
|
+
path: ["triggers", index, "guard", "managedCheckSuccess"],
|
|
38703
|
+
message: "`guard.managedCheckSuccess` requires `route.to.target: github.pull_request`: managed check cycles and authoritative head state are pull-request scoped"
|
|
38704
|
+
});
|
|
38705
|
+
}
|
|
38706
|
+
if (!managedCheckNames.has(trigger.guard.managedCheckSuccess)) {
|
|
38707
|
+
context.addIssue({
|
|
38708
|
+
code: external_exports.ZodIssueCode.custom,
|
|
38709
|
+
path: ["triggers", index, "guard", "managedCheckSuccess"],
|
|
38710
|
+
message: "`guard.managedCheckSuccess` must name a managed check declared in this agent's `triggers[].checks`"
|
|
38711
|
+
});
|
|
38712
|
+
}
|
|
38713
|
+
}
|
|
38714
|
+
}
|
|
38715
|
+
function validateConcurrencyConfig(spec, context) {
|
|
38716
|
+
if (spec.concurrency === void 0 && spec.replace !== void 0) {
|
|
38717
|
+
context.addIssue({
|
|
38718
|
+
code: external_exports.ZodIssueCode.custom,
|
|
38719
|
+
path: ["replace"],
|
|
38720
|
+
message: "`replace` requires `concurrency` (the cap it manages)"
|
|
38721
|
+
});
|
|
38722
|
+
}
|
|
38723
|
+
if (spec.onReplace !== void 0 && spec.replace === void 0) {
|
|
38724
|
+
context.addIssue({
|
|
38725
|
+
code: external_exports.ZodIssueCode.custom,
|
|
38726
|
+
path: ["onReplace"],
|
|
38727
|
+
message: "`onReplace` requires `replace: auto` (it is the rebuild prompt delivered to platform-spawned replacements; nothing consumes it otherwise)"
|
|
38728
|
+
});
|
|
38729
|
+
}
|
|
38730
|
+
if (spec.concurrency !== void 0) {
|
|
38731
|
+
return;
|
|
38732
|
+
}
|
|
38733
|
+
const hasSlotClaimingSpawn = spec.triggers.some(
|
|
38734
|
+
(trigger) => isSlotRoute(trigger) && trigger.route.onUnmatched === "spawn"
|
|
38735
|
+
);
|
|
38736
|
+
if (hasSlotClaimingSpawn) {
|
|
38737
|
+
return;
|
|
38738
|
+
}
|
|
38739
|
+
for (const [index, trigger] of spec.triggers.entries()) {
|
|
38740
|
+
if (isSlotRoute(trigger)) {
|
|
38741
|
+
context.addIssue({
|
|
38742
|
+
code: external_exports.ZodIssueCode.custom,
|
|
38743
|
+
path: ["triggers", index, "route", "to"],
|
|
38744
|
+
message: "A `route.to: slot` trigger resolves the agent's concurrency slot; set `concurrency: 1` on the agent or use `onUnmatched: spawn`"
|
|
38745
|
+
});
|
|
38746
|
+
}
|
|
38747
|
+
}
|
|
38748
|
+
}
|
|
38749
|
+
function isSlotRoute(trigger) {
|
|
38750
|
+
return trigger.route.to === "slot";
|
|
38751
|
+
}
|
|
38752
|
+
function validateBindingActions(bindings, context) {
|
|
38753
|
+
for (const [target, config2] of Object.entries(bindings)) {
|
|
38754
|
+
const parsed = BindingTargetTypeSchema.safeParse(target);
|
|
38755
|
+
const targetType = parsed.success ? parsed.data : null;
|
|
38756
|
+
const actions = config2.bindOn ?? [];
|
|
38757
|
+
const seen = /* @__PURE__ */ new Set();
|
|
38758
|
+
for (const [index, action] of actions.entries()) {
|
|
38759
|
+
if (seen.has(action)) {
|
|
38760
|
+
context.addIssue({
|
|
38761
|
+
code: external_exports.ZodIssueCode.custom,
|
|
38762
|
+
path: ["bindings", target, "bindOn", index],
|
|
38763
|
+
message: "Binding actions must be unique"
|
|
38764
|
+
});
|
|
38765
|
+
}
|
|
38766
|
+
seen.add(action);
|
|
38767
|
+
const legal = BINDING_ACTION_LEGAL_TARGETS[action];
|
|
38768
|
+
if (targetType && legal.has(targetType)) {
|
|
38769
|
+
continue;
|
|
38770
|
+
}
|
|
38771
|
+
const legalList = [...legal].join(", ");
|
|
38772
|
+
context.addIssue({
|
|
38773
|
+
code: external_exports.ZodIssueCode.custom,
|
|
38774
|
+
path: ["bindings", target, "bindOn", index],
|
|
38775
|
+
message: `\`bindOn: ${action}\` is legal only for [${legalList}]; "${target}" is not a valid target for this binding action`
|
|
38776
|
+
});
|
|
38777
|
+
}
|
|
38778
|
+
}
|
|
38779
|
+
}
|
|
38780
|
+
function validateBindingsConfig(spec, context) {
|
|
38781
|
+
if (spec.bindings) validateBindingActions(spec.bindings, context);
|
|
38782
|
+
}
|
|
38783
|
+
var AgentStatusSchema = external_exports.object({
|
|
38784
|
+
runCount: external_exports.number().int().nonnegative().default(0),
|
|
38785
|
+
lastActivityAt: external_exports.string().datetime().nullable().default(null)
|
|
38786
|
+
}).default({ runCount: 0, lastActivityAt: null });
|
|
38787
|
+
var AgentResourceOriginSchema = external_exports.enum(["authored", "built_in"]);
|
|
38788
|
+
var AgentResourceSchema = resourceEnvelopeSchema(
|
|
38789
|
+
AgentSpecSchema
|
|
38790
|
+
).extend({
|
|
38791
|
+
status: AgentStatusSchema,
|
|
38792
|
+
origin: AgentResourceOriginSchema.optional()
|
|
38793
|
+
});
|
|
38794
|
+
var PersistedAgentResourceSchema = external_exports.preprocess(
|
|
38795
|
+
normalizePersistedAgentResource,
|
|
38796
|
+
AgentResourceSchema
|
|
38797
|
+
);
|
|
38798
|
+
function normalizePersistedAgentResource(value) {
|
|
38799
|
+
if (typeof value !== "object" || value === null) return value;
|
|
38800
|
+
const resource = value;
|
|
38801
|
+
if (!resource.spec) return value;
|
|
38802
|
+
const normalizedSpec = normalizePersistedAgentSpec(resource.spec);
|
|
38803
|
+
const normalizedIdentity = normalizePersistedAgentIdentity(
|
|
38804
|
+
normalizedSpec.identity
|
|
38805
|
+
);
|
|
38806
|
+
return {
|
|
38807
|
+
...resource,
|
|
38808
|
+
spec: {
|
|
38809
|
+
...normalizedSpec,
|
|
38810
|
+
identity: normalizedIdentity
|
|
38811
|
+
}
|
|
38812
|
+
};
|
|
38813
|
+
}
|
|
38814
|
+
function normalizePersistedAgentSpec(spec) {
|
|
38815
|
+
const normalized = normalizePersistedAgentGrammar(spec);
|
|
38816
|
+
const bindings = normalizePersistedTaskEraBindings(normalized.bindings);
|
|
38817
|
+
const tools = normalizePersistedTaskEraTools(normalized.tools);
|
|
38818
|
+
return { ...normalized, bindings, tools };
|
|
38819
|
+
}
|
|
38820
|
+
function normalizePersistedTaskEraBindings(value) {
|
|
38821
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
38822
|
+
return value;
|
|
38823
|
+
}
|
|
38824
|
+
const { "auto.task": _retiredTaskBinding, ...bindings } = value;
|
|
38825
|
+
return bindings;
|
|
38826
|
+
}
|
|
38827
|
+
function normalizePersistedTaskEraTools(value) {
|
|
38828
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
38829
|
+
return value;
|
|
38830
|
+
}
|
|
38831
|
+
return Object.fromEntries(
|
|
38832
|
+
Object.entries(value).map(([name, tool]) => {
|
|
38833
|
+
if (typeof tool !== "object" || tool === null || Array.isArray(tool)) {
|
|
38834
|
+
return [name, tool];
|
|
38835
|
+
}
|
|
38836
|
+
const candidate = tool;
|
|
38837
|
+
if (candidate.kind !== "local" || candidate.implementation !== "auto" || typeof candidate.capabilities !== "object" || candidate.capabilities === null || Array.isArray(candidate.capabilities)) {
|
|
38838
|
+
return [name, tool];
|
|
38839
|
+
}
|
|
38840
|
+
const {
|
|
38841
|
+
tasks: _tasks,
|
|
38842
|
+
taskManagement: _taskManagement,
|
|
38843
|
+
...capabilities
|
|
38844
|
+
} = candidate.capabilities;
|
|
38845
|
+
return [name, { ...candidate, capabilities }];
|
|
38846
|
+
})
|
|
38847
|
+
);
|
|
38848
|
+
}
|
|
38849
|
+
var AgentApplyRequestSchema = resourceApplySchema(AgentApplySpecSchema);
|
|
38850
|
+
var ApplyTriggerReceiptSchema = external_exports.object({
|
|
38851
|
+
event: external_exports.string().trim().min(1),
|
|
38852
|
+
endpoint: external_exports.string().trim().min(1),
|
|
38853
|
+
ingestUrl: external_exports.string().trim().min(1),
|
|
38854
|
+
status: external_exports.literal("ready")
|
|
38855
|
+
});
|
|
38856
|
+
var AgentApplyResponseSchema = external_exports.union([
|
|
38857
|
+
AgentResourceSchema,
|
|
38858
|
+
external_exports.object({
|
|
38859
|
+
resource: AgentResourceSchema,
|
|
38860
|
+
triggers: external_exports.array(ApplyTriggerReceiptSchema)
|
|
38861
|
+
})
|
|
38862
|
+
]);
|
|
38863
|
+
var AGENT_TELEGRAM_IDENTITY_STATUSES = [
|
|
38864
|
+
"pending",
|
|
38865
|
+
"realized",
|
|
38866
|
+
"broken",
|
|
38867
|
+
"retired"
|
|
38868
|
+
];
|
|
38869
|
+
var AgentTelegramIdentityStatusSchema = external_exports.enum(
|
|
38870
|
+
AGENT_TELEGRAM_IDENTITY_STATUSES
|
|
38871
|
+
);
|
|
38872
|
+
var AgentPresenceIdentitySchema = external_exports.object({
|
|
38873
|
+
identityId: external_exports.string().trim().min(1),
|
|
38874
|
+
provider: external_exports.string().trim().min(1),
|
|
38875
|
+
connection: external_exports.string().trim().min(1),
|
|
38876
|
+
workspace: external_exports.string().trim().min(1),
|
|
38877
|
+
realized: external_exports.boolean(),
|
|
38878
|
+
appId: external_exports.string().trim().min(1).optional(),
|
|
38879
|
+
botUserId: external_exports.string().trim().min(1).optional(),
|
|
38880
|
+
teamId: external_exports.string().trim().min(1).optional(),
|
|
38881
|
+
// Telegram-realized identities: the persona bot's @username and lifecycle
|
|
38882
|
+
// state (creation is human-confirmed in Telegram, so identities can sit
|
|
38883
|
+
// `pending` between the connect step and the managed_bot webhook).
|
|
38884
|
+
botUsername: external_exports.string().trim().min(1).optional(),
|
|
38885
|
+
telegramStatus: AgentTelegramIdentityStatusSchema.optional(),
|
|
38886
|
+
/**
|
|
38887
|
+
* Telegram privacy-mode state verified during connect: true means privacy
|
|
38888
|
+
* mode is disabled and the persona sees all group messages. Not writable
|
|
38889
|
+
* via the Bot API — flipping it is a BotFather step (/setprivacy), or add
|
|
38890
|
+
* the persona as a group admin.
|
|
38891
|
+
*/
|
|
38892
|
+
canReadAllGroupMessages: external_exports.boolean().optional(),
|
|
38893
|
+
// Avatar drift surface: the agent's desired avatar hash + public URL, and
|
|
38894
|
+
// the hash last confirmed applied to the provider app icon. Providers offer
|
|
38895
|
+
// no API for app icons, so application is a guided manual step recorded via
|
|
38896
|
+
// the presence icon endpoint.
|
|
38897
|
+
avatarSha256: external_exports.string().regex(SHA256_HEX_PATTERN).optional(),
|
|
38898
|
+
avatarUrl: external_exports.string().trim().min(1).optional(),
|
|
38899
|
+
appliedIconSha256: external_exports.string().regex(SHA256_HEX_PATTERN).optional(),
|
|
38900
|
+
/**
|
|
38901
|
+
* Scopes the current agent-app scope set requests that this realized
|
|
38902
|
+
* identity's install never granted. Computed at read time; non-empty means
|
|
38903
|
+
* the install predates a scope addition and `auto agents connect
|
|
38904
|
+
* <agent> --reconnect` refreshes it.
|
|
38905
|
+
*/
|
|
38906
|
+
missingScopes: external_exports.array(external_exports.string().trim().min(1)).optional()
|
|
38907
|
+
});
|
|
38908
|
+
var AgentPresenceResponseSchema = external_exports.object({
|
|
38909
|
+
agent: ResourceNameSchema,
|
|
38910
|
+
identities: external_exports.array(AgentPresenceIdentitySchema)
|
|
38911
|
+
});
|
|
38912
|
+
var AgentPresenceConnectRequestSchema = external_exports.object({
|
|
38913
|
+
/**
|
|
38914
|
+
* Rerun the install OAuth for already-realized identities too. The repair
|
|
38915
|
+
* path for a stranded bot token (e.g. the single-use refresh token was
|
|
38916
|
+
* consumed but the rotated pair failed to persist): the stored app
|
|
38917
|
+
* credentials are reused, so this never creates a new Slack app.
|
|
38918
|
+
*/
|
|
38919
|
+
reconnect: external_exports.boolean().default(false)
|
|
38920
|
+
});
|
|
38921
|
+
var AgentPresenceConnectPendingSchema = external_exports.object({
|
|
38922
|
+
identityId: external_exports.string().trim().min(1),
|
|
38923
|
+
connection: external_exports.string().trim().min(1),
|
|
38924
|
+
workspace: external_exports.string().trim().min(1),
|
|
38925
|
+
/**
|
|
38926
|
+
* The URL the operator opens to realize this identity: the Slack install
|
|
38927
|
+
* authorize URL, or the Telegram managed-bot creation deep link.
|
|
38928
|
+
*/
|
|
38929
|
+
authorizationUrl: external_exports.string().trim().url(),
|
|
38930
|
+
/**
|
|
38931
|
+
* Telegram only: the pre-filled bot username in the creation dialog. The
|
|
38932
|
+
* user can edit it there, so it is a suggestion, not the final identity.
|
|
38933
|
+
*/
|
|
38934
|
+
suggestedUsername: external_exports.string().trim().min(1).optional()
|
|
38935
|
+
});
|
|
38936
|
+
var AgentPresenceConnectResponseSchema = external_exports.object({
|
|
38937
|
+
agent: ResourceNameSchema,
|
|
38938
|
+
pending: external_exports.array(AgentPresenceConnectPendingSchema),
|
|
38939
|
+
realized: external_exports.array(AgentPresenceIdentitySchema),
|
|
38940
|
+
message: external_exports.string().trim().min(1)
|
|
38941
|
+
});
|
|
38942
|
+
var AgentPresenceIconRequestSchema = external_exports.object({
|
|
38943
|
+
sha256: external_exports.string().regex(SHA256_HEX_PATTERN)
|
|
38944
|
+
});
|
|
38945
|
+
var AgentPresenceIconResponseSchema = external_exports.object({
|
|
38946
|
+
agent: ResourceNameSchema,
|
|
38947
|
+
identityId: external_exports.string().trim().min(1),
|
|
38948
|
+
appliedIconSha256: external_exports.string().regex(SHA256_HEX_PATTERN)
|
|
38949
|
+
});
|
|
38950
|
+
var AgentPresenceCompleteResponseSchema = external_exports.object({
|
|
38951
|
+
status: external_exports.literal("connected"),
|
|
38952
|
+
agent: ResourceNameSchema,
|
|
38953
|
+
connection: external_exports.string().trim().min(1),
|
|
38954
|
+
workspace: external_exports.string().trim().min(1),
|
|
38955
|
+
organizationId: external_exports.string().trim().min(1),
|
|
38956
|
+
botUserId: external_exports.string().trim().min(1)
|
|
38957
|
+
});
|
|
38958
|
+
function validateAttachedUserPrompt(trigger, context, guard) {
|
|
38959
|
+
if (guard === "authoring" && trigger.attachedUserPrompt !== void 0 && !routeCanSpawn(trigger.route)) {
|
|
38960
|
+
context.addIssue({
|
|
38961
|
+
code: external_exports.ZodIssueCode.custom,
|
|
38962
|
+
path: ["attachedUserPrompt"],
|
|
38963
|
+
message: "Attached user prompt is supported only for routes that can spawn a session"
|
|
38964
|
+
});
|
|
38965
|
+
}
|
|
38966
|
+
}
|
|
38967
|
+
function routeCanSpawn(route) {
|
|
38968
|
+
return route.to === "new" || (route.to === "slot" || typeof route.to === "object") && route.onUnmatched === "spawn";
|
|
38969
|
+
}
|
|
38970
|
+
function validateTriggerChecks(trigger, context, eventKeys) {
|
|
38971
|
+
const checks = trigger.checks ?? [];
|
|
38972
|
+
if (checks.length === 0) {
|
|
38973
|
+
return;
|
|
38974
|
+
}
|
|
38975
|
+
if (eventKeys.some((event) => !event.startsWith("github.pull_request."))) {
|
|
38976
|
+
context.addIssue({
|
|
38977
|
+
code: external_exports.ZodIssueCode.custom,
|
|
38978
|
+
path: ["checks"],
|
|
38979
|
+
message: "Trigger checks are only supported for GitHub pull request events"
|
|
38980
|
+
});
|
|
38981
|
+
}
|
|
38982
|
+
const names = /* @__PURE__ */ new Set();
|
|
38983
|
+
const displayNames = /* @__PURE__ */ new Set();
|
|
38984
|
+
for (const [index, check2] of checks.entries()) {
|
|
38985
|
+
if (names.has(check2.name)) {
|
|
38986
|
+
context.addIssue({
|
|
38987
|
+
code: external_exports.ZodIssueCode.custom,
|
|
38988
|
+
path: ["checks", index, "name"],
|
|
38989
|
+
message: "Trigger check names must be unique"
|
|
38990
|
+
});
|
|
38991
|
+
}
|
|
38992
|
+
names.add(check2.name);
|
|
38993
|
+
if (displayNames.has(check2.displayName)) {
|
|
38994
|
+
context.addIssue({
|
|
38995
|
+
code: external_exports.ZodIssueCode.custom,
|
|
38996
|
+
path: ["checks", index, "displayName"],
|
|
38997
|
+
message: "Trigger check display names must be unique"
|
|
38998
|
+
});
|
|
38999
|
+
}
|
|
39000
|
+
displayNames.add(check2.displayName);
|
|
39001
|
+
}
|
|
39002
|
+
}
|
|
39003
|
+
function expandTriggerDefinitions(triggers) {
|
|
39004
|
+
const expanded = [];
|
|
39005
|
+
for (const trigger of triggers) {
|
|
39006
|
+
if (trigger.kind === "heartbeat") {
|
|
39007
|
+
expanded.push(trigger);
|
|
39008
|
+
continue;
|
|
39009
|
+
}
|
|
39010
|
+
const { events, ...singleTrigger } = trigger;
|
|
39011
|
+
for (const event of trigger.event ? [trigger.event] : events ?? []) {
|
|
39012
|
+
expanded.push({
|
|
39013
|
+
...singleTrigger,
|
|
39014
|
+
event
|
|
39015
|
+
});
|
|
39016
|
+
}
|
|
39017
|
+
}
|
|
39018
|
+
return expanded;
|
|
39019
|
+
}
|
|
39020
|
+
function expandApplyTriggerDefinitions(triggers) {
|
|
39021
|
+
const expanded = [];
|
|
39022
|
+
for (const trigger of triggers) {
|
|
39023
|
+
if (trigger.kind === "heartbeat") {
|
|
39024
|
+
expanded.push(trigger);
|
|
39025
|
+
continue;
|
|
39026
|
+
}
|
|
39027
|
+
const { events, ...singleTrigger } = trigger;
|
|
39028
|
+
for (const event of trigger.event ? [trigger.event] : events ?? []) {
|
|
39029
|
+
expanded.push({
|
|
39030
|
+
...singleTrigger,
|
|
39031
|
+
event
|
|
39032
|
+
});
|
|
39033
|
+
}
|
|
39034
|
+
}
|
|
39035
|
+
return expanded;
|
|
39036
|
+
}
|
|
39037
|
+
function validateAttributedRunsTriggerPairing(triggers, context) {
|
|
39038
|
+
for (const [index, trigger] of triggers.entries()) {
|
|
39039
|
+
if (trigger.kind === "heartbeat" || !trigger.event) {
|
|
39040
|
+
continue;
|
|
39041
|
+
}
|
|
39042
|
+
const eventTrigger = trigger;
|
|
39043
|
+
if (!isAttributedSessionsDeliverTrigger(eventTrigger) || !isChatMessageEvent(eventTrigger)) {
|
|
39044
|
+
continue;
|
|
39045
|
+
}
|
|
39046
|
+
if (hasFilterValue(eventTrigger, "$.auto.authored", false)) {
|
|
39047
|
+
continue;
|
|
39048
|
+
}
|
|
39049
|
+
context.addIssue({
|
|
39050
|
+
code: external_exports.ZodIssueCode.custom,
|
|
39051
|
+
path: [index, "where", "$.auto.authored"],
|
|
39052
|
+
message: 'Chat thread routes must filter out Auto-authored messages with "$.auto.authored": false.'
|
|
39053
|
+
});
|
|
39054
|
+
}
|
|
39055
|
+
for (const [spawnIndex, spawnTrigger] of triggers.entries()) {
|
|
39056
|
+
if (spawnTrigger.kind === "heartbeat" || !spawnTrigger.event) {
|
|
39057
|
+
continue;
|
|
39058
|
+
}
|
|
39059
|
+
if (!isSpawnTrigger(spawnTrigger)) {
|
|
39060
|
+
continue;
|
|
39061
|
+
}
|
|
39062
|
+
for (const [deliverIndex, deliverTrigger] of triggers.entries()) {
|
|
39063
|
+
if (deliverTrigger.kind === "heartbeat" || !deliverTrigger.event || spawnIndex === deliverIndex || spawnTrigger.event !== deliverTrigger.event || !isAttributedSessionsDeliverTrigger(deliverTrigger)) {
|
|
39064
|
+
continue;
|
|
39065
|
+
}
|
|
39066
|
+
if (hasAutoAttributionsExists(spawnTrigger, false) && hasAutoAttributionsExists(deliverTrigger, true)) {
|
|
39067
|
+
continue;
|
|
39068
|
+
}
|
|
39069
|
+
context.addIssue({
|
|
39070
|
+
code: external_exports.ZodIssueCode.custom,
|
|
39071
|
+
path: [deliverIndex, "route"],
|
|
39072
|
+
message: 'Overlapping spawn and chat thread routes on the same event must use mutually exclusive "$.auto.attributions" filters: spawn requires { exists: false }, delivery requires { exists: true }.'
|
|
39073
|
+
});
|
|
39074
|
+
}
|
|
39075
|
+
}
|
|
39076
|
+
}
|
|
39077
|
+
function isSpawnTrigger(trigger) {
|
|
39078
|
+
return routeCanSpawn(trigger.route);
|
|
39079
|
+
}
|
|
39080
|
+
function isAttributedSessionsDeliverTrigger(trigger) {
|
|
39081
|
+
return typeof trigger.route.to === "object" && trigger.route.to.target === "chat.thread";
|
|
39082
|
+
}
|
|
39083
|
+
function hasAutoAttributionsExists(trigger, expected) {
|
|
39084
|
+
const clause = trigger.where?.["$.auto.attributions"];
|
|
39085
|
+
return clause !== null && typeof clause === "object" && !Array.isArray(clause) && Reflect.get(clause, "exists") === expected;
|
|
39086
|
+
}
|
|
39087
|
+
function isChatMessageEvent(trigger) {
|
|
39088
|
+
return trigger.event.startsWith("chat.message.");
|
|
39089
|
+
}
|
|
39090
|
+
function hasFilterValue(trigger, path2, expected) {
|
|
39091
|
+
return trigger.where?.[path2] === expected;
|
|
39092
|
+
}
|
|
35897
39093
|
|
|
35898
39094
|
// ../../packages/schemas/src/requester.ts
|
|
35899
39095
|
var RequesterOriginSchema = external_exports.discriminatedUnion("kind", [
|
|
@@ -36224,6 +39420,125 @@ var SessionCommandRecordSchema = external_exports.discriminatedUnion("kind", [
|
|
|
36224
39420
|
})
|
|
36225
39421
|
]);
|
|
36226
39422
|
|
|
39423
|
+
// ../../packages/schemas/src/validation-diagnostics.ts
|
|
39424
|
+
var AUTO_VALIDATION_DIAGNOSTIC_CATALOG_VERSION = 1;
|
|
39425
|
+
var AUTO_VALIDATION_DIAGNOSTIC_CATALOG = {
|
|
39426
|
+
"auto.validation.input.dialect_conflict": {
|
|
39427
|
+
severity: "error",
|
|
39428
|
+
message: "Choose exactly one supported validation input dialect.",
|
|
39429
|
+
owner: "schemas/project-apply"
|
|
39430
|
+
},
|
|
39431
|
+
"auto.validation.input.invalid_shape": {
|
|
39432
|
+
severity: "error",
|
|
39433
|
+
message: "The validation input does not match the selected dialect.",
|
|
39434
|
+
owner: "schemas/project-apply"
|
|
39435
|
+
},
|
|
39436
|
+
"auto.validation.authoring.facade_required": {
|
|
39437
|
+
severity: "error",
|
|
39438
|
+
message: "This file uses a typed resource envelope where an authoring facade is required.",
|
|
39439
|
+
owner: "schemas/project-apply-files"
|
|
39440
|
+
},
|
|
39441
|
+
"auto.validation.parse.yaml_invalid": {
|
|
39442
|
+
severity: "error",
|
|
39443
|
+
message: "The Auto authoring file could not be parsed as YAML or JSON.",
|
|
39444
|
+
owner: "schemas/project-apply-files"
|
|
39445
|
+
},
|
|
39446
|
+
"auto.validation.schema_version.invalid": {
|
|
39447
|
+
severity: "error",
|
|
39448
|
+
message: "The authored schema version must be a positive integer.",
|
|
39449
|
+
owner: "schemas/project-apply-files"
|
|
39450
|
+
},
|
|
39451
|
+
"auto.validation.schema_version.unsupported": {
|
|
39452
|
+
severity: "error",
|
|
39453
|
+
message: "This Auto release does not support the authored schema version.",
|
|
39454
|
+
owner: "schemas/project-apply-files"
|
|
39455
|
+
},
|
|
39456
|
+
"auto.validation.authoring.unknown_field": {
|
|
39457
|
+
severity: "error",
|
|
39458
|
+
message: "The versioned authoring document contains an unknown field.",
|
|
39459
|
+
owner: "schemas/project-apply-files"
|
|
39460
|
+
},
|
|
39461
|
+
"auto.validation.schema.invalid": {
|
|
39462
|
+
severity: "error",
|
|
39463
|
+
message: "The Auto resource does not match its schema.",
|
|
39464
|
+
owner: "schemas/project-apply-files"
|
|
39465
|
+
},
|
|
39466
|
+
"auto.validation.legacy.unknown": {
|
|
39467
|
+
severity: "error",
|
|
39468
|
+
message: "Auto validation failed without a recognized diagnostic code.",
|
|
39469
|
+
owner: "schemas/project-apply"
|
|
39470
|
+
}
|
|
39471
|
+
};
|
|
39472
|
+
var AUTO_VALIDATION_DIAGNOSTIC_CODES = Object.freeze(
|
|
39473
|
+
Object.keys(AUTO_VALIDATION_DIAGNOSTIC_CATALOG)
|
|
39474
|
+
);
|
|
39475
|
+
var AutoValidationDiagnosticSchema = external_exports.object({
|
|
39476
|
+
catalogVersion: external_exports.number().int().positive(),
|
|
39477
|
+
// Keep readers forward-compatible with codes added by a newer producer.
|
|
39478
|
+
// Catalog membership is enforced when this version creates diagnostics.
|
|
39479
|
+
code: external_exports.string().min(1),
|
|
39480
|
+
severity: external_exports.enum(["error", "warning", "info"]),
|
|
39481
|
+
blocking: external_exports.boolean(),
|
|
39482
|
+
message: external_exports.string().min(1),
|
|
39483
|
+
path: external_exports.array(external_exports.union([external_exports.string(), external_exports.number().int()])).optional(),
|
|
39484
|
+
location: external_exports.object({
|
|
39485
|
+
file: external_exports.string().min(1),
|
|
39486
|
+
line: external_exports.number().int().positive().optional(),
|
|
39487
|
+
column: external_exports.number().int().positive().optional(),
|
|
39488
|
+
documentIndex: external_exports.number().int().nonnegative().optional()
|
|
39489
|
+
}).optional(),
|
|
39490
|
+
remediation: external_exports.object({
|
|
39491
|
+
summary: external_exports.string().min(1),
|
|
39492
|
+
correctedCall: JsonValueSchema2.optional()
|
|
39493
|
+
}).optional()
|
|
39494
|
+
});
|
|
39495
|
+
function autoValidationDiagnostic(input) {
|
|
39496
|
+
const catalogEntry = AUTO_VALIDATION_DIAGNOSTIC_CATALOG[input.code];
|
|
39497
|
+
return AutoValidationDiagnosticSchema.parse({
|
|
39498
|
+
catalogVersion: AUTO_VALIDATION_DIAGNOSTIC_CATALOG_VERSION,
|
|
39499
|
+
code: input.code,
|
|
39500
|
+
severity: catalogEntry.severity,
|
|
39501
|
+
blocking: input.blocking ?? true,
|
|
39502
|
+
message: catalogEntry.message,
|
|
39503
|
+
...input.path ? { path: input.path } : {},
|
|
39504
|
+
...input.location ? { location: input.location } : {},
|
|
39505
|
+
...input.remediation ? { remediation: input.remediation } : {}
|
|
39506
|
+
});
|
|
39507
|
+
}
|
|
39508
|
+
var AutoValidationDiagnosticError = class extends Error {
|
|
39509
|
+
diagnostic;
|
|
39510
|
+
// Compiler-owned, content-free provenance for immediate telemetry. Keep it
|
|
39511
|
+
// off the serialized diagnostic contract and immutable after first resolve.
|
|
39512
|
+
#authoringOrigin;
|
|
39513
|
+
constructor(message, diagnostic) {
|
|
39514
|
+
super(message);
|
|
39515
|
+
this.name = "AutoValidationDiagnosticError";
|
|
39516
|
+
this.diagnostic = diagnostic;
|
|
39517
|
+
}
|
|
39518
|
+
get authoringOrigin() {
|
|
39519
|
+
return this.#authoringOrigin;
|
|
39520
|
+
}
|
|
39521
|
+
withAuthoringOrigin(origin) {
|
|
39522
|
+
this.#authoringOrigin ??= origin;
|
|
39523
|
+
return this;
|
|
39524
|
+
}
|
|
39525
|
+
toJSON() {
|
|
39526
|
+
return {
|
|
39527
|
+
name: this.name,
|
|
39528
|
+
message: this.message,
|
|
39529
|
+
diagnostic: this.diagnostic
|
|
39530
|
+
};
|
|
39531
|
+
}
|
|
39532
|
+
};
|
|
39533
|
+
function autoValidationDiagnosticFromError(error51) {
|
|
39534
|
+
if (error51 instanceof AutoValidationDiagnosticError) {
|
|
39535
|
+
return error51.diagnostic;
|
|
39536
|
+
}
|
|
39537
|
+
return autoValidationDiagnostic({
|
|
39538
|
+
code: "auto.validation.legacy.unknown"
|
|
39539
|
+
});
|
|
39540
|
+
}
|
|
39541
|
+
|
|
36227
39542
|
// ../../packages/schemas/src/runtime-log.ts
|
|
36228
39543
|
var RUNTIME_LOG_LEVELS = ["debug", "info", "warn", "error"];
|
|
36229
39544
|
var RuntimeLogLevelSchema = external_exports.enum(RUNTIME_LOG_LEVELS);
|
|
@@ -71600,6 +74915,220 @@ function one(e, t) {
|
|
|
71600
74915
|
return null;
|
|
71601
74916
|
}
|
|
71602
74917
|
|
|
74918
|
+
// ../../packages/schemas/src/project-apply-files/source.ts
|
|
74919
|
+
var import_yaml = __toESM(require_dist(), 1);
|
|
74920
|
+
|
|
74921
|
+
// ../../packages/schemas/src/project-apply-files/schema-version.ts
|
|
74922
|
+
var CURRENT_AUTHORED_SCHEMA_VERSION = 1;
|
|
74923
|
+
var LEGACY_AUTHORED_SCHEMA_DIALECT = Object.freeze({
|
|
74924
|
+
kind: "legacy"
|
|
74925
|
+
});
|
|
74926
|
+
var AUTHORED_SCHEMA_MIGRATIONS = Object.freeze([]);
|
|
74927
|
+
var CURRENT_AUTHORED_SCHEMA_DIALECT = Object.freeze({
|
|
74928
|
+
kind: "versioned",
|
|
74929
|
+
version: CURRENT_AUTHORED_SCHEMA_VERSION
|
|
74930
|
+
});
|
|
74931
|
+
function selectAuthoredSchemaDocument(input) {
|
|
74932
|
+
if (!isRecord(input.document) || !Object.hasOwn(input.document, "schemaVersion")) {
|
|
74933
|
+
return {
|
|
74934
|
+
dialect: LEGACY_AUTHORED_SCHEMA_DIALECT,
|
|
74935
|
+
value: input.document
|
|
74936
|
+
};
|
|
74937
|
+
}
|
|
74938
|
+
const version2 = input.document.schemaVersion;
|
|
74939
|
+
if (typeof version2 !== "number" || !isPositiveInteger(version2)) {
|
|
74940
|
+
throw malformedSchemaVersionError(input);
|
|
74941
|
+
}
|
|
74942
|
+
if (version2 > CURRENT_AUTHORED_SCHEMA_VERSION) {
|
|
74943
|
+
throw unsupportedSchemaVersionError(input, version2);
|
|
74944
|
+
}
|
|
74945
|
+
const { schemaVersion: _controlField, ...body } = input.document;
|
|
74946
|
+
return {
|
|
74947
|
+
dialect: CURRENT_AUTHORED_SCHEMA_DIALECT,
|
|
74948
|
+
value: migrateAuthoredSchemaDocument({
|
|
74949
|
+
document: body,
|
|
74950
|
+
fromVersion: version2,
|
|
74951
|
+
toVersion: CURRENT_AUTHORED_SCHEMA_VERSION,
|
|
74952
|
+
migrations: AUTHORED_SCHEMA_MIGRATIONS
|
|
74953
|
+
})
|
|
74954
|
+
};
|
|
74955
|
+
}
|
|
74956
|
+
function migrateAuthoredSchemaDocument(input) {
|
|
74957
|
+
if (!isPositiveInteger(input.fromVersion) || !isPositiveInteger(input.toVersion)) {
|
|
74958
|
+
throw new Error(
|
|
74959
|
+
"Authored schema migration endpoints must be positive integers"
|
|
74960
|
+
);
|
|
74961
|
+
}
|
|
74962
|
+
if (input.fromVersion > input.toVersion) {
|
|
74963
|
+
throw new Error(
|
|
74964
|
+
`Authored schema migrations cannot move backward from ${input.fromVersion} to ${input.toVersion}`
|
|
74965
|
+
);
|
|
74966
|
+
}
|
|
74967
|
+
let document2 = structuredClone(input.document);
|
|
74968
|
+
for (let version2 = input.fromVersion; version2 < input.toVersion; version2 += 1) {
|
|
74969
|
+
const edges = input.migrations.filter(
|
|
74970
|
+
(edge) => edge.fromVersion === version2
|
|
74971
|
+
);
|
|
74972
|
+
if (edges.length !== 1 || edges[0]?.toVersion !== version2 + 1) {
|
|
74973
|
+
throw new Error(
|
|
74974
|
+
`Authored schema migration chain requires exactly one ${version2} -> ${version2 + 1} edge`
|
|
74975
|
+
);
|
|
74976
|
+
}
|
|
74977
|
+
document2 = edges[0].migrate(structuredClone(document2));
|
|
74978
|
+
}
|
|
74979
|
+
return document2;
|
|
74980
|
+
}
|
|
74981
|
+
function malformedSchemaVersionError(input) {
|
|
74982
|
+
return new AutoValidationDiagnosticError(
|
|
74983
|
+
`Invalid schemaVersion in ${documentLabel(input)}: expected a positive integer`,
|
|
74984
|
+
autoValidationDiagnostic({
|
|
74985
|
+
code: "auto.validation.schema_version.invalid",
|
|
74986
|
+
path: ["schemaVersion"],
|
|
74987
|
+
location: diagnosticLocation(input),
|
|
74988
|
+
remediation: {
|
|
74989
|
+
summary: `Set schemaVersion to ${CURRENT_AUTHORED_SCHEMA_VERSION}, or remove it to retain the legacy dialect.`
|
|
74990
|
+
}
|
|
74991
|
+
})
|
|
74992
|
+
);
|
|
74993
|
+
}
|
|
74994
|
+
function unsupportedSchemaVersionError(input, version2) {
|
|
74995
|
+
return new AutoValidationDiagnosticError(
|
|
74996
|
+
`Unsupported schemaVersion ${version2} in ${documentLabel(input)}: this Auto release supports through ${CURRENT_AUTHORED_SCHEMA_VERSION}`,
|
|
74997
|
+
autoValidationDiagnostic({
|
|
74998
|
+
code: "auto.validation.schema_version.unsupported",
|
|
74999
|
+
path: ["schemaVersion"],
|
|
75000
|
+
location: diagnosticLocation(input),
|
|
75001
|
+
remediation: {
|
|
75002
|
+
summary: "Upgrade Auto to a release that supports this authored schema version, then validate again."
|
|
75003
|
+
}
|
|
75004
|
+
})
|
|
75005
|
+
);
|
|
75006
|
+
}
|
|
75007
|
+
function documentLabel(input) {
|
|
75008
|
+
return `${input.location.file} document ${input.documentIndex + 1}`;
|
|
75009
|
+
}
|
|
75010
|
+
function diagnosticLocation(input) {
|
|
75011
|
+
return {
|
|
75012
|
+
...input.topLevelLocations.schemaVersion ?? input.location,
|
|
75013
|
+
documentIndex: input.documentIndex
|
|
75014
|
+
};
|
|
75015
|
+
}
|
|
75016
|
+
function isRecord(value) {
|
|
75017
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
75018
|
+
}
|
|
75019
|
+
function isPositiveInteger(value) {
|
|
75020
|
+
return Number.isInteger(value) && value > 0;
|
|
75021
|
+
}
|
|
75022
|
+
|
|
75023
|
+
// ../../packages/schemas/src/project-apply-files/source.ts
|
|
75024
|
+
var APPLY_DIRECTORIES = {
|
|
75025
|
+
[RESOURCE_KIND_AGENT]: "agents"
|
|
75026
|
+
};
|
|
75027
|
+
var PROJECT_APPLY_RESOURCE_DIRECTORIES = Object.freeze([
|
|
75028
|
+
APPLY_DIRECTORIES[RESOURCE_KIND_AGENT]
|
|
75029
|
+
]);
|
|
75030
|
+
function readSourceDocuments(file2) {
|
|
75031
|
+
const source = Buffer.from(file2.contentBase64, "base64").toString("utf8");
|
|
75032
|
+
const lineCounter = new import_yaml.LineCounter();
|
|
75033
|
+
let parsedDocuments;
|
|
75034
|
+
try {
|
|
75035
|
+
parsedDocuments = (0, import_yaml.parseAllDocuments)(source, {
|
|
75036
|
+
keepSourceTokens: true,
|
|
75037
|
+
lineCounter
|
|
75038
|
+
});
|
|
75039
|
+
const parseError = parsedDocuments.flatMap((document2) => document2.errors).at(0);
|
|
75040
|
+
if (parseError) {
|
|
75041
|
+
throw parseError;
|
|
75042
|
+
}
|
|
75043
|
+
} catch {
|
|
75044
|
+
throw new AutoValidationDiagnosticError(
|
|
75045
|
+
`Invalid apply file ${file2.path}: YAML or JSON could not be parsed`,
|
|
75046
|
+
autoValidationDiagnostic({
|
|
75047
|
+
code: "auto.validation.parse.yaml_invalid",
|
|
75048
|
+
location: { file: file2.path },
|
|
75049
|
+
remediation: {
|
|
75050
|
+
summary: "Fix the YAML or JSON syntax in this file, then validate again."
|
|
75051
|
+
}
|
|
75052
|
+
})
|
|
75053
|
+
);
|
|
75054
|
+
}
|
|
75055
|
+
return parsedDocuments.flatMap((document2, documentIndex) => {
|
|
75056
|
+
if (document2.contents === null) {
|
|
75057
|
+
return [];
|
|
75058
|
+
}
|
|
75059
|
+
const value = sourceDocumentValue(document2, file2.path);
|
|
75060
|
+
const location = sourceNodeLocation(
|
|
75061
|
+
document2.contents,
|
|
75062
|
+
file2.path,
|
|
75063
|
+
lineCounter
|
|
75064
|
+
);
|
|
75065
|
+
const topLevelLocations = topLevelSourceLocations(
|
|
75066
|
+
document2.contents,
|
|
75067
|
+
file2.path,
|
|
75068
|
+
lineCounter
|
|
75069
|
+
);
|
|
75070
|
+
const selected = selectAuthoredSchemaDocument({
|
|
75071
|
+
document: value,
|
|
75072
|
+
documentIndex,
|
|
75073
|
+
location,
|
|
75074
|
+
topLevelLocations
|
|
75075
|
+
});
|
|
75076
|
+
return [
|
|
75077
|
+
{
|
|
75078
|
+
...selected,
|
|
75079
|
+
documentIndex,
|
|
75080
|
+
location,
|
|
75081
|
+
topLevelLocations
|
|
75082
|
+
}
|
|
75083
|
+
];
|
|
75084
|
+
});
|
|
75085
|
+
}
|
|
75086
|
+
function sourceDocumentValue(document2, file2) {
|
|
75087
|
+
try {
|
|
75088
|
+
return document2.toJSON();
|
|
75089
|
+
} catch {
|
|
75090
|
+
throw invalidSourceSyntaxError(file2);
|
|
75091
|
+
}
|
|
75092
|
+
}
|
|
75093
|
+
function invalidSourceSyntaxError(file2) {
|
|
75094
|
+
return new AutoValidationDiagnosticError(
|
|
75095
|
+
`Invalid apply file ${file2}: YAML or JSON could not be parsed`,
|
|
75096
|
+
autoValidationDiagnostic({
|
|
75097
|
+
code: "auto.validation.parse.yaml_invalid",
|
|
75098
|
+
location: { file: file2 },
|
|
75099
|
+
remediation: {
|
|
75100
|
+
summary: "Fix the YAML or JSON syntax in this file, then validate again."
|
|
75101
|
+
}
|
|
75102
|
+
})
|
|
75103
|
+
);
|
|
75104
|
+
}
|
|
75105
|
+
function normalizeSourcePath(path2) {
|
|
75106
|
+
return path2.replaceAll("\\", "/").replace(/^\/+|\/+$/g, "");
|
|
75107
|
+
}
|
|
75108
|
+
function topLevelSourceLocations(node, file2, lineCounter) {
|
|
75109
|
+
if (!(0, import_yaml.isMap)(node)) {
|
|
75110
|
+
return {};
|
|
75111
|
+
}
|
|
75112
|
+
return Object.fromEntries(
|
|
75113
|
+
node.items.flatMap((pair) => {
|
|
75114
|
+
const key = pair.key?.toJSON?.();
|
|
75115
|
+
if (typeof key !== "string") {
|
|
75116
|
+
return [];
|
|
75117
|
+
}
|
|
75118
|
+
return [[key, sourceNodeLocation(pair.key, file2, lineCounter)]];
|
|
75119
|
+
})
|
|
75120
|
+
);
|
|
75121
|
+
}
|
|
75122
|
+
function sourceNodeLocation(node, file2, lineCounter) {
|
|
75123
|
+
const range = node?.range;
|
|
75124
|
+
const position = lineCounter.linePos(range?.[0] ?? 0);
|
|
75125
|
+
return {
|
|
75126
|
+
file: normalizeSourcePath(file2),
|
|
75127
|
+
line: position.line,
|
|
75128
|
+
column: position.col
|
|
75129
|
+
};
|
|
75130
|
+
}
|
|
75131
|
+
|
|
71603
75132
|
// ../../node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
|
|
71604
75133
|
var LATEST_PROTOCOL_VERSION = "2025-11-25";
|
|
71605
75134
|
var DEFAULT_NEGOTIATED_PROTOCOL_VERSION = "2025-03-26";
|
|
@@ -73121,9 +76650,6 @@ var UrlElicitationRequiredError = class extends McpError {
|
|
|
73121
76650
|
}
|
|
73122
76651
|
};
|
|
73123
76652
|
|
|
73124
|
-
// src/commands/agent-bridge/harness/agent-facing-auto-mcp.ts
|
|
73125
|
-
var import_yaml = __toESM(require_dist(), 1);
|
|
73126
|
-
|
|
73127
76653
|
// src/lib/project-apply-filesystem-source.ts
|
|
73128
76654
|
import { readFileSync as readFileSync2, readdirSync as readdirSync2 } from "fs";
|
|
73129
76655
|
import { basename as basename3, dirname as dirname4, join as join5, relative as relative2, resolve as resolve5 } from "path";
|
|
@@ -73286,12 +76812,12 @@ async function createClaudeAutoMcpServer(input) {
|
|
|
73286
76812
|
});
|
|
73287
76813
|
const transformed = input.transformDryRun ? transformToolsListResponse(JSON.stringify(listResponse)) : { body: JSON.stringify(listResponse), pathsCompatible: false };
|
|
73288
76814
|
const listed = JSON.parse(transformed.body);
|
|
73289
|
-
if (
|
|
76815
|
+
if (isRecord3(listed.error)) {
|
|
73290
76816
|
throw new AgentBridgeTerminalPrepareError(
|
|
73291
76817
|
typeof listed.error.message === "string" ? listed.error.message : `Auto MCP server ${input.name} failed tools/list`
|
|
73292
76818
|
);
|
|
73293
76819
|
}
|
|
73294
|
-
const result =
|
|
76820
|
+
const result = isRecord3(listed.result) ? listed.result : {};
|
|
73295
76821
|
const tools = Array.isArray(result.tools) ? result.tools : [];
|
|
73296
76822
|
const sdkServer = tJe({ name: input.name, version: "1" });
|
|
73297
76823
|
sdkServer.instance.server.registerCapabilities({ tools: {} });
|
|
@@ -73324,7 +76850,7 @@ async function createClaudeAutoMcpServer(input) {
|
|
|
73324
76850
|
message,
|
|
73325
76851
|
commandId: exactActiveCommandId(input.activeTurnCommandIds)
|
|
73326
76852
|
});
|
|
73327
|
-
if (
|
|
76853
|
+
if (isRecord3(response.error)) {
|
|
73328
76854
|
return {
|
|
73329
76855
|
content: [
|
|
73330
76856
|
{
|
|
@@ -73364,7 +76890,7 @@ function parseJsonRpcResponseBody(body) {
|
|
|
73364
76890
|
}
|
|
73365
76891
|
try {
|
|
73366
76892
|
const candidate = JSON.parse(line.slice("data:".length).trim());
|
|
73367
|
-
if (
|
|
76893
|
+
if (isRecord3(candidate)) {
|
|
73368
76894
|
parsed = candidate;
|
|
73369
76895
|
}
|
|
73370
76896
|
} catch {
|
|
@@ -73376,7 +76902,7 @@ function parseJsonRpcResponseBody(body) {
|
|
|
73376
76902
|
return parsed;
|
|
73377
76903
|
}
|
|
73378
76904
|
function asCallToolResult(value) {
|
|
73379
|
-
if (
|
|
76905
|
+
if (isRecord3(value) && Array.isArray(value.content)) {
|
|
73380
76906
|
return value;
|
|
73381
76907
|
}
|
|
73382
76908
|
return {
|
|
@@ -73384,7 +76910,7 @@ function asCallToolResult(value) {
|
|
|
73384
76910
|
};
|
|
73385
76911
|
}
|
|
73386
76912
|
function agentFacingDryRunTool(tool) {
|
|
73387
|
-
if (!
|
|
76913
|
+
if (!isRecord3(tool) || tool.name !== DRY_RUN_TOOL_NAME) {
|
|
73388
76914
|
return tool;
|
|
73389
76915
|
}
|
|
73390
76916
|
if (typeof tool.description !== "string" || !tool.description.includes(AUTO_RESOURCES_DRY_RUN_PATHS_PROTOCOL_MARKER)) {
|
|
@@ -73413,7 +76939,7 @@ function agentFacingDryRunTool(tool) {
|
|
|
73413
76939
|
};
|
|
73414
76940
|
}
|
|
73415
76941
|
function resolveAgentFacingDryRun(input) {
|
|
73416
|
-
if (!
|
|
76942
|
+
if (!isRecord3(input.arguments)) {
|
|
73417
76943
|
throw new Error(`Dry-run arguments must be an object. ${correctedCall}`);
|
|
73418
76944
|
}
|
|
73419
76945
|
const argumentsValue = input.arguments;
|
|
@@ -73571,9 +77097,12 @@ function readContainedTextFile(cwdRoot, path2) {
|
|
|
73571
77097
|
}
|
|
73572
77098
|
function localImportPaths(content, importerPath) {
|
|
73573
77099
|
const imports = [];
|
|
73574
|
-
for (const document2 of (
|
|
73575
|
-
|
|
73576
|
-
|
|
77100
|
+
for (const document2 of readSourceDocuments({
|
|
77101
|
+
path: importerPath,
|
|
77102
|
+
contentBase64: Buffer.from(content, "utf8").toString("base64")
|
|
77103
|
+
})) {
|
|
77104
|
+
const value = document2.value;
|
|
77105
|
+
if (!isRecord3(value) || !Array.isArray(value.imports)) {
|
|
73577
77106
|
continue;
|
|
73578
77107
|
}
|
|
73579
77108
|
for (const importPath of value.imports) {
|
|
@@ -73745,8 +77274,8 @@ async function startAutoMcpProxy(input) {
|
|
|
73745
77274
|
return { server, url: `http://127.0.0.1:${address.port}/mcp` };
|
|
73746
77275
|
}
|
|
73747
77276
|
function prepareDryRunToolCall(input) {
|
|
73748
|
-
const params =
|
|
73749
|
-
const argumentsValue =
|
|
77277
|
+
const params = isRecord3(input.message.params) ? input.message.params : {};
|
|
77278
|
+
const argumentsValue = isRecord3(params.arguments) ? params.arguments : {};
|
|
73750
77279
|
const hasLegacyDialect = ["files", "resources"].some(
|
|
73751
77280
|
(key) => Object.hasOwn(argumentsValue, key)
|
|
73752
77281
|
);
|
|
@@ -73781,6 +77310,15 @@ function prepareDryRunToolCall(input) {
|
|
|
73781
77310
|
if (error51 instanceof Error && error51.message === "legacy-pass-through") {
|
|
73782
77311
|
return { kind: "forward", message: input.message };
|
|
73783
77312
|
}
|
|
77313
|
+
if (error51 instanceof AutoValidationDiagnosticError) {
|
|
77314
|
+
return toolError(
|
|
77315
|
+
input.message.id,
|
|
77316
|
+
JSON.stringify({
|
|
77317
|
+
error: error51.message,
|
|
77318
|
+
diagnostic: autoValidationDiagnosticFromError(error51)
|
|
77319
|
+
})
|
|
77320
|
+
);
|
|
77321
|
+
}
|
|
73784
77322
|
return toolError(
|
|
73785
77323
|
input.message.id,
|
|
73786
77324
|
error51 instanceof Error ? error51.message : String(error51)
|
|
@@ -73791,7 +77329,7 @@ function transformToolsListResponse(body) {
|
|
|
73791
77329
|
const parsed = JSON.parse(body);
|
|
73792
77330
|
let compatible = false;
|
|
73793
77331
|
const transformed = transformJsonRpcMessages(parsed, (message) => {
|
|
73794
|
-
if (!
|
|
77332
|
+
if (!isRecord3(message.result) || !Array.isArray(message.result.tools)) {
|
|
73795
77333
|
return message;
|
|
73796
77334
|
}
|
|
73797
77335
|
const tools = message.result.tools.map((tool) => {
|
|
@@ -73808,16 +77346,16 @@ function transformToolsListResponse(body) {
|
|
|
73808
77346
|
function transformJsonRpcMessages(value, transform2) {
|
|
73809
77347
|
if (Array.isArray(value)) {
|
|
73810
77348
|
return value.map(
|
|
73811
|
-
(message) =>
|
|
77349
|
+
(message) => isRecord3(message) ? transform2(message) : message
|
|
73812
77350
|
);
|
|
73813
77351
|
}
|
|
73814
|
-
return
|
|
77352
|
+
return isRecord3(value) ? transform2(value) : value;
|
|
73815
77353
|
}
|
|
73816
77354
|
function isToolsListRequest(value) {
|
|
73817
|
-
return
|
|
77355
|
+
return isRecord3(value) && value.method === "tools/list";
|
|
73818
77356
|
}
|
|
73819
77357
|
function isDryRunToolCall(value) {
|
|
73820
|
-
if (!
|
|
77358
|
+
if (!isRecord3(value) || value.method !== "tools/call" || !isRecord3(value.params)) {
|
|
73821
77359
|
return false;
|
|
73822
77360
|
}
|
|
73823
77361
|
return value.params.name === DRY_RUN_TOOL_NAME;
|
|
@@ -73890,7 +77428,7 @@ function writeResponse(response, status, headers, body) {
|
|
|
73890
77428
|
}
|
|
73891
77429
|
response.end(body);
|
|
73892
77430
|
}
|
|
73893
|
-
function
|
|
77431
|
+
function isRecord3(value) {
|
|
73894
77432
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
73895
77433
|
}
|
|
73896
77434
|
|
|
@@ -77576,12 +81114,12 @@ function canonicalizeMcpResultValue(value) {
|
|
|
77576
81114
|
if (typeof value !== "object" || value === null) {
|
|
77577
81115
|
return { value, deduplicatedBranches: 0 };
|
|
77578
81116
|
}
|
|
77579
|
-
const
|
|
77580
|
-
const duplicateContentIndexes = equivalentMcpTextContentIndexes(
|
|
81117
|
+
const record3 = value;
|
|
81118
|
+
const duplicateContentIndexes = equivalentMcpTextContentIndexes(record3);
|
|
77581
81119
|
let deduplicatedBranches = duplicateContentIndexes.size;
|
|
77582
81120
|
let changed = duplicateContentIndexes.size > 0;
|
|
77583
81121
|
const canonical = /* @__PURE__ */ Object.create(null);
|
|
77584
|
-
for (const [key, item] of Object.entries(
|
|
81122
|
+
for (const [key, item] of Object.entries(record3)) {
|
|
77585
81123
|
if (key === "content" && Array.isArray(item)) {
|
|
77586
81124
|
const retainedContent = duplicateContentIndexes.size > 0 ? item.filter(
|
|
77587
81125
|
(_contentItem, index) => !duplicateContentIndexes.has(index)
|
|
@@ -77625,9 +81163,9 @@ function isPlainMcpTextBlock(value) {
|
|
|
77625
81163
|
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
77626
81164
|
return false;
|
|
77627
81165
|
}
|
|
77628
|
-
const
|
|
77629
|
-
const keys = Object.keys(
|
|
77630
|
-
return keys.length === 2 &&
|
|
81166
|
+
const record3 = value;
|
|
81167
|
+
const keys = Object.keys(record3);
|
|
81168
|
+
return keys.length === 2 && record3.type === "text" && typeof record3.text === "string";
|
|
77631
81169
|
}
|
|
77632
81170
|
function parseJson(value) {
|
|
77633
81171
|
try {
|
|
@@ -79948,15 +83486,15 @@ function fileClaudeSessionResumeStore(path2 = CLAUDE_SESSION_RESUME_PATH) {
|
|
|
79948
83486
|
if (!existsSync2(path2)) {
|
|
79949
83487
|
return null;
|
|
79950
83488
|
}
|
|
79951
|
-
const
|
|
79952
|
-
if (!
|
|
83489
|
+
const record3 = parseResumeRecord(readFileSync4(path2, "utf8"));
|
|
83490
|
+
if (!record3 || record3.sessionId !== sessionId) {
|
|
79953
83491
|
return null;
|
|
79954
83492
|
}
|
|
79955
|
-
return
|
|
83493
|
+
return record3.agentId;
|
|
79956
83494
|
},
|
|
79957
|
-
write(
|
|
83495
|
+
write(record3) {
|
|
79958
83496
|
mkdirSync2(dirname5(path2), { recursive: true });
|
|
79959
|
-
writeFileSync(path2, `${JSON.stringify(
|
|
83497
|
+
writeFileSync(path2, `${JSON.stringify(record3)}
|
|
79960
83498
|
`, "utf8");
|
|
79961
83499
|
}
|
|
79962
83500
|
};
|
|
@@ -80084,15 +83622,15 @@ function fileClaudeReadStateStore(path2 = CLAUDE_READ_STATE_PATH) {
|
|
|
80084
83622
|
if (!existsSync3(path2)) {
|
|
80085
83623
|
return null;
|
|
80086
83624
|
}
|
|
80087
|
-
const
|
|
80088
|
-
if (!
|
|
83625
|
+
const record3 = parseReadStateRecord(readFileSync5(path2, "utf8"));
|
|
83626
|
+
if (!record3 || record3.sessionId !== sessionId) {
|
|
80089
83627
|
return null;
|
|
80090
83628
|
}
|
|
80091
|
-
return
|
|
83629
|
+
return record3.entries;
|
|
80092
83630
|
},
|
|
80093
|
-
write(
|
|
83631
|
+
write(record3) {
|
|
80094
83632
|
mkdirSync3(dirname6(path2), { recursive: true });
|
|
80095
|
-
writeFileSync2(path2, `${JSON.stringify(
|
|
83633
|
+
writeFileSync2(path2, `${JSON.stringify(record3)}
|
|
80096
83634
|
`, "utf8");
|
|
80097
83635
|
}
|
|
80098
83636
|
};
|
|
@@ -82414,15 +85952,15 @@ function fileCodexThreadResumeStore(path2 = CODEX_THREAD_RESUME_PATH) {
|
|
|
82414
85952
|
if (!existsSync4(path2)) {
|
|
82415
85953
|
return null;
|
|
82416
85954
|
}
|
|
82417
|
-
const
|
|
82418
|
-
if (!
|
|
85955
|
+
const record3 = parseResumeRecord2(readFileSync6(path2, "utf8"));
|
|
85956
|
+
if (!record3 || record3.sessionId !== sessionId) {
|
|
82419
85957
|
return null;
|
|
82420
85958
|
}
|
|
82421
|
-
return
|
|
85959
|
+
return record3.threadId;
|
|
82422
85960
|
},
|
|
82423
|
-
write(
|
|
85961
|
+
write(record3) {
|
|
82424
85962
|
mkdirSync4(dirname7(path2), { recursive: true });
|
|
82425
|
-
writeFileSync3(path2, `${JSON.stringify(
|
|
85963
|
+
writeFileSync3(path2, `${JSON.stringify(record3)}
|
|
82426
85964
|
`, "utf8");
|
|
82427
85965
|
}
|
|
82428
85966
|
};
|
|
@@ -83946,11 +87484,11 @@ function idFromResult(result, field) {
|
|
|
83946
87484
|
if (result === null || typeof result !== "object") {
|
|
83947
87485
|
return null;
|
|
83948
87486
|
}
|
|
83949
|
-
const
|
|
83950
|
-
if (
|
|
87487
|
+
const record3 = Reflect.get(result, field);
|
|
87488
|
+
if (record3 === null || typeof record3 !== "object") {
|
|
83951
87489
|
return null;
|
|
83952
87490
|
}
|
|
83953
|
-
const id = Reflect.get(
|
|
87491
|
+
const id = Reflect.get(record3, "id");
|
|
83954
87492
|
return typeof id === "string" && id.length > 0 ? id : null;
|
|
83955
87493
|
}
|
|
83956
87494
|
function errorMessage8(error51) {
|