@alook/daemon 0.1.61 → 0.1.63
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/README.md +42 -0
- package/dist/cli/index.js +880 -578
- package/dist/index.js +358 -290
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -11730,7 +11730,7 @@ var require_JSXTransformer = __commonJS((exports) => {
|
|
|
11730
11730
|
}
|
|
11731
11731
|
exports.startsWithLowerCase = startsWithLowerCase;
|
|
11732
11732
|
function formatJSXTextLiteral(text2) {
|
|
11733
|
-
let
|
|
11733
|
+
let result2 = "";
|
|
11734
11734
|
let whitespace = "";
|
|
11735
11735
|
let isInInitialLineWhitespace = false;
|
|
11736
11736
|
let seenNonWhitespace = false;
|
|
@@ -11746,25 +11746,25 @@ var require_JSXTransformer = __commonJS((exports) => {
|
|
|
11746
11746
|
isInInitialLineWhitespace = true;
|
|
11747
11747
|
} else {
|
|
11748
11748
|
if (seenNonWhitespace && isInInitialLineWhitespace) {
|
|
11749
|
-
|
|
11749
|
+
result2 += " ";
|
|
11750
11750
|
}
|
|
11751
|
-
|
|
11751
|
+
result2 += whitespace;
|
|
11752
11752
|
whitespace = "";
|
|
11753
11753
|
if (c === "&") {
|
|
11754
11754
|
const { entity, newI } = processEntity(text2, i + 1);
|
|
11755
11755
|
i = newI - 1;
|
|
11756
|
-
|
|
11756
|
+
result2 += entity;
|
|
11757
11757
|
} else {
|
|
11758
|
-
|
|
11758
|
+
result2 += c;
|
|
11759
11759
|
}
|
|
11760
11760
|
seenNonWhitespace = true;
|
|
11761
11761
|
isInInitialLineWhitespace = false;
|
|
11762
11762
|
}
|
|
11763
11763
|
}
|
|
11764
11764
|
if (!isInInitialLineWhitespace) {
|
|
11765
|
-
|
|
11765
|
+
result2 += whitespace;
|
|
11766
11766
|
}
|
|
11767
|
-
return JSON.stringify(
|
|
11767
|
+
return JSON.stringify(result2);
|
|
11768
11768
|
}
|
|
11769
11769
|
function formatJSXTextReplacement(text2) {
|
|
11770
11770
|
let numNewlines = 0;
|
|
@@ -11782,29 +11782,29 @@ var require_JSXTransformer = __commonJS((exports) => {
|
|
|
11782
11782
|
`.repeat(numNewlines) + " ".repeat(numSpaces);
|
|
11783
11783
|
}
|
|
11784
11784
|
function formatJSXStringValueLiteral(text2) {
|
|
11785
|
-
let
|
|
11785
|
+
let result2 = "";
|
|
11786
11786
|
for (let i = 0;i < text2.length; i++) {
|
|
11787
11787
|
const c = text2[i];
|
|
11788
11788
|
if (c === `
|
|
11789
11789
|
`) {
|
|
11790
11790
|
if (/\s/.test(text2[i + 1])) {
|
|
11791
|
-
|
|
11791
|
+
result2 += " ";
|
|
11792
11792
|
while (i < text2.length && /\s/.test(text2[i + 1])) {
|
|
11793
11793
|
i++;
|
|
11794
11794
|
}
|
|
11795
11795
|
} else {
|
|
11796
|
-
|
|
11796
|
+
result2 += `
|
|
11797
11797
|
`;
|
|
11798
11798
|
}
|
|
11799
11799
|
} else if (c === "&") {
|
|
11800
11800
|
const { entity, newI } = processEntity(text2, i + 1);
|
|
11801
|
-
|
|
11801
|
+
result2 += entity;
|
|
11802
11802
|
i = newI - 1;
|
|
11803
11803
|
} else {
|
|
11804
|
-
|
|
11804
|
+
result2 += c;
|
|
11805
11805
|
}
|
|
11806
11806
|
}
|
|
11807
|
-
return JSON.stringify(
|
|
11807
|
+
return JSON.stringify(result2);
|
|
11808
11808
|
}
|
|
11809
11809
|
function processEntity(text2, indexAfterAmpersand) {
|
|
11810
11810
|
let str = "";
|
|
@@ -12050,9 +12050,9 @@ var require_CJSImportProcessor = __commonJS((exports) => {
|
|
|
12050
12050
|
index2++;
|
|
12051
12051
|
}
|
|
12052
12052
|
if (this.tokens.matches1AtIndex(index2, _types.TokenType.braceL)) {
|
|
12053
|
-
const
|
|
12054
|
-
index2 =
|
|
12055
|
-
for (const namedImport of
|
|
12053
|
+
const result2 = this.getNamedImports(index2 + 1);
|
|
12054
|
+
index2 = result2.newIndex;
|
|
12055
|
+
for (const namedImport of result2.namedImports) {
|
|
12056
12056
|
if (namedImport.importedName === "default") {
|
|
12057
12057
|
defaultNames.push(namedImport.localName);
|
|
12058
12058
|
} else {
|
|
@@ -12206,9 +12206,9 @@ var require_CJSImportProcessor = __commonJS((exports) => {
|
|
|
12206
12206
|
this.exportBindingsByLocalName.get(localName).push(exportedName);
|
|
12207
12207
|
}
|
|
12208
12208
|
claimImportCode(importPath) {
|
|
12209
|
-
const
|
|
12209
|
+
const result2 = this.importsToReplace.get(importPath);
|
|
12210
12210
|
this.importsToReplace.set(importPath, "");
|
|
12211
|
-
return
|
|
12211
|
+
return result2 || "";
|
|
12212
12212
|
}
|
|
12213
12213
|
getIdentifierReplacement(identifierName) {
|
|
12214
12214
|
return this.identifierReplacements.get(identifierName) || null;
|
|
@@ -13407,12 +13407,12 @@ var require_trace_mapping_umd = __commonJS((exports, module) => {
|
|
|
13407
13407
|
if (!found)
|
|
13408
13408
|
min = lowerBound(segments, matchedColumn, min);
|
|
13409
13409
|
const max = upperBound(segments, matchedColumn, min);
|
|
13410
|
-
const
|
|
13410
|
+
const result2 = [];
|
|
13411
13411
|
for (;min <= max; min++) {
|
|
13412
13412
|
const segment = segments[min];
|
|
13413
|
-
|
|
13413
|
+
result2.push(GMapping(segment[REV_GENERATED_LINE] + 1, segment[REV_GENERATED_COLUMN]));
|
|
13414
13414
|
}
|
|
13415
|
-
return
|
|
13415
|
+
return result2;
|
|
13416
13416
|
}
|
|
13417
13417
|
function generatedPosition(map2, source, line, column, bias, all) {
|
|
13418
13418
|
var _a3, _b;
|
|
@@ -14657,10 +14657,10 @@ var require_types2 = __commonJS((exports) => {
|
|
|
14657
14657
|
exports.func = func;
|
|
14658
14658
|
var TFunc = function(_super) {
|
|
14659
14659
|
__extends(TFunc2, _super);
|
|
14660
|
-
function TFunc2(paramList,
|
|
14660
|
+
function TFunc2(paramList, result2) {
|
|
14661
14661
|
var _this = _super.call(this) || this;
|
|
14662
14662
|
_this.paramList = paramList;
|
|
14663
|
-
_this.result =
|
|
14663
|
+
_this.result = result2;
|
|
14664
14664
|
return _this;
|
|
14665
14665
|
}
|
|
14666
14666
|
TFunc2.prototype.getChecker = function(suite, strict) {
|
|
@@ -19396,11 +19396,11 @@ var require_parser = __commonJS((exports) => {
|
|
|
19396
19396
|
throw new Error("Cannot combine flow and typescript plugins.");
|
|
19397
19397
|
}
|
|
19398
19398
|
_base.initParser.call(undefined, input2, isJSXEnabled, isTypeScriptEnabled, isFlowEnabled);
|
|
19399
|
-
const
|
|
19399
|
+
const result2 = _index.parseFile.call(undefined);
|
|
19400
19400
|
if (_base.state.error) {
|
|
19401
19401
|
throw _base.augmentError.call(undefined, _base.state.error);
|
|
19402
19402
|
}
|
|
19403
|
-
return
|
|
19403
|
+
return result2;
|
|
19404
19404
|
}
|
|
19405
19405
|
exports.parse = parse5;
|
|
19406
19406
|
});
|
|
@@ -19474,9 +19474,9 @@ var require_TokenProcessor = __commonJS((exports) => {
|
|
|
19474
19474
|
this.tokenIndex = snapshot.tokenIndex;
|
|
19475
19475
|
}
|
|
19476
19476
|
dangerouslyGetAndRemoveCodeSinceSnapshot(snapshot) {
|
|
19477
|
-
const
|
|
19477
|
+
const result2 = this.resultCode.slice(snapshot.resultCode.length);
|
|
19478
19478
|
this.resultCode = snapshot.resultCode;
|
|
19479
|
-
return
|
|
19479
|
+
return result2;
|
|
19480
19480
|
}
|
|
19481
19481
|
reset() {
|
|
19482
19482
|
this.resultCode = "";
|
|
@@ -21821,8 +21821,8 @@ var require_RootTransformer = __commonJS((exports) => {
|
|
|
21821
21821
|
for (const transformer of this.transformers) {
|
|
21822
21822
|
suffix += transformer.getSuffixCode();
|
|
21823
21823
|
}
|
|
21824
|
-
const
|
|
21825
|
-
let { code } =
|
|
21824
|
+
const result2 = this.tokens.finish();
|
|
21825
|
+
let { code } = result2;
|
|
21826
21826
|
if (code.startsWith("#!")) {
|
|
21827
21827
|
let newlineIndex = code.indexOf(`
|
|
21828
21828
|
`);
|
|
@@ -21833,12 +21833,12 @@ var require_RootTransformer = __commonJS((exports) => {
|
|
|
21833
21833
|
}
|
|
21834
21834
|
return {
|
|
21835
21835
|
code: code.slice(0, newlineIndex + 1) + prefix + code.slice(newlineIndex + 1) + suffix,
|
|
21836
|
-
mappings: this.shiftMappings(
|
|
21836
|
+
mappings: this.shiftMappings(result2.mappings, prefix.length)
|
|
21837
21837
|
};
|
|
21838
21838
|
} else {
|
|
21839
21839
|
return {
|
|
21840
21840
|
code: prefix + code + suffix,
|
|
21841
|
-
mappings: this.shiftMappings(
|
|
21841
|
+
mappings: this.shiftMappings(result2.mappings, prefix.length)
|
|
21842
21842
|
};
|
|
21843
21843
|
}
|
|
21844
21844
|
}
|
|
@@ -22281,17 +22281,17 @@ var require_dist2 = __commonJS((exports) => {
|
|
|
22281
22281
|
const sucraseContext = getSucraseContext(code, options);
|
|
22282
22282
|
const transformer = new (0, _RootTransformer2.default)(sucraseContext, options.transforms, Boolean(options.enableLegacyBabel5ModuleInterop), options);
|
|
22283
22283
|
const transformerResult = transformer.transform();
|
|
22284
|
-
let
|
|
22284
|
+
let result2 = { code: transformerResult.code };
|
|
22285
22285
|
if (options.sourceMapOptions) {
|
|
22286
22286
|
if (!options.filePath) {
|
|
22287
22287
|
throw new Error("filePath must be specified when generating a source map.");
|
|
22288
22288
|
}
|
|
22289
|
-
|
|
22290
|
-
...
|
|
22289
|
+
result2 = {
|
|
22290
|
+
...result2,
|
|
22291
22291
|
sourceMap: _computeSourceMap2.default.call(undefined, transformerResult, options.filePath, options.sourceMapOptions, code, sucraseContext.tokenProcessor.tokens)
|
|
22292
22292
|
};
|
|
22293
22293
|
}
|
|
22294
|
-
return
|
|
22294
|
+
return result2;
|
|
22295
22295
|
} catch (e) {
|
|
22296
22296
|
if (options.filePath) {
|
|
22297
22297
|
e.message = `Error transforming ${options.filePath}: ${e.message}`;
|
|
@@ -41754,6 +41754,125 @@ function bigint3(params) {
|
|
|
41754
41754
|
function date4(params) {
|
|
41755
41755
|
return _coercedDate(ZodDate, params);
|
|
41756
41756
|
}
|
|
41757
|
+
// ../shared/src/constants/community.ts
|
|
41758
|
+
var MAX_SERVER_NAME_LENGTH = 100;
|
|
41759
|
+
var MAX_SERVER_DESCRIPTION_LENGTH = 2000;
|
|
41760
|
+
var MAX_FOLDER_NAME_LENGTH = 100;
|
|
41761
|
+
var MAX_PROFILE_NAME_LENGTH = 100;
|
|
41762
|
+
var MAX_PROFILE_ABOUT_LENGTH = 1000;
|
|
41763
|
+
var MAX_MESSAGE_CONTENT_LENGTH = 4000;
|
|
41764
|
+
var MAX_ATTACHMENTS_PER_MESSAGE = 10;
|
|
41765
|
+
var MAX_ATTACHMENT_SIZE_BYTES = 25 * 1024 * 1024;
|
|
41766
|
+
var MAX_ATTACHMENT_THUMBNAIL_EDGE_PX = 720;
|
|
41767
|
+
var MAX_ATTACHMENT_THUMBNAIL_SIZE_BYTES = 256 * 1024;
|
|
41768
|
+
var MAX_SERVER_ICON_SIZE_BYTES = 5 * 1024 * 1024;
|
|
41769
|
+
var ALLOWED_ICON_MIME_TYPES = [
|
|
41770
|
+
"image/png",
|
|
41771
|
+
"image/jpeg",
|
|
41772
|
+
"image/webp",
|
|
41773
|
+
"image/gif"
|
|
41774
|
+
];
|
|
41775
|
+
var MAX_ICON_SOURCE_FILE_SIZE_BYTES = 15 * 1024 * 1024;
|
|
41776
|
+
var PARTICIPANT_SOURCE = {
|
|
41777
|
+
MENTION: "mention",
|
|
41778
|
+
SPOKE: "spoke",
|
|
41779
|
+
ADDED: "added"
|
|
41780
|
+
};
|
|
41781
|
+
|
|
41782
|
+
// ../shared/src/lib/discriminator.ts
|
|
41783
|
+
function parseNameAndTag(q) {
|
|
41784
|
+
const m = /^(.+)#(\d{4,})$/.exec(q);
|
|
41785
|
+
if (!m)
|
|
41786
|
+
return null;
|
|
41787
|
+
const name = m[1].trim();
|
|
41788
|
+
const discriminator = m[2];
|
|
41789
|
+
if (!name)
|
|
41790
|
+
return null;
|
|
41791
|
+
return { name, discriminator };
|
|
41792
|
+
}
|
|
41793
|
+
function formatHandle(name, discriminator) {
|
|
41794
|
+
return `${name}#${discriminator}`;
|
|
41795
|
+
}
|
|
41796
|
+
|
|
41797
|
+
// ../shared/src/pii-contract.ts
|
|
41798
|
+
var PII_CAPABILITY = "pii-v1";
|
|
41799
|
+
var PII_MAX_PLUGINS = 32;
|
|
41800
|
+
var PII_SOURCE_MAX_BYTES = 16 * 1024;
|
|
41801
|
+
var PII_TEXT_MAX_BYTES = 1024;
|
|
41802
|
+
var PII_REQUEST_MAX_BYTES = 8 * 1024;
|
|
41803
|
+
var PiiPreviewTextSchema = exports_external.string().max(PII_TEXT_MAX_BYTES).refine((text) => new TextEncoder().encode(text).byteLength <= PII_TEXT_MAX_BYTES).refine((text) => text.trim().length > 0);
|
|
41804
|
+
var PiiPluginSchema = exports_external.strictObject({
|
|
41805
|
+
id: exports_external.string().min(1).max(128),
|
|
41806
|
+
name: exports_external.string().trim().min(1).max(80),
|
|
41807
|
+
description: exports_external.string().trim().min(1).max(256),
|
|
41808
|
+
enabled: exports_external.boolean()
|
|
41809
|
+
});
|
|
41810
|
+
var PiiSnapshotSchema = exports_external.strictObject({
|
|
41811
|
+
revision: exports_external.number().int().nonnegative(),
|
|
41812
|
+
plugins: exports_external.array(PiiPluginSchema).max(PII_MAX_PLUGINS)
|
|
41813
|
+
});
|
|
41814
|
+
var pluginId = exports_external.string().min(1).max(128);
|
|
41815
|
+
var expectedRevision = exports_external.number().int().nonnegative();
|
|
41816
|
+
var PiiOperationSchema = exports_external.discriminatedUnion("action", [
|
|
41817
|
+
exports_external.strictObject({ action: exports_external.literal("list") }),
|
|
41818
|
+
exports_external.strictObject({ action: exports_external.literal("setEnabled"), pluginId, enabled: exports_external.boolean(), expectedRevision }),
|
|
41819
|
+
exports_external.strictObject({ action: exports_external.literal("remove"), pluginId, expectedRevision }),
|
|
41820
|
+
exports_external.strictObject({ action: exports_external.literal("preview"), text: PiiPreviewTextSchema, expectedRevision })
|
|
41821
|
+
]);
|
|
41822
|
+
var PiiRequestSchema = exports_external.strictObject({
|
|
41823
|
+
requestId: exports_external.string().min(1).max(128),
|
|
41824
|
+
operation: PiiOperationSchema
|
|
41825
|
+
});
|
|
41826
|
+
var PiiCommandSchema = PiiRequestSchema.extend({
|
|
41827
|
+
type: exports_external.literal("pii:manage"),
|
|
41828
|
+
botId: exports_external.string().min(1).max(128)
|
|
41829
|
+
});
|
|
41830
|
+
var PiiErrorCodeSchema = exports_external.enum([
|
|
41831
|
+
"PII_CONFLICT",
|
|
41832
|
+
"PII_UNAVAILABLE",
|
|
41833
|
+
"PII_PLUGIN_NOT_FOUND",
|
|
41834
|
+
"PII_BOT_NOT_FOUND",
|
|
41835
|
+
"PII_PLUGIN_FAILED",
|
|
41836
|
+
"PII_PLUGIN_TIMEOUT",
|
|
41837
|
+
"PII_INVALID_RESULT",
|
|
41838
|
+
"PII_OUTPUT_TOO_LARGE",
|
|
41839
|
+
"PII_INVALID_SOURCE",
|
|
41840
|
+
"PII_CONFIG_UNAVAILABLE",
|
|
41841
|
+
"PII_SOURCE_TOO_LARGE",
|
|
41842
|
+
"PII_INVALID_REQUEST"
|
|
41843
|
+
]);
|
|
41844
|
+
var PiiResultSchema = exports_external.discriminatedUnion("status", [
|
|
41845
|
+
exports_external.strictObject({ status: exports_external.literal("complete"), snapshot: PiiSnapshotSchema, output: PiiPreviewTextSchema.optional(), triggeredFilters: exports_external.array(PiiPluginSchema.pick({ id: true, name: true })).max(PII_MAX_PLUGINS).optional() }),
|
|
41846
|
+
exports_external.strictObject({
|
|
41847
|
+
status: exports_external.literal("error"),
|
|
41848
|
+
code: PiiErrorCodeSchema,
|
|
41849
|
+
pluginId: pluginId.optional(),
|
|
41850
|
+
snapshot: PiiSnapshotSchema.optional()
|
|
41851
|
+
})
|
|
41852
|
+
]);
|
|
41853
|
+
var PiiResultFrameSchema = exports_external.strictObject({
|
|
41854
|
+
type: exports_external.literal("pii_result"),
|
|
41855
|
+
botId: exports_external.string().min(1).max(128),
|
|
41856
|
+
requestId: exports_external.string().min(1).max(128),
|
|
41857
|
+
result: PiiResultSchema
|
|
41858
|
+
});
|
|
41859
|
+
var PiiLocalRequestSchema = exports_external.discriminatedUnion("action", [
|
|
41860
|
+
exports_external.strictObject({ action: exports_external.literal("list") }),
|
|
41861
|
+
exports_external.strictObject({
|
|
41862
|
+
action: exports_external.literal("add"),
|
|
41863
|
+
name: PiiPluginSchema.shape.name,
|
|
41864
|
+
description: PiiPluginSchema.shape.description,
|
|
41865
|
+
source: exports_external.string().min(1).max(PII_SOURCE_MAX_BYTES)
|
|
41866
|
+
})
|
|
41867
|
+
]);
|
|
41868
|
+
|
|
41869
|
+
// ../shared/src/utils/community-roles.ts
|
|
41870
|
+
var ROLES = {
|
|
41871
|
+
OWNER: "owner",
|
|
41872
|
+
ADMIN: "admin",
|
|
41873
|
+
MEMBER: "member"
|
|
41874
|
+
};
|
|
41875
|
+
|
|
41757
41876
|
// ../shared/src/db/community-machine-schema.ts
|
|
41758
41877
|
var exports_community_machine_schema = {};
|
|
41759
41878
|
__export(exports_community_machine_schema, {
|
|
@@ -44240,63 +44359,6 @@ var OwnerDiagnosticReportSchema = exports_external.discriminatedUnion("status",
|
|
|
44240
44359
|
objectExpired: exports_external.literal(false)
|
|
44241
44360
|
}).strict()
|
|
44242
44361
|
]);
|
|
44243
|
-
// ../shared/src/community-profile-resource.ts
|
|
44244
|
-
var CommunityResourceProfileSchema = exports_external.strictObject({
|
|
44245
|
-
id: exports_external.string().min(1),
|
|
44246
|
-
name: exports_external.string(),
|
|
44247
|
-
discriminator: exports_external.string().min(1),
|
|
44248
|
-
avatar: exports_external.string().nullable(),
|
|
44249
|
-
avatarVersion: exports_external.number().int().nonnegative(),
|
|
44250
|
-
aboutMe: exports_external.string().optional(),
|
|
44251
|
-
bannerColor: exports_external.string().nullable().optional(),
|
|
44252
|
-
kind: exports_external.enum(["human", "bot"]).optional(),
|
|
44253
|
-
ownerUserId: exports_external.string().min(1).nullable().optional(),
|
|
44254
|
-
ownerHandle: exports_external.string().nullable().optional(),
|
|
44255
|
-
mutualServers: exports_external.number().int().nonnegative().optional(),
|
|
44256
|
-
ownedByViewer: exports_external.boolean().optional(),
|
|
44257
|
-
statusEmoji: exports_external.string().nullable().optional(),
|
|
44258
|
-
statusText: exports_external.string().nullable().optional()
|
|
44259
|
-
});
|
|
44260
|
-
// ../shared/src/business-schema-version.ts
|
|
44261
|
-
var BUSINESS_SCHEMA_VERSION = 7;
|
|
44262
|
-
|
|
44263
|
-
// ../shared/src/community-contract.ts
|
|
44264
|
-
var COMMUNITY_RESOURCE_CONTRACT_VERSION = BUSINESS_SCHEMA_VERSION;
|
|
44265
|
-
|
|
44266
|
-
// ../shared/src/community-friend-approval.ts
|
|
44267
|
-
var identity = CommunityResourceProfileSchema.pick({ id: true, name: true, discriminator: true, avatarVersion: true });
|
|
44268
|
-
var profile = identity.extend({ image: CommunityResourceProfileSchema.shape.avatar });
|
|
44269
|
-
var FriendApprovalPayloadSchema = exports_external.strictObject({
|
|
44270
|
-
friendshipId: exports_external.string(),
|
|
44271
|
-
status: exports_external.enum(["pending", "approved", "denied", "superseded", "cancelled"]),
|
|
44272
|
-
waitingOn: exports_external.enum(["you", "other-owner", "addressee"]).nullable(),
|
|
44273
|
-
otherProfile: profile,
|
|
44274
|
-
botProfile: profile,
|
|
44275
|
-
waitingOnProfile: profile.nullable().optional()
|
|
44276
|
-
});
|
|
44277
|
-
|
|
44278
|
-
// ../shared/src/constants/community.ts
|
|
44279
|
-
var MAX_FOLDER_NAME_LENGTH = 100;
|
|
44280
|
-
var MAX_PROFILE_NAME_LENGTH = 100;
|
|
44281
|
-
var MAX_PROFILE_ABOUT_LENGTH = 1000;
|
|
44282
|
-
var MAX_MESSAGE_CONTENT_LENGTH = 4000;
|
|
44283
|
-
var MAX_ATTACHMENTS_PER_MESSAGE = 10;
|
|
44284
|
-
var MAX_ATTACHMENT_SIZE_BYTES = 25 * 1024 * 1024;
|
|
44285
|
-
var MAX_ATTACHMENT_THUMBNAIL_EDGE_PX = 720;
|
|
44286
|
-
var MAX_ATTACHMENT_THUMBNAIL_SIZE_BYTES = 256 * 1024;
|
|
44287
|
-
var MAX_SERVER_ICON_SIZE_BYTES = 5 * 1024 * 1024;
|
|
44288
|
-
var ALLOWED_ICON_MIME_TYPES = [
|
|
44289
|
-
"image/png",
|
|
44290
|
-
"image/jpeg",
|
|
44291
|
-
"image/webp",
|
|
44292
|
-
"image/gif"
|
|
44293
|
-
];
|
|
44294
|
-
var MAX_ICON_SOURCE_FILE_SIZE_BYTES = 15 * 1024 * 1024;
|
|
44295
|
-
var PARTICIPANT_SOURCE = {
|
|
44296
|
-
MENTION: "mention",
|
|
44297
|
-
SPOKE: "spoke",
|
|
44298
|
-
ADDED: "added"
|
|
44299
|
-
};
|
|
44300
44362
|
|
|
44301
44363
|
// ../shared/src/runtime-models-contract.ts
|
|
44302
44364
|
var RUNTIME_MODEL_DISCOVERY_CAPABILITY = "runtime-model-discovery-v1";
|
|
@@ -44313,107 +44375,6 @@ var RuntimeModelDiscoveryErrorSchema = exports_external.strictObject({
|
|
|
44313
44375
|
message: exports_external.string().min(1).max(256)
|
|
44314
44376
|
});
|
|
44315
44377
|
|
|
44316
|
-
// ../shared/src/utils/slug.ts
|
|
44317
|
-
init_nanoid();
|
|
44318
|
-
var slugId = customAlphabet("0123456789abcdefghijklmnopqrstuvwxyz");
|
|
44319
|
-
function sanitizeSlug(input2) {
|
|
44320
|
-
return input2.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60).replace(/-+$/g, "");
|
|
44321
|
-
}
|
|
44322
|
-
|
|
44323
|
-
// ../shared/src/pii-contract.ts
|
|
44324
|
-
var PII_CAPABILITY = "pii-v1";
|
|
44325
|
-
var PII_MAX_PLUGINS = 32;
|
|
44326
|
-
var PII_SOURCE_MAX_BYTES = 16 * 1024;
|
|
44327
|
-
var PII_TEXT_MAX_BYTES = 1024;
|
|
44328
|
-
var PII_REQUEST_MAX_BYTES = 8 * 1024;
|
|
44329
|
-
var PiiPreviewTextSchema = exports_external.string().max(PII_TEXT_MAX_BYTES).refine((text2) => new TextEncoder().encode(text2).byteLength <= PII_TEXT_MAX_BYTES).refine((text2) => text2.trim().length > 0);
|
|
44330
|
-
var PiiPluginSchema = exports_external.strictObject({
|
|
44331
|
-
id: exports_external.string().min(1).max(128),
|
|
44332
|
-
name: exports_external.string().trim().min(1).max(80),
|
|
44333
|
-
description: exports_external.string().trim().min(1).max(256),
|
|
44334
|
-
enabled: exports_external.boolean()
|
|
44335
|
-
});
|
|
44336
|
-
var PiiSnapshotSchema = exports_external.strictObject({
|
|
44337
|
-
revision: exports_external.number().int().nonnegative(),
|
|
44338
|
-
plugins: exports_external.array(PiiPluginSchema).max(PII_MAX_PLUGINS)
|
|
44339
|
-
});
|
|
44340
|
-
var pluginId = exports_external.string().min(1).max(128);
|
|
44341
|
-
var expectedRevision = exports_external.number().int().nonnegative();
|
|
44342
|
-
var PiiOperationSchema = exports_external.discriminatedUnion("action", [
|
|
44343
|
-
exports_external.strictObject({ action: exports_external.literal("list") }),
|
|
44344
|
-
exports_external.strictObject({ action: exports_external.literal("setEnabled"), pluginId, enabled: exports_external.boolean(), expectedRevision }),
|
|
44345
|
-
exports_external.strictObject({ action: exports_external.literal("remove"), pluginId, expectedRevision }),
|
|
44346
|
-
exports_external.strictObject({ action: exports_external.literal("preview"), text: PiiPreviewTextSchema, expectedRevision })
|
|
44347
|
-
]);
|
|
44348
|
-
var PiiRequestSchema = exports_external.strictObject({
|
|
44349
|
-
requestId: exports_external.string().min(1).max(128),
|
|
44350
|
-
operation: PiiOperationSchema
|
|
44351
|
-
});
|
|
44352
|
-
var PiiCommandSchema = PiiRequestSchema.extend({
|
|
44353
|
-
type: exports_external.literal("pii:manage"),
|
|
44354
|
-
botId: exports_external.string().min(1).max(128)
|
|
44355
|
-
});
|
|
44356
|
-
var PiiErrorCodeSchema = exports_external.enum([
|
|
44357
|
-
"PII_CONFLICT",
|
|
44358
|
-
"PII_UNAVAILABLE",
|
|
44359
|
-
"PII_PLUGIN_NOT_FOUND",
|
|
44360
|
-
"PII_BOT_NOT_FOUND",
|
|
44361
|
-
"PII_PLUGIN_FAILED",
|
|
44362
|
-
"PII_PLUGIN_TIMEOUT",
|
|
44363
|
-
"PII_INVALID_RESULT",
|
|
44364
|
-
"PII_OUTPUT_TOO_LARGE",
|
|
44365
|
-
"PII_INVALID_SOURCE",
|
|
44366
|
-
"PII_CONFIG_UNAVAILABLE",
|
|
44367
|
-
"PII_SOURCE_TOO_LARGE",
|
|
44368
|
-
"PII_INVALID_REQUEST"
|
|
44369
|
-
]);
|
|
44370
|
-
var PiiResultSchema = exports_external.discriminatedUnion("status", [
|
|
44371
|
-
exports_external.strictObject({ status: exports_external.literal("complete"), snapshot: PiiSnapshotSchema, output: PiiPreviewTextSchema.optional(), triggeredFilters: exports_external.array(PiiPluginSchema.pick({ id: true, name: true })).max(PII_MAX_PLUGINS).optional() }),
|
|
44372
|
-
exports_external.strictObject({
|
|
44373
|
-
status: exports_external.literal("error"),
|
|
44374
|
-
code: PiiErrorCodeSchema,
|
|
44375
|
-
pluginId: pluginId.optional(),
|
|
44376
|
-
snapshot: PiiSnapshotSchema.optional()
|
|
44377
|
-
})
|
|
44378
|
-
]);
|
|
44379
|
-
var PiiResultFrameSchema = exports_external.strictObject({
|
|
44380
|
-
type: exports_external.literal("pii_result"),
|
|
44381
|
-
botId: exports_external.string().min(1).max(128),
|
|
44382
|
-
requestId: exports_external.string().min(1).max(128),
|
|
44383
|
-
result: PiiResultSchema
|
|
44384
|
-
});
|
|
44385
|
-
var PiiLocalRequestSchema = exports_external.discriminatedUnion("action", [
|
|
44386
|
-
exports_external.strictObject({ action: exports_external.literal("list") }),
|
|
44387
|
-
exports_external.strictObject({
|
|
44388
|
-
action: exports_external.literal("add"),
|
|
44389
|
-
name: PiiPluginSchema.shape.name,
|
|
44390
|
-
description: PiiPluginSchema.shape.description,
|
|
44391
|
-
source: exports_external.string().min(1).max(PII_SOURCE_MAX_BYTES)
|
|
44392
|
-
})
|
|
44393
|
-
]);
|
|
44394
|
-
|
|
44395
|
-
// ../shared/src/utils/community-roles.ts
|
|
44396
|
-
var ROLES = {
|
|
44397
|
-
OWNER: "owner",
|
|
44398
|
-
ADMIN: "admin",
|
|
44399
|
-
MEMBER: "member"
|
|
44400
|
-
};
|
|
44401
|
-
|
|
44402
|
-
// ../shared/src/lib/discriminator.ts
|
|
44403
|
-
function parseNameAndTag(q) {
|
|
44404
|
-
const m = /^(.+)#(\d{4,})$/.exec(q);
|
|
44405
|
-
if (!m)
|
|
44406
|
-
return null;
|
|
44407
|
-
const name = m[1].trim();
|
|
44408
|
-
const discriminator = m[2];
|
|
44409
|
-
if (!name)
|
|
44410
|
-
return null;
|
|
44411
|
-
return { name, discriminator };
|
|
44412
|
-
}
|
|
44413
|
-
function formatHandle(name, discriminator) {
|
|
44414
|
-
return `${name}#${discriminator}`;
|
|
44415
|
-
}
|
|
44416
|
-
|
|
44417
44378
|
// ../shared/src/community-cli-contract.ts
|
|
44418
44379
|
var AGENT_EVENT_PROMPT_MAX_LENGTH = 32768;
|
|
44419
44380
|
var DM_SERVER = ".dm";
|
|
@@ -44589,6 +44550,91 @@ var HostCommandSchema = exports_external.discriminatedUnion("type", [
|
|
|
44589
44550
|
DiagnosticCollectCommandSchema
|
|
44590
44551
|
]);
|
|
44591
44552
|
|
|
44553
|
+
// ../shared/src/automation.ts
|
|
44554
|
+
var AUTOMATION_WRITE_PERMISSIONS = ["bot.create", "server.create", "server.invite", "message.send"];
|
|
44555
|
+
var AUTOMATION_READ_PERMISSIONS = ["machine.read", "friend.read", "server.read"];
|
|
44556
|
+
var AutomationPermissionSchema = exports_external.enum([...AUTOMATION_WRITE_PERMISSIONS, ...AUTOMATION_READ_PERMISSIONS]);
|
|
44557
|
+
var AutomationExpirySchema = exports_external.enum(["1h", "24h", "7d", "30d", "forever"]);
|
|
44558
|
+
var AutomationPermissionPolicySchema = exports_external.strictObject({
|
|
44559
|
+
permission: AutomationPermissionSchema,
|
|
44560
|
+
limit: exports_external.number().int().positive(),
|
|
44561
|
+
period: exports_external.enum(["hour", "day"])
|
|
44562
|
+
}).refine((value) => value.limit <= (value.period === "hour" ? 64 : 1536), {
|
|
44563
|
+
message: "Limit cannot exceed 64/hour or 1536/day",
|
|
44564
|
+
path: ["limit"]
|
|
44565
|
+
});
|
|
44566
|
+
var permissions = exports_external.array(AutomationPermissionPolicySchema).min(1).max(AutomationPermissionSchema.options.length).refine((values) => new Set(values.map((value) => value.permission)).size === values.length, "Duplicate permission");
|
|
44567
|
+
var AutomationAccessCodeCreateSchema = exports_external.strictObject({
|
|
44568
|
+
name: exports_external.string().trim().min(1).max(100),
|
|
44569
|
+
expiresIn: AutomationExpirySchema.default("24h"),
|
|
44570
|
+
permissions
|
|
44571
|
+
});
|
|
44572
|
+
var AutomationAccessCodeUpdateSchema = exports_external.strictObject({
|
|
44573
|
+
name: exports_external.string().trim().min(1).max(100).optional(),
|
|
44574
|
+
expiresIn: AutomationExpirySchema.optional(),
|
|
44575
|
+
permissions: permissions.optional()
|
|
44576
|
+
}).refine((value) => Object.keys(value).length > 0, "Provide at least one change");
|
|
44577
|
+
var AutomationMessageSendSchema = exports_external.strictObject({
|
|
44578
|
+
target: exports_external.string().min(1).max(1024).refine((value) => {
|
|
44579
|
+
try {
|
|
44580
|
+
parseRef(value);
|
|
44581
|
+
return true;
|
|
44582
|
+
} catch {
|
|
44583
|
+
return false;
|
|
44584
|
+
}
|
|
44585
|
+
}, "Use a channel or DM ref"),
|
|
44586
|
+
as: exports_external.string().max(128).refine((value) => value === "me" || value.startsWith("@") && Boolean(parseNameAndTag(value.slice(1))), "Use me or @name#NNNN"),
|
|
44587
|
+
content: exports_external.string().max(MAX_MESSAGE_CONTENT_LENGTH).refine((value) => value.trim().length > 0, "Message content is required"),
|
|
44588
|
+
nonce: exports_external.string().min(1).max(128)
|
|
44589
|
+
});
|
|
44590
|
+
var AutomationMessageSentSchema = exports_external.object({
|
|
44591
|
+
state: exports_external.literal("sent"),
|
|
44592
|
+
seq: exports_external.string().regex(/^#[1-9]\d*$/),
|
|
44593
|
+
deduped: exports_external.boolean(),
|
|
44594
|
+
threadId: exports_external.string().optional()
|
|
44595
|
+
});
|
|
44596
|
+
// ../shared/src/community-profile-resource.ts
|
|
44597
|
+
var CommunityResourceProfileSchema = exports_external.strictObject({
|
|
44598
|
+
id: exports_external.string().min(1),
|
|
44599
|
+
name: exports_external.string(),
|
|
44600
|
+
discriminator: exports_external.string().min(1),
|
|
44601
|
+
avatar: exports_external.string().nullable(),
|
|
44602
|
+
avatarVersion: exports_external.number().int().nonnegative(),
|
|
44603
|
+
aboutMe: exports_external.string().optional(),
|
|
44604
|
+
bannerColor: exports_external.string().nullable().optional(),
|
|
44605
|
+
kind: exports_external.enum(["human", "bot"]).optional(),
|
|
44606
|
+
ownerUserId: exports_external.string().min(1).nullable().optional(),
|
|
44607
|
+
ownerHandle: exports_external.string().nullable().optional(),
|
|
44608
|
+
mutualServers: exports_external.number().int().nonnegative().optional(),
|
|
44609
|
+
ownedByViewer: exports_external.boolean().optional(),
|
|
44610
|
+
statusEmoji: exports_external.string().nullable().optional(),
|
|
44611
|
+
statusText: exports_external.string().nullable().optional()
|
|
44612
|
+
});
|
|
44613
|
+
// ../shared/src/business-schema-version.ts
|
|
44614
|
+
var BUSINESS_SCHEMA_VERSION = 8;
|
|
44615
|
+
|
|
44616
|
+
// ../shared/src/community-contract.ts
|
|
44617
|
+
var COMMUNITY_RESOURCE_CONTRACT_VERSION = BUSINESS_SCHEMA_VERSION;
|
|
44618
|
+
|
|
44619
|
+
// ../shared/src/community-friend-approval.ts
|
|
44620
|
+
var identity = CommunityResourceProfileSchema.pick({ id: true, name: true, discriminator: true, avatarVersion: true });
|
|
44621
|
+
var profile = identity.extend({ image: CommunityResourceProfileSchema.shape.avatar });
|
|
44622
|
+
var FriendApprovalPayloadSchema = exports_external.strictObject({
|
|
44623
|
+
friendshipId: exports_external.string(),
|
|
44624
|
+
status: exports_external.enum(["pending", "approved", "denied", "superseded", "cancelled"]),
|
|
44625
|
+
waitingOn: exports_external.enum(["you", "other-owner", "addressee"]).nullable(),
|
|
44626
|
+
otherProfile: profile,
|
|
44627
|
+
botProfile: profile,
|
|
44628
|
+
waitingOnProfile: profile.nullable().optional()
|
|
44629
|
+
});
|
|
44630
|
+
|
|
44631
|
+
// ../shared/src/utils/slug.ts
|
|
44632
|
+
init_nanoid();
|
|
44633
|
+
var slugId = customAlphabet("0123456789abcdefghijklmnopqrstuvwxyz");
|
|
44634
|
+
function sanitizeSlug(input2) {
|
|
44635
|
+
return input2.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60).replace(/-+$/g, "");
|
|
44636
|
+
}
|
|
44637
|
+
|
|
44592
44638
|
// ../shared/src/provider-telemetry.ts
|
|
44593
44639
|
var DAILY_TOKEN_USAGE_WINDOW_DAYS = 30;
|
|
44594
44640
|
var safeToken = exports_external.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
|
|
@@ -44802,15 +44848,6 @@ var PollResponseSchema = exports_external.object({
|
|
|
44802
44848
|
file_requests: exports_external.array(FileRequestItemSchema).optional(),
|
|
44803
44849
|
meetings: exports_external.array(PollMeetingItemSchema).optional()
|
|
44804
44850
|
});
|
|
44805
|
-
var DaemonPushMessageSchema = exports_external.discriminatedUnion("type", [
|
|
44806
|
-
exports_external.object({ type: exports_external.literal("daemon.tasks"), tasks: exports_external.array(TaskApiSchema) }),
|
|
44807
|
-
exports_external.object({ type: exports_external.literal("daemon.file_requests"), workspaceId: exports_external.string(), requests: exports_external.array(FileRequestItemSchema) }),
|
|
44808
|
-
exports_external.object({ type: exports_external.literal("daemon.meetings"), meetings: exports_external.array(PollMeetingItemSchema) }),
|
|
44809
|
-
exports_external.object({ type: exports_external.literal("daemon.evict"), workspaceId: exports_external.string() }),
|
|
44810
|
-
exports_external.object({ type: exports_external.literal("daemon.update"), version: exports_external.string() }),
|
|
44811
|
-
exports_external.object({ type: exports_external.literal("daemon.rescan") }),
|
|
44812
|
-
exports_external.object({ type: exports_external.literal("daemon.kill"), workspaceId: exports_external.string(), agentId: exports_external.string().min(1), taskId: exports_external.string(), targetTaskId: exports_external.string() })
|
|
44813
|
-
]);
|
|
44814
44851
|
var RegisterResponseSchema = exports_external.object({
|
|
44815
44852
|
runtimes: exports_external.array(exports_external.object({ id: exports_external.string() }))
|
|
44816
44853
|
});
|
|
@@ -45006,10 +45043,6 @@ var CreateMessageRequestSchema = exports_external.object({
|
|
|
45006
45043
|
content: exports_external.string().min(1, "content is required"),
|
|
45007
45044
|
metadata: exports_external.record(exports_external.string(), exports_external.unknown()).optional()
|
|
45008
45045
|
});
|
|
45009
|
-
var AgentDmRequestSchema = exports_external.object({
|
|
45010
|
-
content: exports_external.string().min(1, "content is required"),
|
|
45011
|
-
task_id: exports_external.string().min(1).optional()
|
|
45012
|
-
});
|
|
45013
45046
|
var EmailAttachmentSchema = exports_external.object({
|
|
45014
45047
|
key: exports_external.string().min(1),
|
|
45015
45048
|
filename: exports_external.string().min(1),
|
|
@@ -46857,6 +46890,7 @@ var serverMembershipSchema = CommunityServerMembershipResourceSchema.extend({
|
|
|
46857
46890
|
viewer: exports_external.boolean()
|
|
46858
46891
|
});
|
|
46859
46892
|
var channelMembershipSchema = CommunityChannelMembershipResourceSchema.extend({ id: exports_external.string().min(1) });
|
|
46893
|
+
var profileSchema = CommunityResourceProfileSchema.extend({ presence: exports_external.enum(["online", "offline"]).optional() });
|
|
46860
46894
|
var readStateSchema = CommunityReadStateResourceSchema.extend({ observedRevision: exports_external.number().int().nonnegative().optional() });
|
|
46861
46895
|
var friendshipSchema = exports_external.strictObject({
|
|
46862
46896
|
id: exports_external.string().min(1),
|
|
@@ -47464,12 +47498,36 @@ var communityBotCreationRequest = sqliteTable("community_bot_creation_request",
|
|
|
47464
47498
|
resolvedAt: text("resolved_at")
|
|
47465
47499
|
}, (t) => [index("idx_bot_creation_requester").on(t.requesterId, t.createdAt), index("idx_bot_creation_owner").on(t.ownerId, t.createdAt)]);
|
|
47466
47500
|
|
|
47501
|
+
// ../shared/src/db/automation-schema.ts
|
|
47502
|
+
var exports_automation_schema = {};
|
|
47503
|
+
__export(exports_automation_schema, {
|
|
47504
|
+
automationAccessPermission: () => automationAccessPermission,
|
|
47505
|
+
automationAccessCode: () => automationAccessCode
|
|
47506
|
+
});
|
|
47507
|
+
var automationAccessCode = sqliteTable("automation_access_code", {
|
|
47508
|
+
id: text("id").primaryKey(),
|
|
47509
|
+
ownerId: text("owner_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
47510
|
+
name: text("name").notNull(),
|
|
47511
|
+
secretHash: text("secret_hash").notNull().unique(),
|
|
47512
|
+
expiresAt: text("expires_at"),
|
|
47513
|
+
createdAt: text("created_at").notNull()
|
|
47514
|
+
}, (table) => [index("idx_automation_code_owner").on(table.ownerId)]);
|
|
47515
|
+
var automationAccessPermission = sqliteTable("automation_access_permission", {
|
|
47516
|
+
codeId: text("code_id").notNull().references(() => automationAccessCode.id, { onDelete: "cascade" }),
|
|
47517
|
+
permission: text("permission").$type().notNull(),
|
|
47518
|
+
limit: integer2("request_limit").notNull(),
|
|
47519
|
+
period: text("period", { enum: ["hour", "day"] }).notNull()
|
|
47520
|
+
}, (table) => [primaryKey({ columns: [table.codeId, table.permission] })]);
|
|
47521
|
+
|
|
47467
47522
|
// ../shared/src/db/index.ts
|
|
47468
|
-
var allSchema = { ...exports_schema, ...exports_community_schema, ...exports_community_machine_schema, ...exports_product_plan_schema, ...exports_billing_schema, ...exports_community_funnel_analytics_schema, ...exports_bot_creation_schema };
|
|
47523
|
+
var allSchema = { ...exports_schema, ...exports_community_schema, ...exports_community_machine_schema, ...exports_product_plan_schema, ...exports_billing_schema, ...exports_community_funnel_analytics_schema, ...exports_bot_creation_schema, ...exports_automation_schema };
|
|
47469
47524
|
// ../shared/src/db/queries/native-oauth.ts
|
|
47470
47525
|
var ATTEMPT_TTL_MS = 10 * 60 * 1000;
|
|
47471
47526
|
var HANDOFF_TTL_MS = 2 * 60 * 1000;
|
|
47472
47527
|
var RETENTION_MS = 24 * 60 * 60 * 1000;
|
|
47528
|
+
|
|
47529
|
+
// ../shared/src/db/queries/automation.ts
|
|
47530
|
+
var publicFields = { id: automationAccessCode.id, name: automationAccessCode.name, createdAt: automationAccessCode.createdAt, expiresAt: automationAccessCode.expiresAt };
|
|
47473
47531
|
// ../shared/src/db/queries/task.ts
|
|
47474
47532
|
var DEFAULT_STALE_SECONDS = Number(process.env.ALOOK_STALE_DISPATCH_TIMEOUT_S) || 20;
|
|
47475
47533
|
var DEFAULT_STALE_RUNNING_SECONDS = Number(process.env.ALOOK_STALE_RUNNING_TIMEOUT_S) || 3600;
|
|
@@ -47645,6 +47703,15 @@ var TaskMemberInstructionCacheSchema = exports_external.strictObject({
|
|
|
47645
47703
|
globalInstruction: exports_external.string()
|
|
47646
47704
|
}).nullable();
|
|
47647
47705
|
var TaskUserIdentityCacheSchema = CommunityResourceProfileSchema.pick({ id: true, name: true }).extend({ email: exports_external.string() }).nullable();
|
|
47706
|
+
// ../shared/src/community-presence.ts
|
|
47707
|
+
var result = exports_external.strictObject({ online: exports_external.array(exports_external.string().min(1)), offline: exports_external.array(exports_external.string().min(1)) });
|
|
47708
|
+
var disjoint = (value) => !value.offline.some((id3) => value.online.includes(id3));
|
|
47709
|
+
var CommunityPresenceResultSchema = result.refine(disjoint, "Conflicting user presence");
|
|
47710
|
+
var CommunityPresenceReadSchema = result.extend({
|
|
47711
|
+
truncated: exports_external.boolean().optional(),
|
|
47712
|
+
limit: exports_external.number().int().positive().optional(),
|
|
47713
|
+
stale: exports_external.literal(true).optional()
|
|
47714
|
+
}).refine(disjoint, "Conflicting user presence");
|
|
47648
47715
|
// ../shared/src/community-forum-sidebar.ts
|
|
47649
47716
|
var timestamp = exports_external.string().refine((value) => Number.isFinite(Date.parse(value)));
|
|
47650
47717
|
var CommunityForumSidebarChannelSummarySchema = CommunityChannelResourceSchema.pick({
|
|
@@ -47830,7 +47897,7 @@ var CommunityBotsProfileReadSchema = exports_external.object({
|
|
|
47830
47897
|
var failure2 = (message2, code, details) => Object.assign(new Error(message2), { code, platformDetails: details });
|
|
47831
47898
|
function registerPlatformCommands(program, getApi, output2) {
|
|
47832
47899
|
const platform = program.command("platform").description("owner-scoped platform capabilities").exitOverride().configureOutput({ writeOut: () => {}, writeErr: () => {} });
|
|
47833
|
-
const machine2 = platform.command("machine").description("read machines, backends, models and model-specific effort").exitOverride().configureOutput({ writeOut: () => {}, writeErr: () => {} }).option("--list", "list your owner's machines").option("--backends", "show backends on --id").option("--models", "show models and effort for --id and --backend").option("--id <id>", "owner machine ID").option("--backend <id>", "backend ID from the selected machine").option("--model <id>", "show effort for this full model ID").option("--refresh", "
|
|
47900
|
+
const machine2 = platform.command("machine").description("read machines, backends, models and model-specific effort").exitOverride().configureOutput({ writeOut: () => {}, writeErr: () => {} }).option("--list", "list your owner's machines").option("--backends", "show backends on --id").option("--models", "show models and effort for --id and --backend").option("--id <id>", "owner machine ID").option("--backend <id>", "backend ID from the selected machine").option("--model <id>", "show effort for this full model ID").option("--refresh", "bypass the five-minute model cache and wait for fresh models");
|
|
47834
47901
|
machine2.action(async () => {
|
|
47835
47902
|
const opts = machine2.opts();
|
|
47836
47903
|
const actions = [opts.list, opts.backends, opts.models].filter(Boolean).length;
|
|
@@ -47851,8 +47918,8 @@ function registerPlatformCommands(program, getApi, output2) {
|
|
|
47851
47918
|
const api2 = getApi();
|
|
47852
47919
|
if (!api2.platformMachine)
|
|
47853
47920
|
throw failure2("Platform machine commands are unavailable", "UPGRADE_REQUIRED");
|
|
47854
|
-
const
|
|
47855
|
-
output2({ success:
|
|
47921
|
+
const result2 = await api2.platformMachine(opts.list ? { action: "list" } : opts.backends ? { action: "backends", machineId: opts.id } : { action: "models", machineId: opts.id, backendId: opts.backend, ...opts.model ? { model: opts.model } : {}, refresh: opts.refresh === true, requestId: randomUUID() });
|
|
47922
|
+
output2({ success: result2 });
|
|
47856
47923
|
});
|
|
47857
47924
|
const bot = platform.command("bot").description("read bots or request owner-approved creation").exitOverride().configureOutput({ writeOut: () => {}, writeErr: () => {} }).option("--list", "list your owner's bot summaries").option("--create <bot-json>", "request one bot; repeat for one gallery request", (value, previous) => [...previous, value], []);
|
|
47858
47925
|
bot.action(async () => {
|
|
@@ -47894,6 +47961,239 @@ function registerPlatformCommands(program, getApi, output2) {
|
|
|
47894
47961
|
});
|
|
47895
47962
|
}
|
|
47896
47963
|
|
|
47964
|
+
// src/cli/use.ts
|
|
47965
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
47966
|
+
import { readFile, stat } from "node:fs/promises";
|
|
47967
|
+
var BotInput = exports_external.strictObject({
|
|
47968
|
+
...CommunityBotCreateRequestSchema.omit({ runtime: true, image: true }).shape,
|
|
47969
|
+
backendId: exports_external.string().min(1).max(64)
|
|
47970
|
+
});
|
|
47971
|
+
var ServerInput = exports_external.strictObject({ name: exports_external.string().trim().min(1).max(MAX_SERVER_NAME_LENGTH), description: exports_external.string().max(MAX_SERVER_DESCRIPTION_LENGTH).optional() });
|
|
47972
|
+
var BackendList = exports_external.array(exports_external.object({
|
|
47973
|
+
id: exports_external.string().min(1),
|
|
47974
|
+
version: exports_external.string().optional(),
|
|
47975
|
+
health: exports_external.enum(["healthy", "unhealthy"]),
|
|
47976
|
+
modelRequired: exports_external.boolean()
|
|
47977
|
+
}));
|
|
47978
|
+
var ServerChannels = exports_external.array(exports_external.object({ name: exports_external.string().min(1), type: exports_external.enum(["text", "forum"]), ref: exports_external.string().min(1) }));
|
|
47979
|
+
var MemberList = exports_external.object({
|
|
47980
|
+
server: exports_external.string().min(1),
|
|
47981
|
+
url: exports_external.url(),
|
|
47982
|
+
members: exports_external.array(exports_external.object({ handle: exports_external.string().min(1), role: exports_external.string().min(1) })),
|
|
47983
|
+
hasMore: exports_external.boolean(),
|
|
47984
|
+
cursor: exports_external.string().min(1).optional()
|
|
47985
|
+
}).refine((value) => !value.hasMore || Boolean(value.cursor));
|
|
47986
|
+
var ModelList = exports_external.object({
|
|
47987
|
+
machineId: exports_external.string().min(1),
|
|
47988
|
+
backendId: exports_external.string().min(1),
|
|
47989
|
+
source: exports_external.enum(["fresh_discovery", "cached_report"]),
|
|
47990
|
+
requestId: exports_external.string().min(1),
|
|
47991
|
+
readAt: exports_external.string(),
|
|
47992
|
+
observedAt: exports_external.iso.datetime(),
|
|
47993
|
+
modelRequired: exports_external.boolean(),
|
|
47994
|
+
defaultModelId: exports_external.string().nullable(),
|
|
47995
|
+
models: exports_external.array(exports_external.object({
|
|
47996
|
+
id: exports_external.string().min(1),
|
|
47997
|
+
displayName: exports_external.string().optional(),
|
|
47998
|
+
reasoningEfforts: exports_external.array(exports_external.object({ value: exports_external.string().min(1), description: exports_external.string().optional() })),
|
|
47999
|
+
defaultReasoningEffort: exports_external.string().nullable()
|
|
48000
|
+
})).nullable()
|
|
48001
|
+
});
|
|
48002
|
+
async function readAccessCode(file2) {
|
|
48003
|
+
let secret = process.env.ALOOK_ACCESS_CODE?.trim();
|
|
48004
|
+
if (file2) {
|
|
48005
|
+
if ((await stat(file2)).size > 1024)
|
|
48006
|
+
throw new Error("Access code file is too large");
|
|
48007
|
+
secret = (await readFile(file2, "utf8")).trim();
|
|
48008
|
+
}
|
|
48009
|
+
if (!secret || !/^aac_[a-f0-9]{64}$/.test(secret))
|
|
48010
|
+
throw new Error("Set ALOOK_ACCESS_CODE or use --access-code-file with an Automation access code");
|
|
48011
|
+
return secret;
|
|
48012
|
+
}
|
|
48013
|
+
function serverOrigin(value) {
|
|
48014
|
+
const url2 = new URL(value);
|
|
48015
|
+
if (url2.username || url2.password || url2.search || url2.hash || url2.pathname !== "/")
|
|
48016
|
+
throw new Error("--server-url must be a server origin");
|
|
48017
|
+
const local = ["localhost", "127.0.0.1", "[::1]"].includes(url2.hostname);
|
|
48018
|
+
if (url2.protocol !== "https:" && !(url2.protocol === "http:" && local))
|
|
48019
|
+
throw new Error("--server-url requires HTTPS, except for local development");
|
|
48020
|
+
return url2.origin;
|
|
48021
|
+
}
|
|
48022
|
+
function parseInput(value, schema) {
|
|
48023
|
+
if (Buffer.byteLength(value, "utf8") > 131072)
|
|
48024
|
+
throw new Error("Automation request is too large");
|
|
48025
|
+
let input2;
|
|
48026
|
+
try {
|
|
48027
|
+
input2 = JSON.parse(value);
|
|
48028
|
+
} catch {
|
|
48029
|
+
throw new Error("Invalid request JSON");
|
|
48030
|
+
}
|
|
48031
|
+
const parsed = schema.safeParse(input2);
|
|
48032
|
+
if (!parsed.success)
|
|
48033
|
+
throw new Error(parsed.error.issues.map((issue3) => `${issue3.path.join(".")}: ${issue3.message}`).join("; "));
|
|
48034
|
+
return parsed.data;
|
|
48035
|
+
}
|
|
48036
|
+
var InviteInput = exports_external.strictObject({
|
|
48037
|
+
server: exports_external.string().max(128).refine((value) => Boolean(parseNameAndTag(value)), "Use a full server handle"),
|
|
48038
|
+
friend: exports_external.string().max(128).refine((value) => Boolean(parseNameAndTag(value)), "Use a full friend handle")
|
|
48039
|
+
});
|
|
48040
|
+
function registerUseCommands(program, output2) {
|
|
48041
|
+
const use = program.command("use").description("user Automation access: read lists, create resources, invite friends and send messages; no daemon connection required").option("--access-code-file <path>", "read the code from a file instead of ALOOK_ACCESS_CODE").option("--server-url <url>", "server origin (or ALOOK_SERVER_URL; defaults to production)").exitOverride().configureOutput({ writeOut: () => {}, writeErr: () => {} });
|
|
48042
|
+
const request = async (path, body, timeoutMs = 30000) => {
|
|
48043
|
+
const options = use.opts();
|
|
48044
|
+
const origin = serverOrigin(options.serverUrl || process.env.ALOOK_SERVER_URL || "https://alook.ai");
|
|
48045
|
+
const secret = await readAccessCode(options.accessCodeFile);
|
|
48046
|
+
let response;
|
|
48047
|
+
try {
|
|
48048
|
+
response = await fetch(`${origin}${path}`, {
|
|
48049
|
+
method: body === undefined ? "GET" : "POST",
|
|
48050
|
+
headers: { "Content-Type": "application/json", Authorization: `Bearer ${secret}` },
|
|
48051
|
+
...body === undefined ? {} : { body: JSON.stringify(body) },
|
|
48052
|
+
redirect: "error",
|
|
48053
|
+
signal: AbortSignal.timeout(timeoutMs)
|
|
48054
|
+
});
|
|
48055
|
+
} catch {
|
|
48056
|
+
throw new Error(body === undefined ? "Automation request failed" : "Automation request failed; the result may be unknown. Do not retry automatically.");
|
|
48057
|
+
}
|
|
48058
|
+
let raw;
|
|
48059
|
+
try {
|
|
48060
|
+
raw = await response.json();
|
|
48061
|
+
} catch {
|
|
48062
|
+
throw new Error(`Automation returned HTTP ${response.status} without a valid result; do not retry automatically`);
|
|
48063
|
+
}
|
|
48064
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw))
|
|
48065
|
+
throw new Error("Automation returned an invalid result");
|
|
48066
|
+
const result2 = raw;
|
|
48067
|
+
if (!response.ok) {
|
|
48068
|
+
const message2 = typeof result2.error === "string" ? result2.error.replaceAll(secret, "[redacted]") : `Automation failed: HTTP ${response.status}`;
|
|
48069
|
+
throw Object.assign(new Error(message2), {
|
|
48070
|
+
...typeof result2.code === "string" ? { code: result2.code.replaceAll(secret, "[redacted]") } : {},
|
|
48071
|
+
...response.status === 429 ? { hint: `Retry after ${response.headers.get("Retry-After") ?? "the indicated"} seconds` } : {}
|
|
48072
|
+
});
|
|
48073
|
+
}
|
|
48074
|
+
return { result: result2, origin };
|
|
48075
|
+
};
|
|
48076
|
+
use.command("expire").description("expire the supplied access code immediately").action(async () => {
|
|
48077
|
+
const { result: result2 } = await request("/api/community/automation/expire", {});
|
|
48078
|
+
if (result2.expired !== true)
|
|
48079
|
+
throw new Error("Automation returned an invalid expiration result");
|
|
48080
|
+
output2({ success: { expired: true } });
|
|
48081
|
+
});
|
|
48082
|
+
use.command("message").exitOverride().configureOutput({ writeOut: () => {}, writeErr: () => {} }).description("send a UTF-8 file as yourself or an owned bot").option("--send", "send one message").requiredOption("--target <ref>", "channel or DM ref").requiredOption("--as <identity>", "me or @name#NNNN of your bot").requiredOption("--file <path>", "UTF-8 message body file").action(async (options) => {
|
|
48083
|
+
if (!options.send)
|
|
48084
|
+
throw new Error("Use message --send");
|
|
48085
|
+
const info = await stat(options.file);
|
|
48086
|
+
if (!info.isFile() || info.size > MAX_MESSAGE_CONTENT_LENGTH * 4)
|
|
48087
|
+
throw new Error("Message file is invalid or too large");
|
|
48088
|
+
const bytes = await readFile(options.file);
|
|
48089
|
+
if (bytes.length > MAX_MESSAGE_CONTENT_LENGTH * 4)
|
|
48090
|
+
throw new Error("Message file is too large");
|
|
48091
|
+
const content = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(bytes);
|
|
48092
|
+
const body = parseInput(JSON.stringify({ target: options.target, as: options.as, content, nonce: randomUUID2() }), AutomationMessageSendSchema);
|
|
48093
|
+
const { result: result2 } = await request("/api/community/automation/messages", body);
|
|
48094
|
+
if (result2.state === "blocked")
|
|
48095
|
+
throw Object.assign(new Error("Bot has unread messages; use its normal inbox pull before sending"), { code: "unaligned" });
|
|
48096
|
+
const sent = AutomationMessageSentSchema.safeParse(result2);
|
|
48097
|
+
if (!sent.success)
|
|
48098
|
+
throw new Error("Automation returned an invalid message result");
|
|
48099
|
+
output2({ success: sent.data });
|
|
48100
|
+
});
|
|
48101
|
+
for (const kind of ["bot", "server", "machine", "friend"]) {
|
|
48102
|
+
const command = use.command(kind).description(`Automation ${kind} operations`).exitOverride().configureOutput({ writeOut: () => {}, writeErr: () => {} });
|
|
48103
|
+
if (kind === "bot" || kind === "server")
|
|
48104
|
+
command.option("--create <json>", kind === "bot" ? "bot JSON: name, machineId, backendId, optional description/model/reasoningEffort" : "server JSON: name, optional description");
|
|
48105
|
+
if (kind !== "bot")
|
|
48106
|
+
command.option("--list", `list minimal ${kind} identities`);
|
|
48107
|
+
if (kind === "machine")
|
|
48108
|
+
command.option("--list-models", "fetch fresh backend models and reasoning efforts").option("--refresh", "bypass the five-minute model cache").option("--id <machine-id>", "target machine ID for --list-models").option("--backend <backend-id>", "target backend ID for --list-models");
|
|
48109
|
+
if (kind === "server")
|
|
48110
|
+
command.option("--invite <json>", "invite JSON: server and friend full handles").option("--members <server>", "list joined members by full server handle").option("--cursor <cursor>", "next page cursor for --members");
|
|
48111
|
+
command.action(async () => {
|
|
48112
|
+
const options = command.opts();
|
|
48113
|
+
if ([options.create !== undefined, options.list === true, options.invite !== undefined, options.listModels === true, options.members !== undefined].filter(Boolean).length !== 1)
|
|
48114
|
+
throw new Error("Choose exactly one action: --create, --list, --invite, --list-models, or --members");
|
|
48115
|
+
if (options.cursor !== undefined && options.members === undefined)
|
|
48116
|
+
throw new Error("--cursor requires --members");
|
|
48117
|
+
if (options.members !== undefined) {
|
|
48118
|
+
if (!parseNameAndTag(options.members))
|
|
48119
|
+
throw new Error("Use a full server handle");
|
|
48120
|
+
const query = options.cursor ? `?${new URLSearchParams({ cursor: options.cursor })}` : "";
|
|
48121
|
+
const { result: result3 } = await request(`/api/community/automation/servers/${encodeURIComponent(options.members)}/members${query}`);
|
|
48122
|
+
const parsed = MemberList.safeParse(result3);
|
|
48123
|
+
if (!parsed.success || parsed.data.server !== options.members)
|
|
48124
|
+
throw new Error("Automation returned an invalid member list");
|
|
48125
|
+
output2({ success: parsed.data });
|
|
48126
|
+
return;
|
|
48127
|
+
}
|
|
48128
|
+
if (options.listModels) {
|
|
48129
|
+
if (!options.id?.trim() || !options.backend?.trim())
|
|
48130
|
+
throw new Error("--list-models requires --id and --backend");
|
|
48131
|
+
const requestId = randomUUID2();
|
|
48132
|
+
const { result: result3 } = await request(`/api/community/automation/machines/${encodeURIComponent(options.id)}/discover-models`, { requestId, runtimeId: options.backend, ...options.refresh ? { refresh: true } : {} }, 55000);
|
|
48133
|
+
const parsed = ModelList.safeParse(result3);
|
|
48134
|
+
if (!parsed.success || parsed.data.machineId !== options.id || parsed.data.backendId !== options.backend || parsed.data.requestId !== requestId)
|
|
48135
|
+
throw new Error("Automation returned an invalid model list");
|
|
48136
|
+
output2({ success: parsed.data });
|
|
48137
|
+
return;
|
|
48138
|
+
}
|
|
48139
|
+
if (options.id !== undefined || options.backend !== undefined || options.refresh)
|
|
48140
|
+
throw new Error("--id, --backend and --refresh require --list-models");
|
|
48141
|
+
if (options.list) {
|
|
48142
|
+
const key = `${kind}s`;
|
|
48143
|
+
const { result: result3 } = await request(kind === "friend" ? "/api/community/automation/friends" : `/api/community/automation/${key}`);
|
|
48144
|
+
const rows = result3[key];
|
|
48145
|
+
if (!Array.isArray(rows))
|
|
48146
|
+
throw new Error("Automation returned an invalid list");
|
|
48147
|
+
const list = rows.map((row) => {
|
|
48148
|
+
if (!row || typeof row !== "object" || !("name" in row) || typeof row.name !== "string")
|
|
48149
|
+
throw new Error("Automation returned an invalid identity");
|
|
48150
|
+
if (kind === "machine" && "id" in row && typeof row.id === "string" && "status" in row && (row.status === "online" || row.status === "offline")) {
|
|
48151
|
+
const backends = BackendList.safeParse("backends" in row ? row.backends : undefined);
|
|
48152
|
+
if (!backends.success)
|
|
48153
|
+
throw new Error("Automation returned an invalid backend list");
|
|
48154
|
+
return { id: row.id, name: row.name, status: row.status, backends: backends.data };
|
|
48155
|
+
}
|
|
48156
|
+
if (kind === "friend" && "handle" in row && typeof row.handle === "string" && "is_my_bot" in row && typeof row.is_my_bot === "boolean")
|
|
48157
|
+
return { name: row.name, handle: row.handle, is_my_bot: row.is_my_bot };
|
|
48158
|
+
if (kind === "server" && "handle" in row && typeof row.handle === "string") {
|
|
48159
|
+
const channels = ServerChannels.safeParse("channels" in row ? row.channels : undefined);
|
|
48160
|
+
if (!channels.success)
|
|
48161
|
+
throw new Error("Automation returned an invalid server channel list");
|
|
48162
|
+
return { name: row.name, handle: row.handle, channels: channels.data };
|
|
48163
|
+
}
|
|
48164
|
+
throw new Error("Automation returned an invalid identity");
|
|
48165
|
+
});
|
|
48166
|
+
output2({ success: { [key]: list } });
|
|
48167
|
+
return;
|
|
48168
|
+
}
|
|
48169
|
+
if (options.invite !== undefined) {
|
|
48170
|
+
const input2 = parseInput(options.invite, InviteInput);
|
|
48171
|
+
const { result: result3 } = await request(`/api/community/automation/servers/${encodeURIComponent(input2.server)}/invites`, { friend: input2.friend });
|
|
48172
|
+
const value = result3.invitation;
|
|
48173
|
+
if (!value || typeof value !== "object" || !("sent" in value) || value.sent !== true || !("server" in value) || typeof value.server !== "string" || !("friend" in value) || typeof value.friend !== "string")
|
|
48174
|
+
throw new Error("Automation returned an invalid invitation result; do not retry automatically");
|
|
48175
|
+
output2({ success: { invitation: { server: value.server, friend: value.friend, sent: true } } });
|
|
48176
|
+
return;
|
|
48177
|
+
}
|
|
48178
|
+
let body;
|
|
48179
|
+
if (kind === "bot") {
|
|
48180
|
+
const { backendId, ...bot } = parseInput(options.create, BotInput);
|
|
48181
|
+
body = { ...bot, runtime: backendId };
|
|
48182
|
+
} else
|
|
48183
|
+
body = parseInput(options.create, ServerInput);
|
|
48184
|
+
const { result: result2, origin } = await request(`/api/community/automation/${kind}s`, body);
|
|
48185
|
+
const resource = result2[kind];
|
|
48186
|
+
if (!resource || typeof resource !== "object" || !("id" in resource) || !("name" in resource) || !("discriminator" in resource) || typeof resource.id !== "string" || typeof resource.name !== "string" || typeof resource.discriminator !== "string")
|
|
48187
|
+
throw new Error("Automation returned an invalid result; do not retry automatically");
|
|
48188
|
+
output2({ success: { [kind]: {
|
|
48189
|
+
id: resource.id,
|
|
48190
|
+
handle: `${resource.name}#${resource.discriminator}`,
|
|
48191
|
+
...kind === "server" ? { url: `${origin}/c/channels/${encodeURIComponent(resource.id)}` } : {}
|
|
48192
|
+
} } });
|
|
48193
|
+
});
|
|
48194
|
+
}
|
|
48195
|
+
}
|
|
48196
|
+
|
|
47897
48197
|
// src/cli/index.ts
|
|
47898
48198
|
import { Command, CommanderError } from "commander";
|
|
47899
48199
|
|
|
@@ -47987,7 +48287,7 @@ class PiiRunner {
|
|
|
47987
48287
|
sequence = 0;
|
|
47988
48288
|
tail = Promise.resolve();
|
|
47989
48289
|
evaluate(plugins, text2) {
|
|
47990
|
-
return this.evaluateWithResult(plugins, text2).then((
|
|
48290
|
+
return this.evaluateWithResult(plugins, text2).then((result2) => result2.text);
|
|
47991
48291
|
}
|
|
47992
48292
|
evaluateWithResult(plugins, text2) {
|
|
47993
48293
|
if (this.closed || this.pending >= 32)
|
|
@@ -48271,7 +48571,7 @@ function registerPiiCommands(program, output2) {
|
|
|
48271
48571
|
|
|
48272
48572
|
// src/cli/index.ts
|
|
48273
48573
|
import { realpathSync as realpathSync2 } from "node:fs";
|
|
48274
|
-
import { randomUUID as
|
|
48574
|
+
import { randomUUID as randomUUID15 } from "node:crypto";
|
|
48275
48575
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
48276
48576
|
// src/cli/proxyServerApi.ts
|
|
48277
48577
|
import * as fs from "fs";
|
|
@@ -48686,9 +48986,7 @@ function createProxyServerApi(config2) {
|
|
|
48686
48986
|
const machine2 = `/machines/${encodeURIComponent(req.machineId)}`;
|
|
48687
48987
|
if (req.action === "backends")
|
|
48688
48988
|
return platformCall(machine2);
|
|
48689
|
-
|
|
48690
|
-
return platformCall(`${machine2}/discover-models`, "POST", { requestId: req.requestId ?? crypto.randomUUID(), runtimeId: req.backendId });
|
|
48691
|
-
return platformCall(`${machine2}/models?backend=${encodeURIComponent(req.backendId)}${req.model ? `&model=${encodeURIComponent(req.model)}` : ""}`);
|
|
48989
|
+
return platformCall(`${machine2}/discover-models?wait=1${req.model ? `&model=${encodeURIComponent(req.model)}` : ""}`, "POST", { requestId: req.requestId ?? crypto.randomUUID(), runtimeId: req.backendId, ...req.refresh ? { refresh: true } : {} });
|
|
48692
48990
|
}
|
|
48693
48991
|
async function callPlatformBot(req) {
|
|
48694
48992
|
if (req.action === "list")
|
|
@@ -48736,7 +49034,7 @@ import * as path14 from "path";
|
|
|
48736
49034
|
import * as fs6 from "fs";
|
|
48737
49035
|
import { fileURLToPath } from "url";
|
|
48738
49036
|
// agent-driver/dist/host/default-host.js
|
|
48739
|
-
import { randomUUID as
|
|
49037
|
+
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
48740
49038
|
function createDefaultAgentDriverHost(options = {}) {
|
|
48741
49039
|
const environment = { ...options.environment ?? process.env };
|
|
48742
49040
|
return {
|
|
@@ -48759,7 +49057,7 @@ function createDefaultAgentDriverHost(options = {}) {
|
|
|
48759
49057
|
options.onRawOutput?.(event);
|
|
48760
49058
|
},
|
|
48761
49059
|
now: () => Date.now(),
|
|
48762
|
-
createId: () =>
|
|
49060
|
+
createId: () => randomUUID3()
|
|
48763
49061
|
};
|
|
48764
49062
|
}
|
|
48765
49063
|
|
|
@@ -48772,7 +49070,7 @@ import { EventEmitter } from "events";
|
|
|
48772
49070
|
|
|
48773
49071
|
// agent-driver/dist/internal/killTree.js
|
|
48774
49072
|
import { execFileSync as execFileSync2, spawn } from "child_process";
|
|
48775
|
-
import { randomUUID as
|
|
49073
|
+
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
48776
49074
|
import { createServer } from "node:net";
|
|
48777
49075
|
import { PassThrough } from "node:stream";
|
|
48778
49076
|
|
|
@@ -49227,7 +49525,7 @@ function spawnAgentProcess(command, args, opts) {
|
|
|
49227
49525
|
if (!isPosix) {
|
|
49228
49526
|
const stdin = opts.stdin ?? "pipe";
|
|
49229
49527
|
const stdinProxy = stdin === "pipe" ? new PassThrough : undefined;
|
|
49230
|
-
const stdinPipe = stdinProxy ? `\\\\.\\pipe\\alook-agent-${process.pid}-${
|
|
49528
|
+
const stdinPipe = stdinProxy ? `\\\\.\\pipe\\alook-agent-${process.pid}-${randomUUID4()}` : undefined;
|
|
49231
49529
|
let stdinSocket;
|
|
49232
49530
|
const stdinServer = stdinProxy ? createServer((socket) => {
|
|
49233
49531
|
stdinSocket = socket;
|
|
@@ -49385,12 +49683,12 @@ function taskkillTree(pid) {
|
|
|
49385
49683
|
windowsHide: true
|
|
49386
49684
|
});
|
|
49387
49685
|
let settled = false;
|
|
49388
|
-
const settle2 = (
|
|
49686
|
+
const settle2 = (result2, error62) => {
|
|
49389
49687
|
if (settled)
|
|
49390
49688
|
return;
|
|
49391
49689
|
settled = true;
|
|
49392
49690
|
clearTimeout(timer);
|
|
49393
|
-
if (
|
|
49691
|
+
if (result2 === "resolve")
|
|
49394
49692
|
resolve();
|
|
49395
49693
|
else
|
|
49396
49694
|
reject(error62);
|
|
@@ -49907,9 +50205,9 @@ async function prepareCliTransport(ctx, extraEnv = {}, cli = DEFAULT_CLI_CONFIG,
|
|
|
49907
50205
|
}
|
|
49908
50206
|
|
|
49909
50207
|
// agent-driver/dist/internal/utils.js
|
|
49910
|
-
import { randomUUID as
|
|
50208
|
+
import { randomUUID as randomUUID5 } from "crypto";
|
|
49911
50209
|
function jsonRpcRequest(method, params, id3) {
|
|
49912
|
-
return JSON.stringify({ jsonrpc: "2.0", id: id3 ??
|
|
50210
|
+
return JSON.stringify({ jsonrpc: "2.0", id: id3 ?? randomUUID5(), method, params });
|
|
49913
50211
|
}
|
|
49914
50212
|
function tryParseJsonLine(line) {
|
|
49915
50213
|
try {
|
|
@@ -50240,20 +50538,20 @@ class AgyDriver {
|
|
|
50240
50538
|
}
|
|
50241
50539
|
if (this.inputIndex === undefined || index2 <= this.inputIndex)
|
|
50242
50540
|
return [];
|
|
50243
|
-
const
|
|
50541
|
+
const result3 = [];
|
|
50244
50542
|
if (step.step_type === "agent_response" && typeof step.text_delta === "string")
|
|
50245
|
-
|
|
50543
|
+
result3.push({ kind: "assistant_message_delta", text: step.text_delta });
|
|
50246
50544
|
if (step.step_type === "tool") {
|
|
50247
50545
|
const tool = asRecord(step.tool_info);
|
|
50248
50546
|
const name = typeof step.tool_name === "string" ? step.tool_name : "tool";
|
|
50249
50547
|
const callId = `${this.sessionId}:${index2}`;
|
|
50250
50548
|
if ((step.state === "ACTIVE" || step.state === "DONE") && !this.tools.has(index2)) {
|
|
50251
50549
|
this.tools.set(index2, "active");
|
|
50252
|
-
|
|
50550
|
+
result3.push({ kind: "tool_call", callId, name, input: tool?.parameters });
|
|
50253
50551
|
}
|
|
50254
50552
|
if (step.state === "DONE" && this.tools.get(index2) === "active") {
|
|
50255
50553
|
this.tools.set(index2, "done");
|
|
50256
|
-
|
|
50554
|
+
result3.push({ kind: "tool_output", callId, name });
|
|
50257
50555
|
}
|
|
50258
50556
|
}
|
|
50259
50557
|
const usage = asRecord(step.usage);
|
|
@@ -50270,21 +50568,21 @@ class AgyDriver {
|
|
|
50270
50568
|
outputIncludesReasoning: true
|
|
50271
50569
|
});
|
|
50272
50570
|
if (projected?.kind === "telemetry" && projected.name === "token_usage")
|
|
50273
|
-
|
|
50571
|
+
result3.push({
|
|
50274
50572
|
...projected,
|
|
50275
50573
|
identity: { source: `${this.usageSource}:${this.sessionId}`, index: index2, occurredAt: this.inputAt }
|
|
50276
50574
|
});
|
|
50277
50575
|
}
|
|
50278
|
-
return
|
|
50576
|
+
return result3;
|
|
50279
50577
|
}
|
|
50280
50578
|
if (event?.event !== "result")
|
|
50281
50579
|
return [];
|
|
50282
|
-
const
|
|
50283
|
-
if (
|
|
50284
|
-
return this.fail(typeof
|
|
50285
|
-
if (!this.pending ||
|
|
50580
|
+
const result2 = asRecord(event.result);
|
|
50581
|
+
if (result2?.status === "ERROR" && !this.sessionId)
|
|
50582
|
+
return this.fail(typeof result2.error === "string" ? result2.error : "Antigravity CLI initialization failed");
|
|
50583
|
+
if (!this.pending || result2?.conversation_id !== this.sessionId)
|
|
50286
50584
|
return [];
|
|
50287
|
-
const turns =
|
|
50585
|
+
const turns = result2.num_turns;
|
|
50288
50586
|
if (!Number.isSafeInteger(turns) || turns < 1)
|
|
50289
50587
|
return this.fail("Antigravity CLI emitted an invalid turn counter");
|
|
50290
50588
|
if (this.previousTurns !== undefined && turns <= this.previousTurns)
|
|
@@ -50294,17 +50592,17 @@ class AgyDriver {
|
|
|
50294
50592
|
this.previousTurns = turns;
|
|
50295
50593
|
this.pending = false;
|
|
50296
50594
|
const events = [];
|
|
50297
|
-
const interrupted =
|
|
50298
|
-
if (
|
|
50299
|
-
if (typeof
|
|
50595
|
+
const interrupted = result2.status === "CANCELLED" || result2.status === "ERROR" && result2.error === "interrupted";
|
|
50596
|
+
if (result2.status === "SUCCESS") {
|
|
50597
|
+
if (typeof result2.response !== "string")
|
|
50300
50598
|
return this.fail("Antigravity CLI result is missing response text");
|
|
50301
|
-
events.push({ kind: "assistant_message_completed", text:
|
|
50599
|
+
events.push({ kind: "assistant_message_completed", text: result2.response });
|
|
50302
50600
|
} else if (!interrupted)
|
|
50303
|
-
events.push({ kind: "error", message: typeof
|
|
50601
|
+
events.push({ kind: "error", message: typeof result2.error === "string" ? result2.error : `Antigravity CLI status: ${String(result2.status)}` });
|
|
50304
50602
|
events.push({
|
|
50305
50603
|
kind: "turn_end",
|
|
50306
50604
|
sessionId: this.currentSessionId,
|
|
50307
|
-
...
|
|
50605
|
+
...result2.status !== "SUCCESS" ? { pendingContent: "discard" } : {},
|
|
50308
50606
|
...interrupted ? { outcome: "interrupted" } : {}
|
|
50309
50607
|
});
|
|
50310
50608
|
return events;
|
|
@@ -50374,7 +50672,7 @@ function fields(data) {
|
|
|
50374
50672
|
}
|
|
50375
50673
|
throw new Error("Invalid native usage varint");
|
|
50376
50674
|
};
|
|
50377
|
-
const
|
|
50675
|
+
const result2 = [];
|
|
50378
50676
|
while (offset < data.length) {
|
|
50379
50677
|
const tag = varint();
|
|
50380
50678
|
const number4 = Number(tag >> 3n);
|
|
@@ -50382,12 +50680,12 @@ function fields(data) {
|
|
|
50382
50680
|
if (!number4 || number4 > 536870911)
|
|
50383
50681
|
throw new Error("Invalid native usage field");
|
|
50384
50682
|
if (wire === 0)
|
|
50385
|
-
|
|
50683
|
+
result2.push({ number: number4, value: varint() });
|
|
50386
50684
|
else if (wire === 2) {
|
|
50387
50685
|
const length = Number(varint());
|
|
50388
50686
|
if (!Number.isSafeInteger(length) || length < 0 || offset + length > data.length)
|
|
50389
50687
|
throw new Error("Invalid native usage length");
|
|
50390
|
-
|
|
50688
|
+
result2.push({ number: number4, value: data.subarray(offset, offset + length) });
|
|
50391
50689
|
offset += length;
|
|
50392
50690
|
} else if (wire === 1 || wire === 5) {
|
|
50393
50691
|
offset += wire === 1 ? 8 : 4;
|
|
@@ -50396,7 +50694,7 @@ function fields(data) {
|
|
|
50396
50694
|
} else
|
|
50397
50695
|
throw new Error("Unsupported native usage field");
|
|
50398
50696
|
}
|
|
50399
|
-
return
|
|
50697
|
+
return result2;
|
|
50400
50698
|
}
|
|
50401
50699
|
function nested(data, number4) {
|
|
50402
50700
|
const value = data.filter((field) => field.number === number4).at(-1)?.value;
|
|
@@ -50442,7 +50740,7 @@ class NativeUsageReader {
|
|
|
50442
50740
|
const path5 = join5(this.home, "antigravity-acp", "conversations", `${this.sessionId}.db`);
|
|
50443
50741
|
let cursor = this.cursor;
|
|
50444
50742
|
let complete = false;
|
|
50445
|
-
const
|
|
50743
|
+
const result2 = [];
|
|
50446
50744
|
for (let batch = 0;batch < 16; batch++) {
|
|
50447
50745
|
const rows = await this.readRows(path5, cursor);
|
|
50448
50746
|
for (const row of rows) {
|
|
@@ -50453,7 +50751,7 @@ class NativeUsageReader {
|
|
|
50453
50751
|
const parsed = parseNativeGeneration(Buffer.from(row.data, "hex"));
|
|
50454
50752
|
if (!parsed.occurredAt)
|
|
50455
50753
|
throw new Error("Native usage timestamp unavailable");
|
|
50456
|
-
|
|
50754
|
+
result2.push({ usage: row.has_children ? { input: null, output: null, cache: null } : parsed.usage, identity: { source: `antigravity:${createHash2("sha256").update(this.home).digest("hex").slice(0, 16)}:${this.sessionId}`, index: row.idx, occurredAt: parsed.occurredAt } });
|
|
50457
50755
|
cursor = row.idx;
|
|
50458
50756
|
}
|
|
50459
50757
|
if (!rows.length) {
|
|
@@ -50462,7 +50760,7 @@ class NativeUsageReader {
|
|
|
50462
50760
|
}
|
|
50463
50761
|
}
|
|
50464
50762
|
this.cursor = cursor;
|
|
50465
|
-
return { samples:
|
|
50763
|
+
return { samples: result2, complete, ...this.childTrajectories ? { incompleteScope: true } : {} };
|
|
50466
50764
|
}
|
|
50467
50765
|
}
|
|
50468
50766
|
async function queryNativeRowsWithCli(path5, cursor) {
|
|
@@ -50902,8 +51200,8 @@ class AntigravityAcpLane {
|
|
|
50902
51200
|
completePrompt(prompt, value) {
|
|
50903
51201
|
if (this.currentPromptRequestId !== prompt.requestId)
|
|
50904
51202
|
return;
|
|
50905
|
-
const
|
|
50906
|
-
if (!
|
|
51203
|
+
const result2 = record2(value);
|
|
51204
|
+
if (!result2 || typeof result2.stopReason !== "string" || !PROMPT_STOP_REASONS.has(result2.stopReason)) {
|
|
50907
51205
|
this.failPrompt(prompt, new Error("Antigravity ACP prompt response did not contain a supported stopReason"), "antigravity.invalid_stop_reason");
|
|
50908
51206
|
return;
|
|
50909
51207
|
}
|
|
@@ -50915,7 +51213,7 @@ class AntigravityAcpLane {
|
|
|
50915
51213
|
kind: "turn_end",
|
|
50916
51214
|
sessionId: this.sessionId ?? undefined,
|
|
50917
51215
|
turnOwner: terminalOwner,
|
|
50918
|
-
...
|
|
51216
|
+
...result2.stopReason === "cancelled" ? { outcome: "interrupted", pendingContent: "discard" } : {}
|
|
50919
51217
|
});
|
|
50920
51218
|
}
|
|
50921
51219
|
failPrompt(prompt, error62, code = "antigravity.prompt_failed") {
|
|
@@ -51101,14 +51399,14 @@ class AntigravityAcpLane {
|
|
|
51101
51399
|
(async () => {
|
|
51102
51400
|
const deadline = Date.now() + 5000;
|
|
51103
51401
|
for (let batch = 0;batch < 16; batch++) {
|
|
51104
|
-
const
|
|
51402
|
+
const result2 = await this.usageReader.read();
|
|
51105
51403
|
if (this.currentPromptRequestId !== pending.prompt.requestId || this.isClosed() || this.requestedStopReason)
|
|
51106
51404
|
return;
|
|
51107
|
-
for (const sample of
|
|
51405
|
+
for (const sample of result2.samples)
|
|
51108
51406
|
this.events.emit("runtime_event", { kind: "telemetry", name: "token_usage", source: "antigravity.native", ...sample });
|
|
51109
|
-
if (
|
|
51407
|
+
if (result2.incompleteScope)
|
|
51110
51408
|
throw new Error("Child trajectory accounting unavailable");
|
|
51111
|
-
if (
|
|
51409
|
+
if (result2.complete) {
|
|
51112
51410
|
this.events.emit("runtime_event", { kind: "telemetry", name: "token_usage_status", source: "antigravity.native", status: "available" });
|
|
51113
51411
|
return;
|
|
51114
51412
|
}
|
|
@@ -51296,7 +51594,7 @@ class AntigravityAcpLane {
|
|
|
51296
51594
|
}
|
|
51297
51595
|
|
|
51298
51596
|
// agent-driver/dist/adapters/antigravity/probe.js
|
|
51299
|
-
import { createHash as createHash3, randomUUID as
|
|
51597
|
+
import { createHash as createHash3, randomUUID as randomUUID6 } from "node:crypto";
|
|
51300
51598
|
import { mkdirSync as mkdirSync3, readFileSync as readFileSync3, renameSync as renameSync2, writeFileSync as writeFileSync3 } from "node:fs";
|
|
51301
51599
|
import { homedir as homedir5 } from "node:os";
|
|
51302
51600
|
import { join as join6 } from "node:path";
|
|
@@ -51341,7 +51639,7 @@ async function probeAntigravity(command, options = {}) {
|
|
|
51341
51639
|
let version3;
|
|
51342
51640
|
let sessionRequestId = 0;
|
|
51343
51641
|
let loading = false;
|
|
51344
|
-
const finish = (
|
|
51642
|
+
const finish = (result2) => {
|
|
51345
51643
|
if (settled)
|
|
51346
51644
|
return;
|
|
51347
51645
|
settled = true;
|
|
@@ -51352,7 +51650,7 @@ async function probeAntigravity(command, options = {}) {
|
|
|
51352
51650
|
else
|
|
51353
51651
|
child.kill("SIGTERM");
|
|
51354
51652
|
});
|
|
51355
|
-
cleanup(proc).then(() => resolve2(
|
|
51653
|
+
cleanup(proc).then(() => resolve2(result2), () => resolve2({ status: "unhealthy", lastError: "antigravity_acp_cleanup_failed" }));
|
|
51356
51654
|
};
|
|
51357
51655
|
const fail = (lastError) => finish({ status: "unhealthy", lastError });
|
|
51358
51656
|
const timer = setTimeout(() => fail("antigravity_acp_timeout"), options.timeoutMs ?? (process.platform === "win32" ? 30000 : 1e4));
|
|
@@ -51420,20 +51718,20 @@ async function probeAntigravity(command, options = {}) {
|
|
|
51420
51718
|
finish({ status: "healthy", ...version3 ? { version: version3 } : {} });
|
|
51421
51719
|
continue;
|
|
51422
51720
|
}
|
|
51423
|
-
const
|
|
51424
|
-
const sessionId = loading ? cachedSessionId :
|
|
51425
|
-
if (typeof sessionId !== "string" || !/^[A-Za-z0-9_-]{1,100}$/.test(sessionId) || loading &&
|
|
51721
|
+
const result3 = asRecord(message2.result);
|
|
51722
|
+
const sessionId = loading ? cachedSessionId : result3?.sessionId;
|
|
51723
|
+
if (typeof sessionId !== "string" || !/^[A-Za-z0-9_-]{1,100}$/.test(sessionId) || loading && result3?.sessionId !== undefined && result3.sessionId !== sessionId)
|
|
51426
51724
|
return fail("antigravity_acp_invalid_session");
|
|
51427
51725
|
if (!loading) {
|
|
51428
51726
|
try {
|
|
51429
|
-
const temporary = `${cacheFile}.${
|
|
51727
|
+
const temporary = `${cacheFile}.${randomUUID6()}.tmp`;
|
|
51430
51728
|
writeFileSync3(temporary, sessionId, { mode: 384 });
|
|
51431
51729
|
renameSync2(temporary, cacheFile);
|
|
51432
51730
|
} catch {
|
|
51433
51731
|
return fail("antigravity_acp_probe_storage_failed");
|
|
51434
51732
|
}
|
|
51435
51733
|
}
|
|
51436
|
-
const catalog = parseAntigravityCatalog(
|
|
51734
|
+
const catalog = parseAntigravityCatalog(result3);
|
|
51437
51735
|
finish({
|
|
51438
51736
|
status: "healthy",
|
|
51439
51737
|
...version3 ? { version: version3 } : {},
|
|
@@ -51443,10 +51741,10 @@ async function probeAntigravity(command, options = {}) {
|
|
|
51443
51741
|
}
|
|
51444
51742
|
if (message2?.id !== 1 || sessionRequestId)
|
|
51445
51743
|
continue;
|
|
51446
|
-
const
|
|
51447
|
-
if (message2.jsonrpc !== "2.0" || message2.error ||
|
|
51744
|
+
const result2 = asRecord(message2.result);
|
|
51745
|
+
if (message2.jsonrpc !== "2.0" || message2.error || result2?.protocolVersion !== 1 || asRecord(result2.agentCapabilities)?.loadSession !== true || asRecord(result2.agentInfo)?.name !== "antigravity-acp")
|
|
51448
51746
|
return fail("antigravity_acp_incompatible");
|
|
51449
|
-
const reportedVersion = asRecord(
|
|
51747
|
+
const reportedVersion = asRecord(result2.agentInfo)?.version;
|
|
51450
51748
|
version3 = typeof reportedVersion === "string" ? reportedVersion : undefined;
|
|
51451
51749
|
if (!includeModels) {
|
|
51452
51750
|
finish({ status: "healthy", ...version3 ? { version: version3 } : {} });
|
|
@@ -51492,7 +51790,7 @@ class AntigravityDriver {
|
|
|
51492
51790
|
}
|
|
51493
51791
|
|
|
51494
51792
|
// agent-driver/dist/adapters/claude/index.js
|
|
51495
|
-
import { randomUUID as
|
|
51793
|
+
import { randomUUID as randomUUID8 } from "node:crypto";
|
|
51496
51794
|
|
|
51497
51795
|
// agent-driver/dist/adapters/claude/providerIsolation.js
|
|
51498
51796
|
import * as fs5 from "fs";
|
|
@@ -51852,7 +52150,7 @@ class ClaudeEventNormalizer {
|
|
|
51852
52150
|
}
|
|
51853
52151
|
|
|
51854
52152
|
// agent-driver/dist/adapters/claude/turnProtocol.js
|
|
51855
|
-
import { randomUUID as
|
|
52153
|
+
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
51856
52154
|
|
|
51857
52155
|
class ClaudeTurnProtocol {
|
|
51858
52156
|
rootUuid = null;
|
|
@@ -51862,7 +52160,7 @@ class ClaudeTurnProtocol {
|
|
|
51862
52160
|
interruptRequested = false;
|
|
51863
52161
|
finalized = false;
|
|
51864
52162
|
beginTurn() {
|
|
51865
|
-
const uuid3 =
|
|
52163
|
+
const uuid3 = randomUUID7();
|
|
51866
52164
|
this.rootUuid = uuid3;
|
|
51867
52165
|
this.segmentOwnerUuid = uuid3;
|
|
51868
52166
|
this.delivered.clear();
|
|
@@ -51878,7 +52176,7 @@ class ClaudeTurnProtocol {
|
|
|
51878
52176
|
return this.rootUuid;
|
|
51879
52177
|
}
|
|
51880
52178
|
steeringInputUuid() {
|
|
51881
|
-
const uuid3 =
|
|
52179
|
+
const uuid3 = randomUUID7();
|
|
51882
52180
|
this.delivered.set(uuid3, { acknowledged: false, followOn: this.awaitingFollowOn });
|
|
51883
52181
|
return uuid3;
|
|
51884
52182
|
}
|
|
@@ -51945,7 +52243,7 @@ import { createInterface } from "node:readline";
|
|
|
51945
52243
|
// agent-driver/dist/internal/recent-context.js
|
|
51946
52244
|
import path6 from "node:path";
|
|
51947
52245
|
import { createReadStream } from "node:fs";
|
|
51948
|
-
import { readdir, stat } from "node:fs/promises";
|
|
52246
|
+
import { readdir, stat as stat2 } from "node:fs/promises";
|
|
51949
52247
|
function normalizeAbsolutePath(value) {
|
|
51950
52248
|
if (typeof value !== "string" || !path6.isAbsolute(value))
|
|
51951
52249
|
return null;
|
|
@@ -51989,7 +52287,7 @@ async function readFirstLine(filePath, maxBytes = 65536) {
|
|
|
51989
52287
|
async function collectJsonlFileCandidates(root, options = {}) {
|
|
51990
52288
|
const candidates = [];
|
|
51991
52289
|
const readDirectory = options.readDirectory ?? ((directory) => readdir(directory, { withFileTypes: true }));
|
|
51992
|
-
const statPath = options.statPath ??
|
|
52290
|
+
const statPath = options.statPath ?? stat2;
|
|
51993
52291
|
const visit2 = async (directory, remainingDepth, includeFiles) => {
|
|
51994
52292
|
let entries;
|
|
51995
52293
|
try {
|
|
@@ -52205,8 +52503,8 @@ class ClaudeDriver {
|
|
|
52205
52503
|
probe(command, includeModels = true) {
|
|
52206
52504
|
const explicit = command?.trim();
|
|
52207
52505
|
const base = explicit ? (() => {
|
|
52208
|
-
const
|
|
52209
|
-
return
|
|
52506
|
+
const result2 = probeCommandVersion(explicit);
|
|
52507
|
+
return result2.ok ? { status: "healthy", version: result2.version } : { status: "unhealthy", lastError: result2.error };
|
|
52210
52508
|
})() : probeClaude();
|
|
52211
52509
|
return base.status === "healthy" && includeModels ? { ...base, reasoning: CLAUDE_MODEL_CATALOG } : base;
|
|
52212
52510
|
}
|
|
@@ -52258,7 +52556,7 @@ class ClaudeDriver {
|
|
|
52258
52556
|
writeInterrupt(input2, process2) {
|
|
52259
52557
|
process2.stdin.write(JSON.stringify({
|
|
52260
52558
|
type: "control_request",
|
|
52261
|
-
request_id: input2.requestId ??
|
|
52559
|
+
request_id: input2.requestId ?? randomUUID8(),
|
|
52262
52560
|
request: { subtype: "interrupt" }
|
|
52263
52561
|
}) + `
|
|
52264
52562
|
`);
|
|
@@ -52440,8 +52738,8 @@ function rotateCodexQuotaSource() {
|
|
|
52440
52738
|
codexQuotaSourceGeneration += 1;
|
|
52441
52739
|
codexAccountFingerprint = null;
|
|
52442
52740
|
}
|
|
52443
|
-
function observeCodexAccount(
|
|
52444
|
-
const account2 =
|
|
52741
|
+
function observeCodexAccount(result2) {
|
|
52742
|
+
const account2 = result2?.account;
|
|
52445
52743
|
const fingerprint = account2 && typeof account2 === "object" ? JSON.stringify([
|
|
52446
52744
|
account2.type ?? "unknown",
|
|
52447
52745
|
account2.email ?? null,
|
|
@@ -53005,13 +53303,13 @@ class CodexDriver {
|
|
|
53005
53303
|
return this.codexHomeRoot;
|
|
53006
53304
|
}
|
|
53007
53305
|
async probe(command, includeModels = true) {
|
|
53008
|
-
const
|
|
53009
|
-
if (
|
|
53010
|
-
return
|
|
53306
|
+
const result2 = await probeCliRuntime("codex", {}, command);
|
|
53307
|
+
if (result2.status !== "healthy")
|
|
53308
|
+
return result2;
|
|
53011
53309
|
if (!includeModels)
|
|
53012
|
-
return
|
|
53310
|
+
return result2;
|
|
53013
53311
|
return {
|
|
53014
|
-
...
|
|
53312
|
+
...result2,
|
|
53015
53313
|
reasoning: await this.probeReasoningCatalog(command)
|
|
53016
53314
|
};
|
|
53017
53315
|
}
|
|
@@ -53099,13 +53397,13 @@ class CodexDriver {
|
|
|
53099
53397
|
return;
|
|
53100
53398
|
if (message2.error || !message2.result || typeof message2.result !== "object")
|
|
53101
53399
|
return finish();
|
|
53102
|
-
const
|
|
53103
|
-
for (const model of Array.isArray(
|
|
53400
|
+
const result2 = message2.result;
|
|
53401
|
+
for (const model of Array.isArray(result2.data) ? result2.data : []) {
|
|
53104
53402
|
consumeModel(model);
|
|
53105
53403
|
if (models.length >= MODEL_LIST_MAX)
|
|
53106
53404
|
break;
|
|
53107
53405
|
}
|
|
53108
|
-
const cursor = typeof
|
|
53406
|
+
const cursor = typeof result2.nextCursor === "string" ? result2.nextCursor : undefined;
|
|
53109
53407
|
if (cursor && models.length < MODEL_LIST_MAX)
|
|
53110
53408
|
return requestModelPage(cursor);
|
|
53111
53409
|
if (models.length === 0)
|
|
@@ -53464,19 +53762,19 @@ async function probeCursorAcpCatalog(command, options = {}) {
|
|
|
53464
53762
|
request("session/new", { cwd, mcpServers: [] });
|
|
53465
53763
|
return;
|
|
53466
53764
|
}
|
|
53467
|
-
const
|
|
53468
|
-
if (!
|
|
53765
|
+
const result2 = record3(message2.result);
|
|
53766
|
+
if (!result2)
|
|
53469
53767
|
return finish();
|
|
53470
53768
|
if (expectedMethod === "initialize") {
|
|
53471
|
-
const authMethods = Array.isArray(
|
|
53472
|
-
if (
|
|
53769
|
+
const authMethods = Array.isArray(result2.authMethods) ? result2.authMethods : [];
|
|
53770
|
+
if (result2.protocolVersion !== ACP_PROTOCOL_VERSION2 || !authMethods.some((method) => record3(method)?.id === AUTH_METHOD_ID))
|
|
53473
53771
|
return finish();
|
|
53474
53772
|
request("authenticate", { methodId: AUTH_METHOD_ID });
|
|
53475
53773
|
return;
|
|
53476
53774
|
}
|
|
53477
|
-
if (expectedMethod !== "session/new" || typeof
|
|
53775
|
+
if (expectedMethod !== "session/new" || typeof result2.sessionId !== "string" || !result2.sessionId.trim())
|
|
53478
53776
|
return finish();
|
|
53479
|
-
finish(parseCursorAcpModelCatalog(
|
|
53777
|
+
finish(parseCursorAcpModelCatalog(result2));
|
|
53480
53778
|
};
|
|
53481
53779
|
const timer = setTimeout(() => finish(), options.timeoutMs ?? CATALOG_PROBE_TIMEOUT_MS);
|
|
53482
53780
|
timer.unref?.();
|
|
@@ -53817,8 +54115,8 @@ class CursorAcpLane {
|
|
|
53817
54115
|
completePrompt(prompt, value) {
|
|
53818
54116
|
if (this.currentPromptRequestId !== prompt.requestId)
|
|
53819
54117
|
return;
|
|
53820
|
-
const
|
|
53821
|
-
if (!
|
|
54118
|
+
const result2 = record4(value);
|
|
54119
|
+
if (!result2 || typeof result2.stopReason !== "string" || !PROMPT_STOP_REASONS2.has(result2.stopReason)) {
|
|
53822
54120
|
this.failPrompt(prompt, new Error("Cursor ACP prompt response did not contain a supported stopReason"), "cursor.invalid_stop_reason");
|
|
53823
54121
|
return;
|
|
53824
54122
|
}
|
|
@@ -53830,7 +54128,7 @@ class CursorAcpLane {
|
|
|
53830
54128
|
kind: "turn_end",
|
|
53831
54129
|
sessionId: this.sessionId ?? undefined,
|
|
53832
54130
|
turnOwner: terminalOwner,
|
|
53833
|
-
...
|
|
54131
|
+
...result2.stopReason === "cancelled" ? { outcome: "interrupted" } : {}
|
|
53834
54132
|
});
|
|
53835
54133
|
}
|
|
53836
54134
|
failPrompt(prompt, error62, code = "cursor.prompt_failed") {
|
|
@@ -54192,20 +54490,20 @@ function runBoundedDiscoveryProcess(options) {
|
|
|
54192
54490
|
let settled = false;
|
|
54193
54491
|
let decoderEnded = false;
|
|
54194
54492
|
let outputBytes = 0;
|
|
54195
|
-
const settle2 = (
|
|
54493
|
+
const settle2 = (result2, error62) => {
|
|
54196
54494
|
if (settled)
|
|
54197
54495
|
return;
|
|
54198
54496
|
settled = true;
|
|
54199
54497
|
clearTimeout(timer);
|
|
54200
54498
|
if (!decoderEnded)
|
|
54201
54499
|
decoder.end();
|
|
54202
|
-
Promise.resolve().then(() => options.cleanup?.(options.process) ?? cleanupProcess(options.process, options.label)).then(() => error62 ? reject(error62) : resolve3(
|
|
54500
|
+
Promise.resolve().then(() => options.cleanup?.(options.process) ?? cleanupProcess(options.process, options.label)).then(() => error62 ? reject(error62) : resolve3(result2), () => reject(error62 ?? new Error(`${options.label} discovery cleanup failed`)));
|
|
54203
54501
|
};
|
|
54204
54502
|
const control = {
|
|
54205
54503
|
get outputBytes() {
|
|
54206
54504
|
return outputBytes;
|
|
54207
54505
|
},
|
|
54208
|
-
finish: (
|
|
54506
|
+
finish: (result2) => settle2(result2),
|
|
54209
54507
|
fail: (message2) => settle2(undefined, new Error(message2)),
|
|
54210
54508
|
flushStdout: () => {
|
|
54211
54509
|
if (settled || decoderEnded)
|
|
@@ -54282,19 +54580,19 @@ async function discoverCursorRecentContext(request, dependencies = {}) {
|
|
|
54282
54580
|
return;
|
|
54283
54581
|
if (message2.error !== undefined)
|
|
54284
54582
|
return control.fail("Cursor discovery request failed");
|
|
54285
|
-
const
|
|
54286
|
-
if (!
|
|
54583
|
+
const result2 = asRecord(message2.result);
|
|
54584
|
+
if (!result2)
|
|
54287
54585
|
return control.fail("Cursor discovery returned an invalid response");
|
|
54288
54586
|
if (expectedMethod === "initialize") {
|
|
54289
|
-
if (
|
|
54587
|
+
if (result2.protocolVersion !== ACP_PROTOCOL_VERSION4) {
|
|
54290
54588
|
return control.fail("Cursor discovery protocol is incompatible");
|
|
54291
54589
|
}
|
|
54292
|
-
const capabilities = asRecord(
|
|
54590
|
+
const capabilities = asRecord(result2.agentCapabilities);
|
|
54293
54591
|
const sessionCapabilities = asRecord(capabilities?.sessionCapabilities);
|
|
54294
54592
|
if (sessionCapabilities?.list !== true && !asRecord(sessionCapabilities?.list)) {
|
|
54295
54593
|
return control.fail("Cursor session listing is unavailable");
|
|
54296
54594
|
}
|
|
54297
|
-
const authMethods = Array.isArray(
|
|
54595
|
+
const authMethods = Array.isArray(result2.authMethods) ? result2.authMethods : [];
|
|
54298
54596
|
if (!authMethods.some((method) => asRecord(method)?.id === AUTH_METHOD_ID3)) {
|
|
54299
54597
|
return control.fail("Cursor discovery authentication is unavailable");
|
|
54300
54598
|
}
|
|
@@ -54307,7 +54605,7 @@ async function discoverCursorRecentContext(request, dependencies = {}) {
|
|
|
54307
54605
|
}
|
|
54308
54606
|
if (expectedMethod !== "session/list")
|
|
54309
54607
|
return control.fail("Cursor discovery state is invalid");
|
|
54310
|
-
const sessions = Array.isArray(
|
|
54608
|
+
const sessions = Array.isArray(result2.sessions) ? result2.sessions : Array.isArray(result2.data) ? result2.data : [];
|
|
54311
54609
|
for (const value of sessions) {
|
|
54312
54610
|
const session2 = asRecord(value);
|
|
54313
54611
|
if (!session2)
|
|
@@ -54316,7 +54614,7 @@ async function discoverCursorRecentContext(request, dependencies = {}) {
|
|
|
54316
54614
|
if (collector.satisfied)
|
|
54317
54615
|
return control.finish(collector.result());
|
|
54318
54616
|
}
|
|
54319
|
-
const nextCursor = typeof
|
|
54617
|
+
const nextCursor = typeof result2.nextCursor === "string" && result2.nextCursor ? result2.nextCursor : undefined;
|
|
54320
54618
|
if (!nextCursor)
|
|
54321
54619
|
return control.finish(collector.result());
|
|
54322
54620
|
if (seenCursors.has(nextCursor))
|
|
@@ -54376,11 +54674,11 @@ class CursorDriver {
|
|
|
54376
54674
|
this.catalogProbe = catalogProbe;
|
|
54377
54675
|
}
|
|
54378
54676
|
async probe(command, includeModels = true) {
|
|
54379
|
-
const
|
|
54380
|
-
if (
|
|
54381
|
-
return
|
|
54677
|
+
const result2 = probeCliRuntime("cursor-agent", {}, command);
|
|
54678
|
+
if (result2.status !== "healthy")
|
|
54679
|
+
return result2;
|
|
54382
54680
|
if (!includeModels)
|
|
54383
|
-
return
|
|
54681
|
+
return result2;
|
|
54384
54682
|
let reasoning;
|
|
54385
54683
|
try {
|
|
54386
54684
|
reasoning = await this.catalogProbe(command);
|
|
@@ -54388,7 +54686,7 @@ class CursorDriver {
|
|
|
54388
54686
|
reasoning = undefined;
|
|
54389
54687
|
}
|
|
54390
54688
|
return {
|
|
54391
|
-
...
|
|
54689
|
+
...result2,
|
|
54392
54690
|
reasoning
|
|
54393
54691
|
};
|
|
54394
54692
|
}
|
|
@@ -54483,8 +54781,8 @@ function parseGrokModelCatalog(value) {
|
|
|
54483
54781
|
models
|
|
54484
54782
|
};
|
|
54485
54783
|
}
|
|
54486
|
-
function catalogFromInitialize(
|
|
54487
|
-
const meta3 = asRecord(
|
|
54784
|
+
function catalogFromInitialize(result2) {
|
|
54785
|
+
const meta3 = asRecord(result2._meta) ?? asRecord(result2.meta);
|
|
54488
54786
|
return parseGrokModelCatalog(meta3?.modelState);
|
|
54489
54787
|
}
|
|
54490
54788
|
async function cleanupProbeProcess2(process2) {
|
|
@@ -54561,15 +54859,15 @@ async function probeGrokAcpCatalog(command, options = {}) {
|
|
|
54561
54859
|
if (!("result" in message2)) {
|
|
54562
54860
|
return finish({ status: "unhealthy", lastError: "grok_acp_invalid_response" });
|
|
54563
54861
|
}
|
|
54564
|
-
const
|
|
54862
|
+
const result2 = asRecord(message2.result) ?? {};
|
|
54565
54863
|
if (expectedId === 1) {
|
|
54566
|
-
const capabilities = asRecord(
|
|
54567
|
-
const methods = Array.isArray(
|
|
54864
|
+
const capabilities = asRecord(result2.agentCapabilities);
|
|
54865
|
+
const methods = Array.isArray(result2.authMethods) ? result2.authMethods : [];
|
|
54568
54866
|
const methodIds = methods.flatMap((method) => {
|
|
54569
54867
|
const id3 = asRecord(method)?.id;
|
|
54570
54868
|
return typeof id3 === "string" ? [id3] : [];
|
|
54571
54869
|
});
|
|
54572
|
-
if (
|
|
54870
|
+
if (result2.protocolVersion !== ACP_PROTOCOL_VERSION5) {
|
|
54573
54871
|
return finish({ status: "unhealthy", lastError: "grok_acp_protocol_incompatible" });
|
|
54574
54872
|
}
|
|
54575
54873
|
if (capabilities?.loadSession !== true) {
|
|
@@ -54583,7 +54881,7 @@ async function probeGrokAcpCatalog(command, options = {}) {
|
|
|
54583
54881
|
}
|
|
54584
54882
|
if (options.includeModels === false)
|
|
54585
54883
|
return finish({ status: "compatible" });
|
|
54586
|
-
catalog = catalogFromInitialize(
|
|
54884
|
+
catalog = catalogFromInitialize(result2) ?? catalog;
|
|
54587
54885
|
expectedId = 2;
|
|
54588
54886
|
write("authenticate", { methodId: AUTH_METHOD_ID4 }, expectedId);
|
|
54589
54887
|
return;
|
|
@@ -55061,13 +55359,13 @@ class GrokAcpLane {
|
|
|
55061
55359
|
completePrompt(prompt, value) {
|
|
55062
55360
|
if (this.currentPromptRequestId !== prompt.requestId)
|
|
55063
55361
|
return;
|
|
55064
|
-
const
|
|
55065
|
-
if (!
|
|
55362
|
+
const result2 = asRecord(value);
|
|
55363
|
+
if (!result2 || typeof result2.stopReason !== "string" || !PROMPT_STOP_REASONS3.has(result2.stopReason)) {
|
|
55066
55364
|
this.failPrompt(prompt, new Error("Grok ACP prompt response did not contain a supported stopReason"), "grok.invalid_stop_reason");
|
|
55067
55365
|
return;
|
|
55068
55366
|
}
|
|
55069
55367
|
const terminalOwner = this.terminalOwner ?? prompt.receipt;
|
|
55070
|
-
const meta3 = asRecord(
|
|
55368
|
+
const meta3 = asRecord(result2._meta) ?? asRecord(result2.meta);
|
|
55071
55369
|
const responseUsage = projectGrokUsage(this.usageProjector, this.sessionId ?? "unknown", prompt.providerPromptId, meta3?.usage);
|
|
55072
55370
|
const usage = responseUsage ?? projectGrokUsage(this.usageProjector, this.sessionId ?? "unknown", prompt.providerPromptId, prompt.fallbackUsage);
|
|
55073
55371
|
this.currentPromptRequestId = null;
|
|
@@ -55079,7 +55377,7 @@ class GrokAcpLane {
|
|
|
55079
55377
|
kind: "turn_end",
|
|
55080
55378
|
sessionId: this.sessionId ?? undefined,
|
|
55081
55379
|
turnOwner: terminalOwner,
|
|
55082
|
-
...
|
|
55380
|
+
...result2.stopReason === "cancelled" ? { outcome: "interrupted" } : {}
|
|
55083
55381
|
});
|
|
55084
55382
|
this.refreshBilling();
|
|
55085
55383
|
}
|
|
@@ -55406,15 +55704,15 @@ class GrokAcpLane {
|
|
|
55406
55704
|
return;
|
|
55407
55705
|
this.billingInFlight = true;
|
|
55408
55706
|
try {
|
|
55409
|
-
const
|
|
55707
|
+
const result2 = await this.call("_x.ai/billing", {});
|
|
55410
55708
|
if (this.requestedStopReason)
|
|
55411
55709
|
return;
|
|
55412
|
-
const payload = asRecord(
|
|
55710
|
+
const payload = asRecord(result2);
|
|
55413
55711
|
this.events.emit("runtime_event", {
|
|
55414
55712
|
kind: "telemetry",
|
|
55415
55713
|
name: "rate_limits",
|
|
55416
55714
|
source: "grok_billing",
|
|
55417
|
-
quota: normalizeGrokBilling(payload?.billing ??
|
|
55715
|
+
quota: normalizeGrokBilling(payload?.billing ?? result2, this.quotaSourceEpoch)
|
|
55418
55716
|
});
|
|
55419
55717
|
} catch (error62) {
|
|
55420
55718
|
if (this.requestedStopReason)
|
|
@@ -55498,19 +55796,19 @@ async function discoverGrokRecentContext(request, dependencies = {}) {
|
|
|
55498
55796
|
return;
|
|
55499
55797
|
if (message2.error !== undefined)
|
|
55500
55798
|
return control.fail("Grok discovery request failed");
|
|
55501
|
-
const
|
|
55502
|
-
if (!
|
|
55799
|
+
const result2 = asRecord(message2.result);
|
|
55800
|
+
if (!result2)
|
|
55503
55801
|
return control.fail("Grok discovery returned an invalid response");
|
|
55504
55802
|
if (expectedMethod === "initialize") {
|
|
55505
|
-
if (
|
|
55803
|
+
if (result2.protocolVersion !== ACP_PROTOCOL_VERSION7) {
|
|
55506
55804
|
return control.fail("Grok discovery protocol is incompatible");
|
|
55507
55805
|
}
|
|
55508
|
-
const capabilities = asRecord(
|
|
55806
|
+
const capabilities = asRecord(result2.agentCapabilities);
|
|
55509
55807
|
const sessionCapabilities = asRecord(capabilities?.sessionCapabilities);
|
|
55510
55808
|
if (sessionCapabilities?.list !== true && !asRecord(sessionCapabilities?.list)) {
|
|
55511
55809
|
return control.fail("Grok session listing is unavailable");
|
|
55512
55810
|
}
|
|
55513
|
-
const authMethods = Array.isArray(
|
|
55811
|
+
const authMethods = Array.isArray(result2.authMethods) ? result2.authMethods : [];
|
|
55514
55812
|
if (!authMethods.some((method) => asRecord(method)?.id === AUTH_METHOD_ID6)) {
|
|
55515
55813
|
return control.fail("Grok discovery authentication is unavailable");
|
|
55516
55814
|
}
|
|
@@ -55523,7 +55821,7 @@ async function discoverGrokRecentContext(request, dependencies = {}) {
|
|
|
55523
55821
|
}
|
|
55524
55822
|
if (expectedMethod !== "session/list")
|
|
55525
55823
|
return control.fail("Grok discovery state is invalid");
|
|
55526
|
-
const sessions = Array.isArray(
|
|
55824
|
+
const sessions = Array.isArray(result2.sessions) ? result2.sessions : Array.isArray(result2.data) ? result2.data : [];
|
|
55527
55825
|
for (const value of sessions) {
|
|
55528
55826
|
const session2 = asRecord(value);
|
|
55529
55827
|
if (!session2)
|
|
@@ -55532,7 +55830,7 @@ async function discoverGrokRecentContext(request, dependencies = {}) {
|
|
|
55532
55830
|
if (collector.satisfied)
|
|
55533
55831
|
return control.finish(collector.result());
|
|
55534
55832
|
}
|
|
55535
|
-
const nextCursor = typeof
|
|
55833
|
+
const nextCursor = typeof result2.nextCursor === "string" && result2.nextCursor ? result2.nextCursor : undefined;
|
|
55536
55834
|
if (!nextCursor)
|
|
55537
55835
|
return control.finish(collector.result());
|
|
55538
55836
|
if (seenCursors.has(nextCursor))
|
|
@@ -55594,9 +55892,9 @@ class GrokDriver {
|
|
|
55594
55892
|
this.spawnProcess = spawnProcess;
|
|
55595
55893
|
}
|
|
55596
55894
|
async probe(command, includeModels = true) {
|
|
55597
|
-
const
|
|
55598
|
-
if (
|
|
55599
|
-
return
|
|
55895
|
+
const result2 = probeCliRuntime("grok", {}, command);
|
|
55896
|
+
if (result2.status !== "healthy")
|
|
55897
|
+
return result2;
|
|
55600
55898
|
let acpProbe;
|
|
55601
55899
|
try {
|
|
55602
55900
|
acpProbe = includeModels ? await this.catalogProbe(command) : await this.catalogProbe(command, { includeModels: false });
|
|
@@ -55604,9 +55902,9 @@ class GrokDriver {
|
|
|
55604
55902
|
acpProbe = { status: "unhealthy", lastError: "grok_acp_probe_failed" };
|
|
55605
55903
|
}
|
|
55606
55904
|
if (acpProbe.status === "unhealthy") {
|
|
55607
|
-
return { ...
|
|
55905
|
+
return { ...result2, status: "unhealthy", lastError: acpProbe.lastError };
|
|
55608
55906
|
}
|
|
55609
|
-
return { ...
|
|
55907
|
+
return { ...result2, reasoning: acpProbe.reasoning };
|
|
55610
55908
|
}
|
|
55611
55909
|
async openLane(ctx, options) {
|
|
55612
55910
|
return new GrokAcpLane(this, ctx, { onRawStdoutLine: options?.onRawStdoutLine });
|
|
@@ -57393,27 +57691,27 @@ class OpenCodeDriver {
|
|
|
57393
57691
|
discoverRecentContext(request) {
|
|
57394
57692
|
if (request.recentProjectsTopK === 0)
|
|
57395
57693
|
return discoverOpenCodeRecentContext(request);
|
|
57396
|
-
const
|
|
57397
|
-
if (
|
|
57694
|
+
const result2 = this.versionProbe("opencode", {}, request.command);
|
|
57695
|
+
if (result2.status !== "healthy")
|
|
57398
57696
|
throw new Error("Installed OpenCode CLI could not report its version");
|
|
57399
|
-
return discoverOpenCodeRecentContext(request, { compatibility: resolveOpenCodeCompatibility(
|
|
57697
|
+
return discoverOpenCodeRecentContext(request, { compatibility: resolveOpenCodeCompatibility(result2.version) });
|
|
57400
57698
|
}
|
|
57401
57699
|
probe(command, includeModels = true) {
|
|
57402
|
-
const
|
|
57403
|
-
if (
|
|
57404
|
-
return
|
|
57700
|
+
const result2 = this.versionProbe("opencode", {}, command);
|
|
57701
|
+
if (result2.status !== "healthy")
|
|
57702
|
+
return result2;
|
|
57405
57703
|
let compatibility;
|
|
57406
57704
|
try {
|
|
57407
|
-
compatibility = resolveOpenCodeCompatibility(
|
|
57705
|
+
compatibility = resolveOpenCodeCompatibility(result2.version);
|
|
57408
57706
|
} catch {
|
|
57409
|
-
return { ...
|
|
57707
|
+
return { ...result2, status: "unhealthy", lastError: "unsupported_opencode_cli_version" };
|
|
57410
57708
|
}
|
|
57411
57709
|
if (!includeModels)
|
|
57412
|
-
return
|
|
57710
|
+
return result2;
|
|
57413
57711
|
const spec = resolveSpawnSpec("opencode", [...compatibility.modelArgs], command);
|
|
57414
57712
|
const output2 = this.outputProbe(spec.command, spec.args);
|
|
57415
57713
|
return {
|
|
57416
|
-
...
|
|
57714
|
+
...result2,
|
|
57417
57715
|
reasoning: output2.ok ? parseOpenCodeModelCatalog(output2.output) : undefined
|
|
57418
57716
|
};
|
|
57419
57717
|
}
|
|
@@ -57422,10 +57720,10 @@ class OpenCodeDriver {
|
|
|
57422
57720
|
}
|
|
57423
57721
|
async openLane(ctx, options) {
|
|
57424
57722
|
const command = resolveLaunchFieldsOrDefault(ctx.config.runtimeConfig).command;
|
|
57425
|
-
const
|
|
57426
|
-
if (
|
|
57723
|
+
const result2 = this.versionProbe("opencode", {}, command);
|
|
57724
|
+
if (result2.status !== "healthy")
|
|
57427
57725
|
throw new Error("Installed OpenCode CLI could not report its version");
|
|
57428
|
-
const compatibility = resolveOpenCodeCompatibility(
|
|
57726
|
+
const compatibility = resolveOpenCodeCompatibility(result2.version);
|
|
57429
57727
|
const factory = {
|
|
57430
57728
|
spawnService: (launch, port, password) => this.spawnService(launch, port, password, compatibility)
|
|
57431
57729
|
};
|
|
@@ -58295,8 +58593,8 @@ function ensureSymlinks(workDir, canonical = CANONICAL_FILE, aliases = SYMLINK_A
|
|
|
58295
58593
|
continue;
|
|
58296
58594
|
const aliasPath = join11(workDir, alias2);
|
|
58297
58595
|
try {
|
|
58298
|
-
const
|
|
58299
|
-
if (
|
|
58596
|
+
const stat3 = lstatSync(aliasPath);
|
|
58597
|
+
if (stat3.isSymbolicLink()) {
|
|
58300
58598
|
const target2 = readlinkSync(aliasPath);
|
|
58301
58599
|
if (target2 === canonical)
|
|
58302
58600
|
continue;
|
|
@@ -58540,8 +58838,8 @@ class LogicalAgentSession {
|
|
|
58540
58838
|
};
|
|
58541
58839
|
}
|
|
58542
58840
|
});
|
|
58543
|
-
this.settingsUpdateTail = operation.then((
|
|
58544
|
-
if (
|
|
58841
|
+
this.settingsUpdateTail = operation.then((result2) => {
|
|
58842
|
+
if (result2.status === "applied") {
|
|
58545
58843
|
this.settingsUpdatePending = false;
|
|
58546
58844
|
return;
|
|
58547
58845
|
}
|
|
@@ -59532,17 +59830,17 @@ class LogicalAgentSession {
|
|
|
59532
59830
|
status: "failed",
|
|
59533
59831
|
error: driverError("internal", "host_release_failed", String(error62))
|
|
59534
59832
|
}));
|
|
59535
|
-
const
|
|
59833
|
+
const result2 = await Promise.race([release, timeout]);
|
|
59536
59834
|
release.catch(() => {});
|
|
59537
|
-
if (
|
|
59835
|
+
if (result2.status === "failed" || result2.status === "timed_out") {
|
|
59538
59836
|
this.emit({
|
|
59539
59837
|
type: "diagnostic",
|
|
59540
59838
|
severity: "error",
|
|
59541
59839
|
source: "host",
|
|
59542
|
-
message:
|
|
59840
|
+
message: result2.error.message
|
|
59543
59841
|
});
|
|
59544
59842
|
}
|
|
59545
|
-
return
|
|
59843
|
+
return result2;
|
|
59546
59844
|
} finally {
|
|
59547
59845
|
if (timer)
|
|
59548
59846
|
clearTimeout(timer);
|
|
@@ -59573,12 +59871,12 @@ class LogicalAgentSession {
|
|
|
59573
59871
|
this.interruptedTurnId = undefined;
|
|
59574
59872
|
}
|
|
59575
59873
|
const cleanup = await this.cleanupResource(releaseReason);
|
|
59576
|
-
const
|
|
59577
|
-
this.terminalResult =
|
|
59874
|
+
const result2 = buildResult(cleanup);
|
|
59875
|
+
this.terminalResult = result2;
|
|
59578
59876
|
this.state = "closed";
|
|
59579
|
-
this.emit({ type: "session_closed", result });
|
|
59877
|
+
this.emit({ type: "session_closed", result: result2 });
|
|
59580
59878
|
this.eventQueue.close();
|
|
59581
|
-
this.resolveClosed(
|
|
59879
|
+
this.resolveClosed(result2);
|
|
59582
59880
|
this.finishing = false;
|
|
59583
59881
|
})();
|
|
59584
59882
|
}
|
|
@@ -59620,14 +59918,14 @@ class LogicalAgentSession {
|
|
|
59620
59918
|
mode,
|
|
59621
59919
|
sessionId: this.backendSessionId ?? this.launch.resumeSessionId,
|
|
59622
59920
|
terminalOwner: mode === "idle" ? this.activeTurn?.terminalOwner : undefined
|
|
59623
|
-
}).then((
|
|
59624
|
-
if (!
|
|
59625
|
-
if (
|
|
59626
|
-
throw new StructuredLaneAdmissionError("runtime_busy",
|
|
59921
|
+
}).then((result2) => {
|
|
59922
|
+
if (!result2.ok) {
|
|
59923
|
+
if (result2.reason === "runtime_busy") {
|
|
59924
|
+
throw new StructuredLaneAdmissionError("runtime_busy", result2.error ?? result2.reason);
|
|
59627
59925
|
}
|
|
59628
|
-
throw new Error(
|
|
59926
|
+
throw new Error(result2.error ?? result2.reason);
|
|
59629
59927
|
}
|
|
59630
|
-
return
|
|
59928
|
+
return result2;
|
|
59631
59929
|
});
|
|
59632
59930
|
}
|
|
59633
59931
|
stopLane(reason, forceAfterMs) {
|
|
@@ -59764,25 +60062,25 @@ function createAgentDriverSdkWithRegistry(options) {
|
|
|
59764
60062
|
const adapter = registration.createAdapter();
|
|
59765
60063
|
assertAdapterCompatibility(String(registration.id), registration.capabilities, adapter);
|
|
59766
60064
|
const command = capabilities2.commandOverride ? input2.command : undefined;
|
|
59767
|
-
const
|
|
59768
|
-
if (
|
|
60065
|
+
const result2 = input2.includeModels === false ? await adapter.probe(command, false) : await adapter.probe(command);
|
|
60066
|
+
if (result2.status === "healthy") {
|
|
59769
60067
|
return {
|
|
59770
60068
|
status: "healthy",
|
|
59771
|
-
version:
|
|
60069
|
+
version: result2.version,
|
|
59772
60070
|
capabilities: capabilities2,
|
|
59773
|
-
reasoning:
|
|
60071
|
+
reasoning: result2.reasoning && adapter.modelCatalogOrigin ? { ...result2.reasoning, catalogOrigin: adapter.modelCatalogOrigin } : result2.reasoning
|
|
59774
60072
|
};
|
|
59775
60073
|
}
|
|
59776
60074
|
return {
|
|
59777
60075
|
status: "unhealthy",
|
|
59778
60076
|
error: {
|
|
59779
60077
|
category: "runtime_unavailable",
|
|
59780
|
-
code: stableErrorCode(
|
|
60078
|
+
code: stableErrorCode(result2.lastError, "probe_failed"),
|
|
59781
60079
|
message: `Backend ${input2.backend} is unavailable`,
|
|
59782
60080
|
retryable: true
|
|
59783
60081
|
},
|
|
59784
60082
|
capabilities: capabilities2,
|
|
59785
|
-
reasoning:
|
|
60083
|
+
reasoning: result2.reasoning && adapter.modelCatalogOrigin ? { ...result2.reasoning, catalogOrigin: adapter.modelCatalogOrigin } : result2.reasoning
|
|
59786
60084
|
};
|
|
59787
60085
|
} catch (error62) {
|
|
59788
60086
|
const contractInvalid = error62 instanceof Error && (error62.message.startsWith("Adapter ") || error62.message.startsWith("Agent backend registration "));
|
|
@@ -60072,7 +60370,7 @@ import { homedir as homedir14 } from "os";
|
|
|
60072
60370
|
// src/pii/store.ts
|
|
60073
60371
|
import { chmodSync, existsSync as existsSync7, mkdirSync as mkdirSync6, readFileSync as readFileSync7, renameSync as renameSync3, rmSync as rmSync2, statSync as statSync2, writeFileSync as writeFileSync5 } from "node:fs";
|
|
60074
60372
|
import { join as join13 } from "node:path";
|
|
60075
|
-
import { randomUUID as
|
|
60373
|
+
import { randomUUID as randomUUID9 } from "node:crypto";
|
|
60076
60374
|
|
|
60077
60375
|
// src/pii/id-numbers.ts
|
|
60078
60376
|
var ID_NUMBERS_SOURCE = String.raw`export default (text: string) => {
|
|
@@ -61543,7 +61841,7 @@ class PiiStore {
|
|
|
61543
61841
|
}
|
|
61544
61842
|
save(botId, pipeline) {
|
|
61545
61843
|
const directory = this.directoryFor(botId);
|
|
61546
|
-
const temporary = join13(directory, `.${
|
|
61844
|
+
const temporary = join13(directory, `.${randomUUID9()}.tmp`);
|
|
61547
61845
|
try {
|
|
61548
61846
|
mkdirSync6(directory, { recursive: true, mode: 448 });
|
|
61549
61847
|
chmodSync(directory, 448);
|
|
@@ -61574,7 +61872,7 @@ class PiiStore {
|
|
|
61574
61872
|
const pipeline = { ...current, plugins: [...current.plugins] };
|
|
61575
61873
|
if (pipeline.plugins.length >= PII_MAX_PLUGINS)
|
|
61576
61874
|
throw new PiiError("PII_PLUGIN_LIMIT");
|
|
61577
|
-
pipeline.plugins.push({ id:
|
|
61875
|
+
pipeline.plugins.push({ id: randomUUID9(), name: input2.name, description: input2.description, enabled: true, source: input2.source });
|
|
61578
61876
|
pipeline.revision++;
|
|
61579
61877
|
this.save(botId, pipeline);
|
|
61580
61878
|
return this.snapshot(pipeline);
|
|
@@ -61627,14 +61925,14 @@ class PiiStore {
|
|
|
61627
61925
|
return this.filterPipelineWithResult(pipeline, text2);
|
|
61628
61926
|
}
|
|
61629
61927
|
async filterPipelineWithResult(pipeline, text2) {
|
|
61630
|
-
const
|
|
61631
|
-
return { text:
|
|
61928
|
+
const result2 = await this.runWithResult(pipeline, text2);
|
|
61929
|
+
return { text: result2.text, triggeredFilters: result2.triggers.filter((trigger) => trigger.triggered).map((trigger) => {
|
|
61632
61930
|
const plugin = pipeline.plugins.find((plugin2) => plugin2.id === trigger.pluginId);
|
|
61633
61931
|
return { id: plugin.id, name: plugin.name };
|
|
61634
61932
|
}) };
|
|
61635
61933
|
}
|
|
61636
61934
|
run(pipeline, text2) {
|
|
61637
|
-
return this.runWithResult(pipeline, text2).then((
|
|
61935
|
+
return this.runWithResult(pipeline, text2).then((result2) => result2.text);
|
|
61638
61936
|
}
|
|
61639
61937
|
runWithResult(pipeline, text2) {
|
|
61640
61938
|
let plugins = this.compiled.get(pipeline);
|
|
@@ -61679,8 +61977,8 @@ function createRotatingFileSink(path15, maxBytes, opts = {}) {
|
|
|
61679
61977
|
if (!existsSync8(filePath))
|
|
61680
61978
|
return true;
|
|
61681
61979
|
try {
|
|
61682
|
-
const
|
|
61683
|
-
if (!
|
|
61980
|
+
const stat3 = lstatSync2(filePath);
|
|
61981
|
+
if (!stat3.isFile()) {
|
|
61684
61982
|
if (opts.mode === undefined && !opts.hardMaxBytes)
|
|
61685
61983
|
return true;
|
|
61686
61984
|
report("unsafe_generation", new Error("log generation is not a regular file"));
|
|
@@ -61688,7 +61986,7 @@ function createRotatingFileSink(path15, maxBytes, opts = {}) {
|
|
|
61688
61986
|
}
|
|
61689
61987
|
if (opts.mode !== undefined)
|
|
61690
61988
|
chmodSync2(filePath, opts.mode);
|
|
61691
|
-
if (opts.hardMaxBytes && maxBytes > 0 &&
|
|
61989
|
+
if (opts.hardMaxBytes && maxBytes > 0 && stat3.size > maxBytes) {
|
|
61692
61990
|
try {
|
|
61693
61991
|
unlinkSync3(filePath);
|
|
61694
61992
|
} catch (error62) {
|
|
@@ -61760,10 +62058,10 @@ function createRotatingFileSink(path15, maxBytes, opts = {}) {
|
|
|
61760
62058
|
const noFollow = "O_NOFOLLOW" in constants ? constants.O_NOFOLLOW : 0;
|
|
61761
62059
|
const fd = openSync(candidate, constants.O_RDONLY | noFollow);
|
|
61762
62060
|
try {
|
|
61763
|
-
const
|
|
61764
|
-
if (!
|
|
62061
|
+
const stat3 = fstatSync(fd);
|
|
62062
|
+
if (!stat3.isFile())
|
|
61765
62063
|
throw new Error("snapshot source is not a regular file");
|
|
61766
|
-
files.push({ path: candidate, fd, size:
|
|
62064
|
+
files.push({ path: candidate, fd, size: stat3.size });
|
|
61767
62065
|
} catch (error62) {
|
|
61768
62066
|
closeSync(fd);
|
|
61769
62067
|
throw error62;
|
|
@@ -62461,10 +62759,10 @@ class WsControlChannel {
|
|
|
62461
62759
|
const pending = [];
|
|
62462
62760
|
for (const cb of this.commandCbs) {
|
|
62463
62761
|
try {
|
|
62464
|
-
const
|
|
62465
|
-
if (
|
|
62762
|
+
const result2 = cb(cmd);
|
|
62763
|
+
if (result2 === WS_CONTROL_COMMAND_CONSUMED)
|
|
62466
62764
|
break;
|
|
62467
|
-
pending.push(Promise.resolve(
|
|
62765
|
+
pending.push(Promise.resolve(result2).catch((err) => {
|
|
62468
62766
|
this.log.warn("command listener threw", { type: cmd.type, err: describeErr(err) });
|
|
62469
62767
|
}));
|
|
62470
62768
|
} catch (err) {
|
|
@@ -62484,7 +62782,7 @@ class WsControlChannel {
|
|
|
62484
62782
|
return;
|
|
62485
62783
|
}
|
|
62486
62784
|
if (cmd.type === "agent:wake") {
|
|
62487
|
-
const
|
|
62785
|
+
const result2 = await this.wakeCoordinator.run(cmd, (accepted) => this.dispatchListeners(accepted), (advanced) => {
|
|
62488
62786
|
for (const cb of this.wakeDesiredCbs) {
|
|
62489
62787
|
try {
|
|
62490
62788
|
cb(advanced);
|
|
@@ -62493,7 +62791,7 @@ class WsControlChannel {
|
|
|
62493
62791
|
}
|
|
62494
62792
|
}
|
|
62495
62793
|
});
|
|
62496
|
-
if (
|
|
62794
|
+
if (result2.state === "suppressed") {
|
|
62497
62795
|
await this.reportWakeAck({
|
|
62498
62796
|
agentId: cmd.agentId,
|
|
62499
62797
|
launchId: cmd.launchId,
|
|
@@ -62503,7 +62801,7 @@ class WsControlChannel {
|
|
|
62503
62801
|
agentId: cmd.agentId,
|
|
62504
62802
|
channel: cmd.unreadNotice.channel,
|
|
62505
62803
|
latestSeq: cmd.unreadNotice.latestSeq,
|
|
62506
|
-
coveredSeq:
|
|
62804
|
+
coveredSeq: result2.coveredSeq
|
|
62507
62805
|
});
|
|
62508
62806
|
}
|
|
62509
62807
|
return;
|
|
@@ -62863,7 +63161,8 @@ async function startCredentialProxy(broker, options = {}) {
|
|
|
62863
63161
|
}
|
|
62864
63162
|
};
|
|
62865
63163
|
const server = http.createServer(async (req, res) => {
|
|
62866
|
-
const
|
|
63164
|
+
const requestUrl = new URL2(req.url ?? "/", "http://placeholder");
|
|
63165
|
+
const pathname = requestUrl.pathname;
|
|
62867
63166
|
if (pathname === LOCAL_PII_PATH && (req.method === "GET" || req.method === "POST")) {
|
|
62868
63167
|
const localVerdict = broker.check(req.headers["authorization"], req.method === "GET" ? "read" : "send");
|
|
62869
63168
|
if (!localVerdict.ok) {
|
|
@@ -63096,7 +63395,8 @@ async function startCredentialProxy(broker, options = {}) {
|
|
|
63096
63395
|
res.writeHead(502, { "content-type": "application/json" });
|
|
63097
63396
|
res.end(JSON.stringify({ error: `upstream error: ${err.message}`, code: "upstream_error" }));
|
|
63098
63397
|
});
|
|
63099
|
-
const
|
|
63398
|
+
const waitingForModels = req.method === "POST" && /^\/api\/community\/machines\/[^/]+\/discover-models$/.test(pathname) && requestUrl.searchParams.get("wait") === "1";
|
|
63399
|
+
const upstreamTimeoutMs = options.upstreamTimeoutMs ?? (waitingForModels ? 55000 : DEFAULT_UPSTREAM_TIMEOUT_MS);
|
|
63100
63400
|
upstreamReq.setTimeout(upstreamTimeoutMs, () => {
|
|
63101
63401
|
upstreamReq.destroy();
|
|
63102
63402
|
upstreamRes?.destroy();
|
|
@@ -63817,10 +64117,11 @@ var MEMORY_MAINTENANCE_PROMPT = `The daemon is preparing to reset this idle sess
|
|
|
63817
64117
|
2. Facts: Verify claims, especially work progress, against the latest original records. Search the context timeline and task discussions through their latest outcomes. Correct outdated or unsupported claims; keep uncertainty explicit.
|
|
63818
64118
|
3. Learn: Use .context_timeline to find channels and threads you recently participated in. Read the full history of each recent discussion, from the initial request through the work, intermediate corrections, and any final decisions. Understand the sequence of events and why the user corrected the approach before learning first principles. Proactively record the user's guidance on communication, collaboration, and how to do work. Distill it into first principles: the underlying goals, reasons, and constraints that make the guidance reusable. Preserve its scope and source links; distinguish explicit user instructions from your own inferences. Update or remove superseded notes.
|
|
63819
64119
|
4. Durability: Keep only lasting facts, preferences, and reusable lessons or procedures. Remove task status, milestones, temporary plans, and diaries; extract a reusable lesson only when useful. Keep memory.md brief with links; put procedures, scope, and reasons in experiences. Reason from first principles: distill specific events into underlying causes, constraints, and reusable principles. Omit incidental dates and details; retain context only when it changes the principle’s validity or scope.
|
|
64120
|
+
5. Follow up: After completing the memory review and any needed edits, run \`$ALOOK_CLI message mark list\` and check each unfinished item's latest discussion. In the item's original channel, thread, or DM, send the relevant person a brief reminder of the remaining work and the next action needed. Skip items that are already complete or cancelled. Do not wait for replies.
|
|
63820
64121
|
|
|
63821
|
-
Edit only your own memory files. This review is internal maintenance; perform it silently. Do not proactively send the owner, users, or channels progress updates, completion notices, or details about your memory state. Communicate task-relevant results, questions, and blockers normally. If nothing needs a user-facing response, send no message.
|
|
64122
|
+
Edit only your own memory files. This review is internal maintenance; perform it silently. Do not proactively send the owner, users, or channels progress updates, completion notices, or details about your memory state. The task reminders in step 5 are separate from memory-maintenance updates. Communicate task-relevant results, questions, and blockers normally. If nothing needs a user-facing response, send no message.
|
|
63822
64123
|
|
|
63823
|
-
If new work arrives, handle it first and defer nap. Otherwise, after completing the review
|
|
64124
|
+
If new work arrives, handle it first and defer nap. Otherwise, after completing the review, any needed edits, and the task reminders, your final action is to run the following command without --handoff. Do not finish with only a written reply. This instruction authorizes that nap:
|
|
63824
64125
|
|
|
63825
64126
|
$ALOOK_CLI nap`;
|
|
63826
64127
|
// src/runtimeConfig.ts
|
|
@@ -63832,7 +64133,7 @@ function runtimeModelName(config2) {
|
|
|
63832
64133
|
}
|
|
63833
64134
|
// agent-driver/dist/adapters/antigravity/quota.js
|
|
63834
64135
|
import { createHash as createHash5, randomBytes as randomBytes6 } from "node:crypto";
|
|
63835
|
-
import { readFile } from "node:fs/promises";
|
|
64136
|
+
import { readFile as readFile2 } from "node:fs/promises";
|
|
63836
64137
|
import { homedir as homedir11 } from "node:os";
|
|
63837
64138
|
import { isAbsolute, join as join15 } from "node:path";
|
|
63838
64139
|
var PROD = "https://cloudcode-pa.googleapis.com";
|
|
@@ -63842,8 +64143,8 @@ function text2(value) {
|
|
|
63842
64143
|
return typeof value === "string" && value.trim() ? value.trim() : undefined;
|
|
63843
64144
|
}
|
|
63844
64145
|
function label(value) {
|
|
63845
|
-
const
|
|
63846
|
-
return
|
|
64146
|
+
const result2 = text2(value);
|
|
64147
|
+
return result2 && Buffer.byteLength(result2) <= 64 ? result2 : undefined;
|
|
63847
64148
|
}
|
|
63848
64149
|
function parseAntigravityQuota(value) {
|
|
63849
64150
|
const body = asRecord(value);
|
|
@@ -63908,7 +64209,7 @@ async function readAntigravityQuota(options = {}) {
|
|
|
63908
64209
|
const home = options.home ?? homedir11();
|
|
63909
64210
|
const configuredHome = env.GEMINI_HOME?.replace(/^~(?=[/\\]|$)/, home);
|
|
63910
64211
|
const root = configuredHome ? isAbsolute(configuredHome) ? configuredHome : join15(process.cwd(), configuredHome) : join15(home, ".gemini");
|
|
63911
|
-
const read = options.readCredentialsFile ?? ((path16) =>
|
|
64212
|
+
const read = options.readCredentialsFile ?? ((path16) => readFile2(path16, "utf8"));
|
|
63912
64213
|
let credentials = null;
|
|
63913
64214
|
let authType;
|
|
63914
64215
|
let storageUnavailable = false;
|
|
@@ -64026,7 +64327,7 @@ async function readAntigravityQuota(options = {}) {
|
|
|
64026
64327
|
|
|
64027
64328
|
// agent-driver/dist/provider-quota.js
|
|
64028
64329
|
import { execFile } from "node:child_process";
|
|
64029
|
-
import { readFile as
|
|
64330
|
+
import { readFile as readFile3 } from "node:fs/promises";
|
|
64030
64331
|
import { homedir as homedir12 } from "node:os";
|
|
64031
64332
|
import { join as join16 } from "node:path";
|
|
64032
64333
|
import { promisify } from "node:util";
|
|
@@ -64058,7 +64359,7 @@ async function claudeCredentials(options) {
|
|
|
64058
64359
|
const env = options.env ?? process.env;
|
|
64059
64360
|
const root = env.CLAUDE_CONFIG_DIR || join16(options.home ?? homedir12(), ".claude");
|
|
64060
64361
|
try {
|
|
64061
|
-
const value = options.readCredentialsFile ? await options.readCredentialsFile(join16(root, ".credentials.json")) : await
|
|
64362
|
+
const value = options.readCredentialsFile ? await options.readCredentialsFile(join16(root, ".credentials.json")) : await readFile3(join16(root, ".credentials.json"), "utf8");
|
|
64062
64363
|
return parseCredentials(value);
|
|
64063
64364
|
} catch {
|
|
64064
64365
|
return null;
|
|
@@ -64256,7 +64557,7 @@ function cliCommandsSection() {
|
|
|
64256
64557
|
"",
|
|
64257
64558
|
`1. \`${CLI} platform machine --list\` — list your owner's machines.`,
|
|
64258
64559
|
`2. \`${CLI} platform machine --backends --id <machine-id>\` — read the selected online machine's backends.`,
|
|
64259
|
-
`3. \`${CLI} platform machine --models --id <machine-id> --backend <backend-id> [--model <full-model-id>] [--refresh]\` — read
|
|
64560
|
+
`3. \`${CLI} platform machine --models --id <machine-id> --backend <backend-id> [--model <full-model-id>] [--refresh]\` — read models and model-specific effort options using a five-minute server cache. A cache miss or expiry fetches fresh models and waits for the result; \`--refresh\` bypasses the cache. Failures do not return an old list. Do not poll.`,
|
|
64260
64561
|
`4. \`${CLI} platform bot --list\` — list your owner's bots.`,
|
|
64261
64562
|
`5. \`${CLI} platform bot --create '<bot-json>'\` — request new bots for your owner. Each JSON requires \`name\`, \`machineId\`, \`backendId\` and \`reason\`; optional fields are \`description\`, \`model\` and \`reasoningEffort\`. ` + `Use an online machine and its backend. The \`reason\` explains to your owner why the bot is needed and what work it will do; this text appears on the approval card. Repeat \`--create\` for up to 20 bots in one request. ` + `The command submits one approval card to the DM between you and your owner. It creates no bots until your human owner approves the request.`,
|
|
64262
64563
|
"",
|
|
@@ -64590,7 +64891,7 @@ function toLocalISO(iso) {
|
|
|
64590
64891
|
}
|
|
64591
64892
|
|
|
64592
64893
|
// src/manager/managerRuntime.ts
|
|
64593
|
-
import { randomUUID as
|
|
64894
|
+
import { randomUUID as randomUUID10 } from "node:crypto";
|
|
64594
64895
|
var SESSION_STOP_GRACE_MS2 = 2000;
|
|
64595
64896
|
function normalizeTerminationCause(value) {
|
|
64596
64897
|
return value === "runtime_error" || value === "killed_stalled" ? value : "other";
|
|
@@ -64830,7 +65131,7 @@ class AgentProcessManager {
|
|
|
64830
65131
|
shuttingDown = false;
|
|
64831
65132
|
shutdownPromise;
|
|
64832
65133
|
publishedAgentActivity = new Map;
|
|
64833
|
-
traceProcessNonce =
|
|
65134
|
+
traceProcessNonce = randomUUID10();
|
|
64834
65135
|
nextSpawnOrdinal = 1;
|
|
64835
65136
|
nextDaemonTurnOrdinal = 1;
|
|
64836
65137
|
nextDeliveryOrdinal = 1;
|
|
@@ -64947,10 +65248,10 @@ class AgentProcessManager {
|
|
|
64947
65248
|
return desiredRevision === appliedRevision ? "idempotent" : "stale";
|
|
64948
65249
|
}
|
|
64949
65250
|
const canApplyNatively = applied && this.runtimeLaunchTuple(applied) === this.runtimeLaunchTuple(desired) && typeof session2.updateSettings === "function";
|
|
64950
|
-
let
|
|
65251
|
+
let result2 = { status: "unsupported" };
|
|
64951
65252
|
if (canApplyNatively) {
|
|
64952
65253
|
try {
|
|
64953
|
-
|
|
65254
|
+
result2 = await session2.updateSettings({
|
|
64954
65255
|
reasoningEffort: desired.reasoningEffort ?? null
|
|
64955
65256
|
});
|
|
64956
65257
|
} catch (error62) {
|
|
@@ -64964,12 +65265,12 @@ class AgentProcessManager {
|
|
|
64964
65265
|
return "saved_for_start";
|
|
64965
65266
|
}
|
|
64966
65267
|
}
|
|
64967
|
-
if (
|
|
65268
|
+
if (result2.status !== "applied") {
|
|
64968
65269
|
this.log.warn("runtime config live apply unavailable; restarting at safe boundary", {
|
|
64969
65270
|
agentId,
|
|
64970
65271
|
revision: desiredRevision,
|
|
64971
|
-
status:
|
|
64972
|
-
code:
|
|
65272
|
+
status: result2.status,
|
|
65273
|
+
code: result2.error?.code
|
|
64973
65274
|
});
|
|
64974
65275
|
if (restartOnFailure)
|
|
64975
65276
|
await this.restartForRuntimeConfig(agentId, session2);
|
|
@@ -65139,13 +65440,13 @@ class AgentProcessManager {
|
|
|
65139
65440
|
const session2 = this.sessions.get(agentId);
|
|
65140
65441
|
if (!session2)
|
|
65141
65442
|
return;
|
|
65142
|
-
const
|
|
65143
|
-
if (
|
|
65443
|
+
const result2 = await session2.interrupt({ requestId: randomUUID10(), reason: "owner_request" });
|
|
65444
|
+
if (result2.status !== "accepted")
|
|
65144
65445
|
return;
|
|
65145
65446
|
this.log.info("agent turn interrupt accepted", {
|
|
65146
65447
|
agentId,
|
|
65147
65448
|
sessionInstanceId: session2.sessionInstanceId,
|
|
65148
|
-
turnId:
|
|
65449
|
+
turnId: result2.turnId
|
|
65149
65450
|
});
|
|
65150
65451
|
try {
|
|
65151
65452
|
this.opts.onBotAuditEvent?.(agentId, { kind: "turn_interrupt", payload: { status: "accepted" } }, this.auditContext(agentId));
|
|
@@ -65176,7 +65477,7 @@ class AgentProcessManager {
|
|
|
65176
65477
|
]));
|
|
65177
65478
|
this.sessions.clear();
|
|
65178
65479
|
this.sessionLifecycles.clear();
|
|
65179
|
-
failures.push(...[...factories, ...completed].filter((
|
|
65480
|
+
failures.push(...[...factories, ...completed].filter((result2) => result2.status === "rejected").map((result2) => result2.reason));
|
|
65180
65481
|
if (failures.length)
|
|
65181
65482
|
throw new AggregateError(failures, "Agent shutdown did not complete cleanly");
|
|
65182
65483
|
});
|
|
@@ -65725,7 +66026,7 @@ ${this.opts.wakePromptFooter}` : text3;
|
|
|
65725
66026
|
if (!agent2 || agent2.sessionId !== effect.sessionId || agent2.resetting || agent2.idleSince === null)
|
|
65726
66027
|
break;
|
|
65727
66028
|
this.deliver(effect.agentId, {
|
|
65728
|
-
id: `${effect.agentId}:memory-maintenance:${
|
|
66029
|
+
id: `${effect.agentId}:memory-maintenance:${randomUUID10()}`,
|
|
65729
66030
|
text: MEMORY_MAINTENANCE_PROMPT
|
|
65730
66031
|
});
|
|
65731
66032
|
break;
|
|
@@ -65866,7 +66167,7 @@ ${this.opts.wakePromptFooter}` : text3;
|
|
|
65866
66167
|
this.opts.onRuntimeSpawnFailed?.(driver.id, reason);
|
|
65867
66168
|
this.emitErrorAudit(agentId, options?.scope ?? "spawn", reason, options?.message ?? `Launch failed (${reason})`);
|
|
65868
66169
|
};
|
|
65869
|
-
const teardown = (
|
|
66170
|
+
const teardown = (result2) => {
|
|
65870
66171
|
clearHandshakeTimer();
|
|
65871
66172
|
if (state.torndown)
|
|
65872
66173
|
return;
|
|
@@ -65877,18 +66178,18 @@ ${this.opts.wakePromptFooter}` : text3;
|
|
|
65877
66178
|
this.closeTurn(state, state.activeSpan, { event: "turn_abort", abortCause: "physical_exit" });
|
|
65878
66179
|
return;
|
|
65879
66180
|
}
|
|
65880
|
-
const failedStart =
|
|
66181
|
+
const failedStart = result2.outcome === "failed_to_start";
|
|
65881
66182
|
if (failedStart)
|
|
65882
|
-
reportSpawnFailure(
|
|
66183
|
+
reportSpawnFailure(result2.error.code || "failed_to_start");
|
|
65883
66184
|
if (!state.hasEstablished && !failedStart)
|
|
65884
66185
|
reportSpawnFailure("pre_handshake_exit");
|
|
65885
66186
|
this.closeTurn(state, state.activeSpan, {
|
|
65886
66187
|
event: "turn_abort",
|
|
65887
66188
|
abortCause: failedStart ? "spawn_failure" : "physical_exit"
|
|
65888
66189
|
});
|
|
65889
|
-
const exitCode = "exitCode" in
|
|
65890
|
-
const exitSignal = "signal" in
|
|
65891
|
-
const requested = "requested" in
|
|
66190
|
+
const exitCode = "exitCode" in result2 ? result2.exitCode ?? null : null;
|
|
66191
|
+
const exitSignal = "signal" in result2 ? result2.signal ?? null : null;
|
|
66192
|
+
const requested = "requested" in result2 && result2.requested === true;
|
|
65892
66193
|
const abnormal = !requested && (exitSignal !== null || exitCode !== null && exitCode !== 0);
|
|
65893
66194
|
if (state.hasEstablished && !state.suppressExitLog) {
|
|
65894
66195
|
this.logSessionEnded(agentId, "exit");
|
|
@@ -65973,7 +66274,7 @@ ${this.opts.wakePromptFooter}` : text3;
|
|
|
65973
66274
|
const done = Promise.allSettled([closed, eventsDone]).then(([closedResult, eventsResult]) => {
|
|
65974
66275
|
if (closedResult.status === "fulfilled")
|
|
65975
66276
|
teardown(closedResult.value);
|
|
65976
|
-
const failures = [closedResult, eventsResult].filter((
|
|
66277
|
+
const failures = [closedResult, eventsResult].filter((result2) => result2.status === "rejected").map((result2) => result2.reason);
|
|
65977
66278
|
if (closedResult.status === "fulfilled" && (closedResult.value.cleanup.status === "failed" || closedResult.value.cleanup.status === "timed_out")) {
|
|
65978
66279
|
failures.push(closedResult.value.cleanup.error);
|
|
65979
66280
|
}
|
|
@@ -66333,11 +66634,11 @@ ${this.opts.wakePromptFooter}` : text3;
|
|
|
66333
66634
|
turnId: event.turnId
|
|
66334
66635
|
};
|
|
66335
66636
|
if (this.pendingRuntimeConfigUpdates.has(agentId) && this.sessions.get(agentId) === owner.session) {
|
|
66336
|
-
this.convergeRuntimeConfig(agentId, false).then((
|
|
66337
|
-
if (
|
|
66637
|
+
this.convergeRuntimeConfig(agentId, false).then((result2) => {
|
|
66638
|
+
if (result2 === "saved_for_start" && owner.session)
|
|
66338
66639
|
this.markResetting(agentId);
|
|
66339
66640
|
this.dispatch(completionEvent, owner);
|
|
66340
|
-
if (
|
|
66641
|
+
if (result2 === "saved_for_start" && owner.session) {
|
|
66341
66642
|
this.restartForRuntimeConfig(agentId, owner.session);
|
|
66342
66643
|
}
|
|
66343
66644
|
}).catch((error62) => {
|
|
@@ -66778,11 +67079,11 @@ class AgentRouter {
|
|
|
66778
67079
|
revision: cmd.config.runtimeConfigRevision ?? 0
|
|
66779
67080
|
});
|
|
66780
67081
|
try {
|
|
66781
|
-
const
|
|
67082
|
+
const result2 = await this.opts.manager.updateRuntimeConfig(cmd.agentId, cmd.config);
|
|
66782
67083
|
this.log.info("agent:runtime_config_update accepted", {
|
|
66783
67084
|
agentId: cmd.agentId,
|
|
66784
67085
|
revision: cmd.config.runtimeConfigRevision ?? 0,
|
|
66785
|
-
result
|
|
67086
|
+
result: result2
|
|
66786
67087
|
});
|
|
66787
67088
|
} catch (err) {
|
|
66788
67089
|
this.log.warn("agent:runtime_config_update rejected", {
|
|
@@ -66971,11 +67272,11 @@ function timelineRowHash(line) {
|
|
|
66971
67272
|
}
|
|
66972
67273
|
function timelineFileGeneration(filePath, lines) {
|
|
66973
67274
|
try {
|
|
66974
|
-
const
|
|
66975
|
-
if (!
|
|
67275
|
+
const stat3 = fs9.lstatSync(filePath, { bigint: true });
|
|
67276
|
+
if (!stat3.isFile())
|
|
66976
67277
|
return null;
|
|
66977
67278
|
const digest = createHash6("sha256");
|
|
66978
|
-
digest.update(`${
|
|
67279
|
+
digest.update(`${stat3.dev}:${stat3.ino}:${stat3.size}:${stat3.mtimeNs}:${stat3.ctimeNs}
|
|
66979
67280
|
`);
|
|
66980
67281
|
for (const line of lines)
|
|
66981
67282
|
digest.update(line.text, "utf8").update(`
|
|
@@ -67075,8 +67376,8 @@ function scanTimelineFile(filePath) {
|
|
|
67075
67376
|
let fd = null;
|
|
67076
67377
|
try {
|
|
67077
67378
|
fd = fs9.openSync(filePath, fs9.constants.O_RDONLY | (fs9.constants.O_NOFOLLOW ?? 0));
|
|
67078
|
-
const
|
|
67079
|
-
if (!
|
|
67379
|
+
const stat3 = fs9.fstatSync(fd);
|
|
67380
|
+
if (!stat3.isFile())
|
|
67080
67381
|
return null;
|
|
67081
67382
|
const chunk2 = Buffer.allocUnsafe(TIMELINE_READ_CHUNK_BYTES);
|
|
67082
67383
|
const newest = [];
|
|
@@ -67089,9 +67390,9 @@ function scanTimelineFile(filePath) {
|
|
|
67089
67390
|
let oversized = false;
|
|
67090
67391
|
let stop = false;
|
|
67091
67392
|
let discardIncompleteTail = false;
|
|
67092
|
-
if (
|
|
67393
|
+
if (stat3.size > 0) {
|
|
67093
67394
|
const last = Buffer.allocUnsafe(1);
|
|
67094
|
-
fs9.readSync(fd, last, 0, 1,
|
|
67395
|
+
fs9.readSync(fd, last, 0, 1, stat3.size - 1);
|
|
67095
67396
|
discardIncompleteTail = last[0] !== 10;
|
|
67096
67397
|
}
|
|
67097
67398
|
const resetPhysicalLine = () => {
|
|
@@ -67150,7 +67451,7 @@ function scanTimelineFile(filePath) {
|
|
|
67150
67451
|
}
|
|
67151
67452
|
resetPhysicalLine();
|
|
67152
67453
|
};
|
|
67153
|
-
let position =
|
|
67454
|
+
let position = stat3.size;
|
|
67154
67455
|
while (position > 0 && !stop) {
|
|
67155
67456
|
const start = Math.max(0, position - chunk2.length);
|
|
67156
67457
|
const requested = position - start;
|
|
@@ -67302,11 +67603,11 @@ function readResumeControlState(timelineDir) {
|
|
|
67302
67603
|
let fd = null;
|
|
67303
67604
|
try {
|
|
67304
67605
|
fd = fs9.openSync(filePath, fs9.constants.O_RDONLY | (fs9.constants.O_NOFOLLOW ?? 0));
|
|
67305
|
-
const
|
|
67306
|
-
if (!
|
|
67606
|
+
const stat3 = fs9.fstatSync(fd);
|
|
67607
|
+
if (!stat3.isFile() || stat3.size <= 0 || stat3.size > RESUME_CONTROL_MAX_BYTES) {
|
|
67307
67608
|
return { kind: "invalid" };
|
|
67308
67609
|
}
|
|
67309
|
-
const bounded = Buffer.allocUnsafe(
|
|
67610
|
+
const bounded = Buffer.allocUnsafe(stat3.size + 1);
|
|
67310
67611
|
let bytesRead = 0;
|
|
67311
67612
|
while (bytesRead < bounded.length) {
|
|
67312
67613
|
const count2 = fs9.readSync(fd, bounded, bytesRead, bounded.length - bytesRead, bytesRead);
|
|
@@ -67314,7 +67615,7 @@ function readResumeControlState(timelineDir) {
|
|
|
67314
67615
|
break;
|
|
67315
67616
|
bytesRead += count2;
|
|
67316
67617
|
}
|
|
67317
|
-
if (bytesRead !==
|
|
67618
|
+
if (bytesRead !== stat3.size)
|
|
67318
67619
|
return { kind: "invalid" };
|
|
67319
67620
|
const raw = bounded.subarray(0, bytesRead).toString("utf8");
|
|
67320
67621
|
const value = JSON.parse(raw);
|
|
@@ -67756,20 +68057,20 @@ function createTimelineRecorder(opts) {
|
|
|
67756
68057
|
}
|
|
67757
68058
|
}
|
|
67758
68059
|
};
|
|
67759
|
-
const handleTrackedResult = (agentId, state,
|
|
67760
|
-
if (
|
|
67761
|
-
applyRewrite(agentId,
|
|
67762
|
-
if (state &&
|
|
67763
|
-
state.handle =
|
|
68060
|
+
const handleTrackedResult = (agentId, state, result2) => {
|
|
68061
|
+
if (result2.status === "written") {
|
|
68062
|
+
applyRewrite(agentId, result2.rewrite);
|
|
68063
|
+
if (state && result2.handle) {
|
|
68064
|
+
state.handle = result2.handle;
|
|
67764
68065
|
state.rowFenced = false;
|
|
67765
68066
|
}
|
|
67766
68067
|
return "written";
|
|
67767
68068
|
}
|
|
67768
|
-
if (
|
|
68069
|
+
if (result2.reason === "lock" || result2.reason === "write")
|
|
67769
68070
|
return "retryable";
|
|
67770
|
-
if (state &&
|
|
68071
|
+
if (state && result2.reason !== "oversized")
|
|
67771
68072
|
state.rowFenced = true;
|
|
67772
|
-
diagnostic(agentId, "timeline_exact_write_rejected",
|
|
68073
|
+
diagnostic(agentId, "timeline_exact_write_rejected", result2.reason);
|
|
67773
68074
|
return "terminal";
|
|
67774
68075
|
};
|
|
67775
68076
|
const tryCommit = (agentId, state) => {
|
|
@@ -67781,11 +68082,11 @@ function createTimelineRecorder(opts) {
|
|
|
67781
68082
|
return "terminal";
|
|
67782
68083
|
}
|
|
67783
68084
|
if (state.handle) {
|
|
67784
|
-
const
|
|
68085
|
+
const result3 = updateTrackedEntry(dir, state.handle, (entry2) => {
|
|
67785
68086
|
const fitted2 = fitResponsesToRow(entry2, state.responses);
|
|
67786
68087
|
return { ...entry2, agent_responses: fitted2 ?? [...entry2.agent_responses, ...state.responses] };
|
|
67787
68088
|
});
|
|
67788
|
-
return handleTrackedResult(agentId, state,
|
|
68089
|
+
return handleTrackedResult(agentId, state, result3);
|
|
67789
68090
|
}
|
|
67790
68091
|
if (state.rowFenced || state.pendingMode === "handle")
|
|
67791
68092
|
return "terminal";
|
|
@@ -67802,8 +68103,8 @@ function createTimelineRecorder(opts) {
|
|
|
67802
68103
|
return "terminal";
|
|
67803
68104
|
}
|
|
67804
68105
|
entry.agent_responses = fitted;
|
|
67805
|
-
const
|
|
67806
|
-
return handleTrackedResult(agentId, state,
|
|
68106
|
+
const result2 = appendTrackedEntry(dir, entry, now());
|
|
68107
|
+
return handleTrackedResult(agentId, state, result2);
|
|
67807
68108
|
};
|
|
67808
68109
|
const deleteState = (agentId, key) => {
|
|
67809
68110
|
const states = statesFor(agentId);
|
|
@@ -67830,13 +68131,13 @@ function createTimelineRecorder(opts) {
|
|
|
67830
68131
|
deleteState(agentId, key);
|
|
67831
68132
|
continue;
|
|
67832
68133
|
}
|
|
67833
|
-
const
|
|
67834
|
-
if (
|
|
68134
|
+
const result2 = tryCommit(agentId, state);
|
|
68135
|
+
if (result2 === "written") {
|
|
67835
68136
|
state.responses = [];
|
|
67836
68137
|
state.pendingSinceMs = undefined;
|
|
67837
68138
|
state.pendingMode = undefined;
|
|
67838
68139
|
state.completedAtMs = nowMs;
|
|
67839
|
-
} else if (
|
|
68140
|
+
} else if (result2 === "terminal") {
|
|
67840
68141
|
deleteState(agentId, key);
|
|
67841
68142
|
}
|
|
67842
68143
|
}
|
|
@@ -67864,12 +68165,12 @@ function createTimelineRecorder(opts) {
|
|
|
67864
68165
|
const dir = dirFor(agentId);
|
|
67865
68166
|
if (!prepareTimelineDirectory(dir))
|
|
67866
68167
|
return;
|
|
67867
|
-
const
|
|
68168
|
+
const result2 = appendTrackedEntry(dir, createTimelineEntry({
|
|
67868
68169
|
messages,
|
|
67869
68170
|
sessionId: sessionByAgent.get(agentId) ?? null,
|
|
67870
68171
|
provider: opts.providerFor?.(agentId) ?? null
|
|
67871
68172
|
}), now());
|
|
67872
|
-
handleTrackedResult(agentId, null,
|
|
68173
|
+
handleTrackedResult(agentId, null, result2);
|
|
67873
68174
|
};
|
|
67874
68175
|
return {
|
|
67875
68176
|
barrierGeneration(agentId) {
|
|
@@ -67913,16 +68214,16 @@ function createTimelineRecorder(opts) {
|
|
|
67913
68214
|
if (!prepareTimelineDirectory(dir))
|
|
67914
68215
|
return;
|
|
67915
68216
|
const stamp = now();
|
|
67916
|
-
let
|
|
68217
|
+
let result2;
|
|
67917
68218
|
if (state.handle && (state.handle.filename === filenameForDate(stamp) || state.owner.barrierGeneration !== currentBarrier(agentId))) {
|
|
67918
|
-
|
|
68219
|
+
result2 = updateTrackedEntry(dir, state.handle, (entry) => ({
|
|
67919
68220
|
...entry,
|
|
67920
68221
|
messages: [...entry.messages, ...messages],
|
|
67921
68222
|
session_id: state.backendSessionId,
|
|
67922
68223
|
provider: state.provider
|
|
67923
68224
|
}));
|
|
67924
68225
|
} else if (state.owner.barrierGeneration === currentBarrier(agentId)) {
|
|
67925
|
-
|
|
68226
|
+
result2 = appendTrackedEntry(dir, createTimelineEntry({
|
|
67926
68227
|
messages,
|
|
67927
68228
|
sessionId: state.backendSessionId,
|
|
67928
68229
|
provider: state.provider
|
|
@@ -67931,7 +68232,7 @@ function createTimelineRecorder(opts) {
|
|
|
67931
68232
|
appendOwnerless(agentId, messages);
|
|
67932
68233
|
return;
|
|
67933
68234
|
}
|
|
67934
|
-
handleTrackedResult(agentId, state,
|
|
68235
|
+
handleTrackedResult(agentId, state, result2);
|
|
67935
68236
|
},
|
|
67936
68237
|
recordAssistantMessage(agentId, owner, text3, truncated = false) {
|
|
67937
68238
|
retryPending(agentId);
|
|
@@ -67964,11 +68265,11 @@ function createTimelineRecorder(opts) {
|
|
|
67964
68265
|
deleteState(agentId, key);
|
|
67965
68266
|
return;
|
|
67966
68267
|
}
|
|
67967
|
-
const
|
|
67968
|
-
if (
|
|
68268
|
+
const result2 = tryCommit(agentId, state);
|
|
68269
|
+
if (result2 === "written") {
|
|
67969
68270
|
state.responses = [];
|
|
67970
68271
|
state.completedAtMs = now().getTime();
|
|
67971
|
-
} else if (
|
|
68272
|
+
} else if (result2 === "terminal") {
|
|
67972
68273
|
deleteState(agentId, key);
|
|
67973
68274
|
} else {
|
|
67974
68275
|
retainPending(agentId, key, state);
|
|
@@ -68064,8 +68365,8 @@ function createTimelineRecorder(opts) {
|
|
|
68064
68365
|
}
|
|
68065
68366
|
}
|
|
68066
68367
|
}
|
|
68067
|
-
const
|
|
68068
|
-
handleTrackedResult(agentId, null,
|
|
68368
|
+
const result2 = appendTrackedEntry(dir, createSystemEntry(barrierType, stamp.toISOString(), forgottenSessionId), stamp);
|
|
68369
|
+
handleTrackedResult(agentId, null, result2);
|
|
68069
68370
|
return true;
|
|
68070
68371
|
},
|
|
68071
68372
|
pendingIdleResetEvents(agentId) {
|
|
@@ -68095,8 +68396,8 @@ function createTimelineRecorder(opts) {
|
|
|
68095
68396
|
}));
|
|
68096
68397
|
if (!persisted)
|
|
68097
68398
|
return false;
|
|
68098
|
-
const
|
|
68099
|
-
handleTrackedResult(agentId, null,
|
|
68399
|
+
const result2 = appendTrackedEntry(dir, createSystemEntry(type, stamp.toISOString(), sessionId), stamp);
|
|
68400
|
+
handleTrackedResult(agentId, null, result2);
|
|
68100
68401
|
return true;
|
|
68101
68402
|
}
|
|
68102
68403
|
}
|
|
@@ -68249,7 +68550,7 @@ class MessageReminderScheduler {
|
|
|
68249
68550
|
}
|
|
68250
68551
|
|
|
68251
68552
|
// src/manager/agentDriverHost.ts
|
|
68252
|
-
import { randomUUID as
|
|
68553
|
+
import { randomUUID as randomUUID11 } from "node:crypto";
|
|
68253
68554
|
import { homedir as homedir13 } from "node:os";
|
|
68254
68555
|
import { join as join18 } from "node:path";
|
|
68255
68556
|
|
|
@@ -68405,12 +68706,12 @@ function createDaemonAgentDriverHost(ctx, onRawLine) {
|
|
|
68405
68706
|
onRawLine?.(event.text);
|
|
68406
68707
|
},
|
|
68407
68708
|
now: () => Date.now(),
|
|
68408
|
-
createId: () =>
|
|
68709
|
+
createId: () => randomUUID11()
|
|
68409
68710
|
};
|
|
68410
68711
|
}
|
|
68411
68712
|
|
|
68412
68713
|
// src/daemon/daemonSelfSleep.ts
|
|
68413
|
-
var DAEMON_SELF_SLEEP_TIMEOUT_MS =
|
|
68714
|
+
var DAEMON_SELF_SLEEP_TIMEOUT_MS = 7 * 24 * 60 * 60 * 1000;
|
|
68414
68715
|
var systemClock = {
|
|
68415
68716
|
setTimer: (callback, delayMs) => setTimeout(callback, delayMs),
|
|
68416
68717
|
clearTimer: (timer) => clearTimeout(timer)
|
|
@@ -68482,9 +68783,9 @@ class DaemonSelfSleepScheduler {
|
|
|
68482
68783
|
}
|
|
68483
68784
|
|
|
68484
68785
|
// src/telemetry/dailyTokenUsage.ts
|
|
68485
|
-
import { chmod, mkdir, open as open3, readFile as
|
|
68786
|
+
import { chmod, mkdir, open as open3, readFile as readFile4, rename, rm } from "node:fs/promises";
|
|
68486
68787
|
import { dirname as dirname6, join as join19 } from "node:path";
|
|
68487
|
-
import { randomUUID as
|
|
68788
|
+
import { randomUUID as randomUUID12 } from "node:crypto";
|
|
68488
68789
|
var TOKEN_USAGE_WINDOW_DAYS = 30;
|
|
68489
68790
|
var TOKEN_USAGE_RECOVERY_DAYS = 2;
|
|
68490
68791
|
var TOKEN_USAGE_RETENTION_DAYS = TOKEN_USAGE_WINDOW_DAYS + TOKEN_USAGE_RECOVERY_DAYS;
|
|
@@ -68631,7 +68932,7 @@ class DailyTokenUsageStore {
|
|
|
68631
68932
|
return this.usageWindow(botId).then((window2) => window2.snapshots);
|
|
68632
68933
|
}
|
|
68633
68934
|
usageWindow(botId) {
|
|
68634
|
-
let
|
|
68935
|
+
let result2 = [];
|
|
68635
68936
|
let usageDay = "";
|
|
68636
68937
|
let usageTimeZone = "";
|
|
68637
68938
|
return this.enqueue(async () => {
|
|
@@ -68644,28 +68945,28 @@ class DailyTokenUsageStore {
|
|
|
68644
68945
|
if (this.prune(at, timeZone))
|
|
68645
68946
|
await this.persist();
|
|
68646
68947
|
const oldestDay = oldestVisibleDay(usageDay);
|
|
68647
|
-
|
|
68948
|
+
result2 = (this.data.bots[botId] ?? []).filter((snapshot) => snapshot.day >= oldestDay && snapshot.day <= usageDay).map((snapshot) => structuredClone(snapshot));
|
|
68648
68949
|
}).then(() => ({
|
|
68649
68950
|
usageDay,
|
|
68650
68951
|
usageTimeZone,
|
|
68651
|
-
snapshots:
|
|
68952
|
+
snapshots: result2
|
|
68652
68953
|
}));
|
|
68653
68954
|
}
|
|
68654
68955
|
enqueue(operation) {
|
|
68655
|
-
const
|
|
68656
|
-
this.tail =
|
|
68956
|
+
const result2 = this.tail.then(operation, operation);
|
|
68957
|
+
this.tail = result2.then(() => {
|
|
68657
68958
|
return;
|
|
68658
68959
|
}, () => {
|
|
68659
68960
|
return;
|
|
68660
68961
|
});
|
|
68661
|
-
return
|
|
68962
|
+
return result2;
|
|
68662
68963
|
}
|
|
68663
68964
|
async load() {
|
|
68664
68965
|
if (this.loaded)
|
|
68665
68966
|
return;
|
|
68666
68967
|
let source;
|
|
68667
68968
|
try {
|
|
68668
|
-
source = await
|
|
68969
|
+
source = await readFile4(this.filePath, "utf8");
|
|
68669
68970
|
} catch (error62) {
|
|
68670
68971
|
if (!error62 || typeof error62 !== "object" || !("code" in error62) || error62.code !== "ENOENT") {
|
|
68671
68972
|
throw error62;
|
|
@@ -68733,7 +69034,7 @@ class DailyTokenUsageStore {
|
|
|
68733
69034
|
async persist() {
|
|
68734
69035
|
const directory = dirname6(this.filePath);
|
|
68735
69036
|
await mkdir(directory, { recursive: true, mode: 448 });
|
|
68736
|
-
const temporary = `${this.filePath}.${
|
|
69037
|
+
const temporary = `${this.filePath}.${randomUUID12()}.tmp`;
|
|
68737
69038
|
try {
|
|
68738
69039
|
const file2 = await open3(temporary, "wx", 384);
|
|
68739
69040
|
try {
|
|
@@ -68763,33 +69064,33 @@ var RECENT_CONTEXT_HEADING = "## Recent local context";
|
|
|
68763
69064
|
function code(value) {
|
|
68764
69065
|
return `\`${value.replaceAll("`", "\\`")}\``;
|
|
68765
69066
|
}
|
|
68766
|
-
function appendRecentContextToPrompt(prompt,
|
|
69067
|
+
function appendRecentContextToPrompt(prompt, result2) {
|
|
68767
69068
|
const lines = [
|
|
68768
69069
|
prompt,
|
|
68769
69070
|
"",
|
|
68770
69071
|
RECENT_CONTEXT_HEADING,
|
|
68771
69072
|
""
|
|
68772
69073
|
];
|
|
68773
|
-
if (!
|
|
69074
|
+
if (!result2.ok) {
|
|
68774
69075
|
lines.push("Recent sessions and projects could not be discovered on this machine. " + "Continue onboarding without inventing context; ask the owner what they want to start with.");
|
|
68775
69076
|
return lines.join(`
|
|
68776
69077
|
`);
|
|
68777
69078
|
}
|
|
68778
69079
|
lines.push("Use these local pointers to understand what the owner has actually been working on before suggesting next actions. " + "Inspect only what is relevant, and do not paste private file paths or unrelated content into Alook.", "Do not read every session in full. For a session you inspect, read the beginning to understand what the user wanted, " + "then read the end to see the result. Read the middle selectively only when it helps resolve a relevant question.", "", "### Recent sessions", "");
|
|
68779
|
-
if (
|
|
69080
|
+
if (result2.sessionFiles.capability === "unavailable") {
|
|
68780
69081
|
lines.push("This runtime does not expose discoverable session files.");
|
|
68781
|
-
} else if (
|
|
69082
|
+
} else if (result2.sessionFiles.items.length === 0) {
|
|
68782
69083
|
lines.push("No recent session files were found.");
|
|
68783
69084
|
} else {
|
|
68784
|
-
for (const item of
|
|
69085
|
+
for (const item of result2.sessionFiles.items) {
|
|
68785
69086
|
lines.push(`- ${code(item.sessionFilePath)} — project ${code(item.projectPath)}; updated ${item.modifiedAt}`);
|
|
68786
69087
|
}
|
|
68787
69088
|
}
|
|
68788
69089
|
lines.push("", "### Recent projects", "");
|
|
68789
|
-
if (
|
|
69090
|
+
if (result2.recentProjects.length === 0) {
|
|
68790
69091
|
lines.push("No recent projects were found.");
|
|
68791
69092
|
} else {
|
|
68792
|
-
for (const item of
|
|
69093
|
+
for (const item of result2.recentProjects) {
|
|
68793
69094
|
lines.push(`- ${code(item.projectPath)} — updated ${item.modifiedAt}`);
|
|
68794
69095
|
}
|
|
68795
69096
|
}
|
|
@@ -68800,16 +69101,16 @@ function createRecentContextPromptAppender(discover, recentSessionFilesTopK = 20
|
|
|
68800
69101
|
return async (prompt, runtimeConfig) => {
|
|
68801
69102
|
const selected = toAgentBackendSelection(runtimeConfig);
|
|
68802
69103
|
const command = selected.config.command;
|
|
68803
|
-
let
|
|
69104
|
+
let result2;
|
|
68804
69105
|
try {
|
|
68805
|
-
|
|
69106
|
+
result2 = await discover({
|
|
68806
69107
|
backend: selected.backend,
|
|
68807
69108
|
recentSessionFilesTopK,
|
|
68808
69109
|
recentProjectsTopK,
|
|
68809
69110
|
...command ? { command } : {}
|
|
68810
69111
|
});
|
|
68811
69112
|
} catch {
|
|
68812
|
-
|
|
69113
|
+
result2 = {
|
|
68813
69114
|
ok: false,
|
|
68814
69115
|
error: {
|
|
68815
69116
|
category: "runtime_unavailable",
|
|
@@ -68819,7 +69120,7 @@ function createRecentContextPromptAppender(discover, recentSessionFilesTopK = 20
|
|
|
68819
69120
|
}
|
|
68820
69121
|
};
|
|
68821
69122
|
}
|
|
68822
|
-
return appendRecentContextToPrompt(prompt,
|
|
69123
|
+
return appendRecentContextToPrompt(prompt, result2);
|
|
68823
69124
|
};
|
|
68824
69125
|
}
|
|
68825
69126
|
|
|
@@ -69486,10 +69787,10 @@ async function createDaemon(opts) {
|
|
|
69486
69787
|
return Promise.resolve([]);
|
|
69487
69788
|
return trackTelemetry((async () => {
|
|
69488
69789
|
const results = await Promise.allSettled(manager.liveAgentActivities().map((info) => activityPayload(info)));
|
|
69489
|
-
const failed = results.find((
|
|
69790
|
+
const failed = results.find((result2) => result2.status === "rejected");
|
|
69490
69791
|
if (failed)
|
|
69491
69792
|
throw failed.reason;
|
|
69492
|
-
const activities = results.map((
|
|
69793
|
+
const activities = results.map((result2) => result2.value);
|
|
69493
69794
|
return stopping ? [] : activities.filter((activity) => manager.agentActivity(activity.agentId) === activity.state);
|
|
69494
69795
|
})());
|
|
69495
69796
|
},
|
|
@@ -69790,12 +70091,12 @@ async function readPinnedJsonFile(args) {
|
|
|
69790
70091
|
}
|
|
69791
70092
|
}
|
|
69792
70093
|
fd = openSync3(args.path, constants3.O_RDONLY | noFollow);
|
|
69793
|
-
const
|
|
69794
|
-
if (!
|
|
70094
|
+
const stat3 = fstatSync3(fd);
|
|
70095
|
+
if (!stat3.isFile())
|
|
69795
70096
|
return { value: null, warnings: ["source_unavailable"] };
|
|
69796
|
-
if (
|
|
70097
|
+
if (stat3.size > args.maxBytes)
|
|
69797
70098
|
return { value: null, warnings: ["line_too_long"] };
|
|
69798
|
-
const bytes = readPinnedBytes(fd,
|
|
70099
|
+
const bytes = readPinnedBytes(fd, stat3.size);
|
|
69799
70100
|
try {
|
|
69800
70101
|
return { value: JSON.parse(bytes.toString("utf8")), warnings: [] };
|
|
69801
70102
|
} catch {
|
|
@@ -70518,8 +70819,8 @@ function createDiagnosticReportCoordinator(args) {
|
|
|
70518
70819
|
const sidecarPath = (reportId) => join20(dir, `report-${reportId}.json`);
|
|
70519
70820
|
const ensureDir = () => {
|
|
70520
70821
|
if (existsSync9(dir)) {
|
|
70521
|
-
const
|
|
70522
|
-
if (!
|
|
70822
|
+
const stat3 = lstatSync5(dir);
|
|
70823
|
+
if (!stat3.isDirectory() || stat3.isSymbolicLink())
|
|
70523
70824
|
throw new CoordinatorError("local_artifact_invalid");
|
|
70524
70825
|
if (process.platform !== "win32")
|
|
70525
70826
|
chmodSync3(dir, 448);
|
|
@@ -70534,8 +70835,8 @@ function createDiagnosticReportCoordinator(args) {
|
|
|
70534
70835
|
};
|
|
70535
70836
|
const removeExact = (path16) => {
|
|
70536
70837
|
try {
|
|
70537
|
-
const
|
|
70538
|
-
if (
|
|
70838
|
+
const stat3 = lstatSync5(path16);
|
|
70839
|
+
if (stat3.isFile() && !stat3.isSymbolicLink())
|
|
70539
70840
|
unlinkSync6(path16);
|
|
70540
70841
|
} catch {}
|
|
70541
70842
|
};
|
|
@@ -70576,8 +70877,8 @@ function createDiagnosticReportCoordinator(args) {
|
|
|
70576
70877
|
const committedArchive = (reportId) => {
|
|
70577
70878
|
const path16 = archivePath(reportId);
|
|
70578
70879
|
try {
|
|
70579
|
-
const
|
|
70580
|
-
if (!
|
|
70880
|
+
const stat3 = lstatSync5(path16);
|
|
70881
|
+
if (!stat3.isFile() || stat3.isSymbolicLink())
|
|
70581
70882
|
return null;
|
|
70582
70883
|
const bytes = readFileSync9(path16);
|
|
70583
70884
|
return { sizeBytes: bytes.byteLength, sha256: createHash8("sha256").update(bytes).digest("hex") };
|
|
@@ -70605,8 +70906,8 @@ function createDiagnosticReportCoordinator(args) {
|
|
|
70605
70906
|
for (let attempt = 0;attempt < args.retry.maxAttemptsPerRound; attempt += 1) {
|
|
70606
70907
|
if (stopped)
|
|
70607
70908
|
throw new CoordinatorError("coordinator_shutdown");
|
|
70608
|
-
const
|
|
70609
|
-
if (
|
|
70909
|
+
const result2 = await args.transport.fail(reportId, failureCode);
|
|
70910
|
+
if (result2.kind === "terminal") {
|
|
70610
70911
|
if (options.cleanupArtifacts)
|
|
70611
70912
|
cleanup(reportId);
|
|
70612
70913
|
return { status: "failed", failureCode };
|
|
@@ -70640,11 +70941,11 @@ function createDiagnosticReportCoordinator(args) {
|
|
|
70640
70941
|
if (stopped)
|
|
70641
70942
|
throw new CoordinatorError("coordinator_shutdown");
|
|
70642
70943
|
checkpoint("before_upload");
|
|
70643
|
-
const
|
|
70944
|
+
const result2 = await args.transport.upload({ reportId: sidecar.reportId, sizeBytes: sidecar.sizeBytes, sha256: sidecar.sha256 }, createReadStream3(archivePath(sidecar.reportId)));
|
|
70644
70945
|
checkpoint("after_upload");
|
|
70645
|
-
if (
|
|
70946
|
+
if (result2.kind === "terminal") {
|
|
70646
70947
|
cleanup(sidecar.reportId);
|
|
70647
|
-
return { status:
|
|
70948
|
+
return { status: result2.status };
|
|
70648
70949
|
}
|
|
70649
70950
|
if (attempt + 1 < args.retry.maxAttemptsPerRound) {
|
|
70650
70951
|
const delay4 = Math.min(args.retry.maxDelayMs, args.retry.baseDelayMs * 2 ** attempt);
|
|
@@ -70706,8 +71007,8 @@ function createDiagnosticReportCoordinator(args) {
|
|
|
70706
71007
|
const readSidecar = (reportId) => {
|
|
70707
71008
|
const path16 = sidecarPath(reportId);
|
|
70708
71009
|
try {
|
|
70709
|
-
const
|
|
70710
|
-
if (!
|
|
71010
|
+
const stat3 = lstatSync5(path16);
|
|
71011
|
+
if (!stat3.isFile() || stat3.isSymbolicLink())
|
|
70711
71012
|
return null;
|
|
70712
71013
|
return parseSidecar(JSON.parse(readFileSync9(path16, "utf8")));
|
|
70713
71014
|
} catch {
|
|
@@ -70937,8 +71238,8 @@ function tuplesEqual(value, expected) {
|
|
|
70937
71238
|
}
|
|
70938
71239
|
function readIntent(baseDir, machineId) {
|
|
70939
71240
|
const filePath = intentPath(baseDir, machineId);
|
|
70940
|
-
const
|
|
70941
|
-
if (!
|
|
71241
|
+
const stat3 = fs10.lstatSync(filePath);
|
|
71242
|
+
if (!stat3.isFile())
|
|
70942
71243
|
throw new Error("unsafe daemon update intent type");
|
|
70943
71244
|
fs10.chmodSync(filePath, 384);
|
|
70944
71245
|
const value = JSON.parse(fs10.readFileSync(filePath, "utf8"));
|
|
@@ -71035,24 +71336,24 @@ function readTestPackageMap(baseDir, machineId) {
|
|
|
71035
71336
|
const filePath = updatePackageMapPath(baseDir, machineId);
|
|
71036
71337
|
if (!fs10.existsSync(filePath))
|
|
71037
71338
|
return null;
|
|
71038
|
-
const
|
|
71039
|
-
if (!
|
|
71339
|
+
const stat3 = fs10.lstatSync(filePath);
|
|
71340
|
+
if (!stat3.isFile())
|
|
71040
71341
|
throw new Error("unsafe daemon update package map type");
|
|
71041
|
-
if (process.platform !== "win32" && (
|
|
71342
|
+
if (process.platform !== "win32" && (stat3.mode & 63) !== 0) {
|
|
71042
71343
|
throw new Error("daemon update package map must be mode 0600");
|
|
71043
71344
|
}
|
|
71044
71345
|
const parsed = JSON.parse(fs10.readFileSync(filePath, "utf8"));
|
|
71045
71346
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
|
|
71046
71347
|
throw new Error("invalid daemon update package map");
|
|
71047
|
-
const
|
|
71348
|
+
const result2 = {};
|
|
71048
71349
|
for (const [key, value] of Object.entries(parsed)) {
|
|
71049
71350
|
if (key !== "latest" && !parseReleaseVersion(key))
|
|
71050
71351
|
throw new Error("invalid daemon update package map key");
|
|
71051
71352
|
if (typeof value !== "string" || !path16.isAbsolute(value))
|
|
71052
71353
|
throw new Error("invalid daemon update package map value");
|
|
71053
|
-
|
|
71354
|
+
result2[key] = value;
|
|
71054
71355
|
}
|
|
71055
|
-
return
|
|
71356
|
+
return result2;
|
|
71056
71357
|
}
|
|
71057
71358
|
function packageSpec(baseDir, machineId, version3) {
|
|
71058
71359
|
const mapped = readTestPackageMap(baseDir, machineId)?.[version3];
|
|
@@ -71734,8 +72035,8 @@ function writePrivateJsonAtomic2(filePath, value) {
|
|
|
71734
72035
|
function secureExistingFile(filePath) {
|
|
71735
72036
|
if (!fs12.existsSync(filePath))
|
|
71736
72037
|
return;
|
|
71737
|
-
const
|
|
71738
|
-
if (!
|
|
72038
|
+
const stat3 = fs12.lstatSync(filePath);
|
|
72039
|
+
if (!stat3.isFile())
|
|
71739
72040
|
throw new Error("unsafe daemon ownership file type");
|
|
71740
72041
|
fs12.chmodSync(filePath, 384);
|
|
71741
72042
|
}
|
|
@@ -71803,8 +72104,8 @@ function readReplacementLock(filePath) {
|
|
|
71803
72104
|
if (!fs12.existsSync(filePath))
|
|
71804
72105
|
return null;
|
|
71805
72106
|
try {
|
|
71806
|
-
const
|
|
71807
|
-
if (!
|
|
72107
|
+
const stat3 = fs12.lstatSync(filePath);
|
|
72108
|
+
if (!stat3.isFile())
|
|
71808
72109
|
throw new Error("unsafe daemon replacement lock type");
|
|
71809
72110
|
fs12.chmodSync(filePath, 384);
|
|
71810
72111
|
const content = JSON.parse(fs12.readFileSync(filePath, "utf8"));
|
|
@@ -72108,8 +72409,8 @@ function credentialFilePathByMachineId(baseDir, machineId) {
|
|
|
72108
72409
|
function readCredentialFile(filePath) {
|
|
72109
72410
|
if (!fs12.existsSync(filePath))
|
|
72110
72411
|
return null;
|
|
72111
|
-
const
|
|
72112
|
-
if (!
|
|
72412
|
+
const stat3 = fs12.lstatSync(filePath);
|
|
72413
|
+
if (!stat3.isFile())
|
|
72113
72414
|
throw new Error("unsafe daemon credential file type");
|
|
72114
72415
|
fs12.chmodSync(filePath, 384);
|
|
72115
72416
|
try {
|
|
@@ -72931,7 +73232,7 @@ ${MESSAGE_SEND_STDIN_POLICY}`);
|
|
|
72931
73232
|
}
|
|
72932
73233
|
replyToSeq = n;
|
|
72933
73234
|
}
|
|
72934
|
-
const nonce =
|
|
73235
|
+
const nonce = randomUUID15();
|
|
72935
73236
|
let res;
|
|
72936
73237
|
try {
|
|
72937
73238
|
res = await sendWithRetry(api2, {
|
|
@@ -72986,8 +73287,8 @@ async function cmdMessagePropertySet(opts) {
|
|
|
72986
73287
|
throw new CliError("message property set: --target <ref> is required");
|
|
72987
73288
|
const request = parseMessageTarget("message property set", target2);
|
|
72988
73289
|
const property = parseMessagePropertyJson("message property set", opts.json);
|
|
72989
|
-
const
|
|
72990
|
-
return { target: target2, ...
|
|
73290
|
+
const result2 = await withTransientMutationRetry(() => api2.messagePropertySet({ ...request, property }));
|
|
73291
|
+
return { target: target2, ...result2 };
|
|
72991
73292
|
}
|
|
72992
73293
|
async function cmdMessagePropertyList(opts) {
|
|
72993
73294
|
const api2 = getApi();
|
|
@@ -72995,8 +73296,8 @@ async function cmdMessagePropertyList(opts) {
|
|
|
72995
73296
|
if (!target2)
|
|
72996
73297
|
throw new CliError("message property list: --target <ref> is required");
|
|
72997
73298
|
const request = parseMessageTarget("message property list", target2);
|
|
72998
|
-
const
|
|
72999
|
-
return { target: target2, ...
|
|
73299
|
+
const result2 = await api2.messagePropertyList(request);
|
|
73300
|
+
return { target: target2, ...result2 };
|
|
73000
73301
|
}
|
|
73001
73302
|
async function cmdMessagePropertyRemove(opts) {
|
|
73002
73303
|
const api2 = getApi();
|
|
@@ -73005,8 +73306,8 @@ async function cmdMessagePropertyRemove(opts) {
|
|
|
73005
73306
|
throw new CliError("message property remove: --target <ref> is required");
|
|
73006
73307
|
const request = parseMessageTarget("message property remove", target2);
|
|
73007
73308
|
const property = parseMessagePropertyJson("message property remove", opts.json);
|
|
73008
|
-
const
|
|
73009
|
-
return { target: target2, ...
|
|
73309
|
+
const result2 = await withTransientMutationRetry(() => api2.messagePropertyRemove({ ...request, property }));
|
|
73310
|
+
return { target: target2, ...result2 };
|
|
73010
73311
|
}
|
|
73011
73312
|
function parseMessageTarget(command, target2) {
|
|
73012
73313
|
let parsed;
|
|
@@ -73067,7 +73368,7 @@ async function cmdAttachmentUpload(opts) {
|
|
|
73067
73368
|
throw new CliError(`message attachment upload: ${error62.message}`);
|
|
73068
73369
|
}
|
|
73069
73370
|
}
|
|
73070
|
-
const
|
|
73371
|
+
const result2 = await api2.attachmentUpload({
|
|
73071
73372
|
agentId: agent2,
|
|
73072
73373
|
...target2 !== undefined ? { target: target2 } : {},
|
|
73073
73374
|
file: { data: new Uint8Array(bytes), filename, contentType },
|
|
@@ -73075,7 +73376,7 @@ async function cmdAttachmentUpload(opts) {
|
|
|
73075
73376
|
...width !== undefined ? { width } : {},
|
|
73076
73377
|
...height !== undefined ? { height } : {}
|
|
73077
73378
|
});
|
|
73078
|
-
return
|
|
73379
|
+
return result2;
|
|
73079
73380
|
}
|
|
73080
73381
|
async function cmdAttachmentDownload(opts) {
|
|
73081
73382
|
const api2 = getApi();
|
|
@@ -73087,22 +73388,22 @@ async function cmdAttachmentDownload(opts) {
|
|
|
73087
73388
|
const os4 = await import("os");
|
|
73088
73389
|
const pathMod = await import("path");
|
|
73089
73390
|
const destPath = outFlag ?? pathMod.join(os4.tmpdir(), "alook-attachments", agent2, id3, "file");
|
|
73090
|
-
const
|
|
73391
|
+
const result2 = await api2.attachmentDownload({ agentId: agent2, id: id3, destPath });
|
|
73091
73392
|
if (!outFlag) {
|
|
73092
73393
|
const fs13 = await import("fs/promises");
|
|
73093
73394
|
const destDir = pathMod.dirname(destPath);
|
|
73094
|
-
const safeName = pathMod.basename(
|
|
73395
|
+
const safeName = pathMod.basename(result2.filename) || "file";
|
|
73095
73396
|
const renamed = pathMod.join(destDir, safeName);
|
|
73096
73397
|
if (renamed !== destPath) {
|
|
73097
73398
|
try {
|
|
73098
73399
|
await fs13.rename(destPath, renamed);
|
|
73099
|
-
return { ...
|
|
73400
|
+
return { ...result2, path: renamed };
|
|
73100
73401
|
} catch {
|
|
73101
|
-
return { ...
|
|
73402
|
+
return { ...result2, path: destPath };
|
|
73102
73403
|
}
|
|
73103
73404
|
}
|
|
73104
73405
|
}
|
|
73105
|
-
return
|
|
73406
|
+
return result2;
|
|
73106
73407
|
}
|
|
73107
73408
|
async function cmdSettingProfile(opts) {
|
|
73108
73409
|
const bio = opts.setBio;
|
|
@@ -73169,9 +73470,9 @@ async function cmdInboxPull(opts) {
|
|
|
73169
73470
|
};
|
|
73170
73471
|
} else {
|
|
73171
73472
|
try {
|
|
73172
|
-
const
|
|
73173
|
-
acked =
|
|
73174
|
-
failed =
|
|
73473
|
+
const result2 = await api2.ack({ agentId: agent2, cursors: [...latest.values()] });
|
|
73474
|
+
acked = result2.applied.length;
|
|
73475
|
+
failed = result2.failed;
|
|
73175
73476
|
} catch (err) {
|
|
73176
73477
|
ackError = err instanceof Error ? err.message : String(err);
|
|
73177
73478
|
}
|
|
@@ -73324,134 +73625,135 @@ function buildProgram(stdin) {
|
|
|
73324
73625
|
writeErr: () => {}
|
|
73325
73626
|
}).option("--agent <id>", "agent identity (or ALOOK_AGENT_ID env)");
|
|
73326
73627
|
registerPlatformCommands(program, getApi, printEnvelope);
|
|
73628
|
+
registerUseCommands(program, printEnvelope);
|
|
73327
73629
|
registerPiiCommands(program, printEnvelope);
|
|
73328
73630
|
const message2 = program.command("message").description("message operations").exitOverride();
|
|
73329
73631
|
message2.configureOutput({ writeOut: () => {}, writeErr: () => {} });
|
|
73330
73632
|
message2.command("send").description("send a message to a channel, DM, or thread").option("--target <ref>", "destination (path-style ref, e.g. /demo-workspace#1234/general)").requiredOption("--stdin", "read the required UTF-8 message body from non-TTY stdin (max 1 KiB)").option("-a, --attachment <id>", "attach an uploaded file by id (repeatable — order = message order)", (v, prev = []) => [...prev, v], []).option("--force", "bypass duplicate detection only; channel alignment and other send checks still apply").option("--reply <seq>", 'reply to a message by its seq in --target (e.g. "#37" or 37)').requiredOption("--remind-after <0|Nm|Nh>", "required idle follow-up: 0 disables; 1m..24h arms/resets one same-scope timer; a newer message or daemon restart cancels it").exitOverride().configureOutput({ writeOut: () => {}, writeErr: () => {} }).action(async function() {
|
|
73331
73633
|
const localOpts = this.opts();
|
|
73332
73634
|
const globalOpts = program.opts();
|
|
73333
|
-
const
|
|
73334
|
-
printEnvelope({ success:
|
|
73635
|
+
const result2 = await cmdMessageSend({ ...globalOpts, ...localOpts }, stdin);
|
|
73636
|
+
printEnvelope({ success: result2 });
|
|
73335
73637
|
});
|
|
73336
73638
|
const property = message2.command("property").description("message property operations").exitOverride();
|
|
73337
73639
|
property.configureOutput({ writeOut: () => {}, writeErr: () => {} });
|
|
73338
73640
|
property.command("set").description("add a supported property value to a message").requiredOption("--target <ref>", "full message ref").requiredOption("--json <json>", "property JSON").exitOverride().configureOutput({ writeOut: () => {}, writeErr: () => {} }).action(async function() {
|
|
73339
|
-
const
|
|
73340
|
-
printEnvelope({ success:
|
|
73641
|
+
const result2 = await cmdMessagePropertySet({ ...program.opts(), ...this.opts() });
|
|
73642
|
+
printEnvelope({ success: result2 });
|
|
73341
73643
|
});
|
|
73342
73644
|
property.command("list").description("list current properties and supported capabilities").requiredOption("--target <ref>", "full message ref").exitOverride().configureOutput({ writeOut: () => {}, writeErr: () => {} }).action(async function() {
|
|
73343
|
-
const
|
|
73344
|
-
printEnvelope({ success:
|
|
73645
|
+
const result2 = await cmdMessagePropertyList({ ...program.opts(), ...this.opts() });
|
|
73646
|
+
printEnvelope({ success: result2 });
|
|
73345
73647
|
});
|
|
73346
73648
|
property.command("remove").description("remove a supported property value from a message").requiredOption("--target <ref>", "full message ref").requiredOption("--json <json>", "property JSON").exitOverride().configureOutput({ writeOut: () => {}, writeErr: () => {} }).action(async function() {
|
|
73347
|
-
const
|
|
73348
|
-
printEnvelope({ success:
|
|
73649
|
+
const result2 = await cmdMessagePropertyRemove({ ...program.opts(), ...this.opts() });
|
|
73650
|
+
printEnvelope({ success: result2 });
|
|
73349
73651
|
});
|
|
73350
73652
|
const mark = message2.command("mark").description("global durable-mark queries").exitOverride();
|
|
73351
73653
|
mark.configureOutput({ writeOut: () => {}, writeErr: () => {} });
|
|
73352
73654
|
mark.command("list").description("list all currently visible marked messages").exitOverride().configureOutput({ writeOut: () => {}, writeErr: () => {} }).action(async function() {
|
|
73353
|
-
const
|
|
73354
|
-
printEnvelope({ success:
|
|
73655
|
+
const result2 = await cmdMessageMarkList({ ...program.opts(), ...this.opts() });
|
|
73656
|
+
printEnvelope({ success: result2 });
|
|
73355
73657
|
});
|
|
73356
73658
|
const attachment = message2.command("attachment").description("attachment operations").exitOverride();
|
|
73357
73659
|
attachment.configureOutput({ writeOut: () => {}, writeErr: () => {} });
|
|
73358
73660
|
attachment.command("upload").description("upload a local file and get its reusable attachment id").option("--target <ref>", "optional legacy target (channel, DM, or thread ref)").option("--file <path>", "local file to upload").exitOverride().configureOutput({ writeOut: () => {}, writeErr: () => {} }).action(async function() {
|
|
73359
73661
|
const localOpts = this.opts();
|
|
73360
73662
|
const globalOpts = program.opts();
|
|
73361
|
-
const
|
|
73362
|
-
printEnvelope({ success:
|
|
73663
|
+
const result2 = await cmdAttachmentUpload({ ...globalOpts, ...localOpts });
|
|
73664
|
+
printEnvelope({ success: result2 });
|
|
73363
73665
|
});
|
|
73364
73666
|
attachment.command("download").description("download an attachment by id to disk").option("--id <id>", "attachment id (from inbox pull / send response)").option("--out <path>", "explicit output path (default: /tmp/alook-attachments/<agent>/<id>/<filename>)").exitOverride().configureOutput({ writeOut: () => {}, writeErr: () => {} }).action(async function() {
|
|
73365
73667
|
const localOpts = this.opts();
|
|
73366
73668
|
const globalOpts = program.opts();
|
|
73367
|
-
const
|
|
73368
|
-
printEnvelope({ success:
|
|
73669
|
+
const result2 = await cmdAttachmentDownload({ ...globalOpts, ...localOpts });
|
|
73670
|
+
printEnvelope({ success: result2 });
|
|
73369
73671
|
});
|
|
73370
73672
|
const inbox = program.command("inbox").description("inbox operations").exitOverride();
|
|
73371
73673
|
inbox.configureOutput({ writeOut: () => {}, writeErr: () => {} });
|
|
73372
73674
|
inbox.command("pull").description("fetch unread messages from all channels").option("--max <n>", "max messages to return").exitOverride().configureOutput({ writeOut: () => {}, writeErr: () => {} }).action(async function() {
|
|
73373
73675
|
const localOpts = this.opts();
|
|
73374
73676
|
const globalOpts = program.opts();
|
|
73375
|
-
const
|
|
73376
|
-
printEnvelope({ success:
|
|
73677
|
+
const result2 = await cmdInboxPull({ ...globalOpts, ...localOpts });
|
|
73678
|
+
printEnvelope({ success: result2 });
|
|
73377
73679
|
});
|
|
73378
73680
|
const server = program.command("server").description("server operations").exitOverride();
|
|
73379
73681
|
server.configureOutput({ writeOut: () => {}, writeErr: () => {} });
|
|
73380
73682
|
server.command("list").description("list servers this agent is a member of").exitOverride().configureOutput({ writeOut: () => {}, writeErr: () => {} }).action(async function() {
|
|
73381
73683
|
const localOpts = this.opts();
|
|
73382
73684
|
const globalOpts = program.opts();
|
|
73383
|
-
const
|
|
73384
|
-
printEnvelope({ success:
|
|
73685
|
+
const result2 = await cmdServerList({ ...globalOpts, ...localOpts });
|
|
73686
|
+
printEnvelope({ success: result2 });
|
|
73385
73687
|
});
|
|
73386
73688
|
server.command("member").description("list members of a server (paginated; each member carries online + status)").option("--server <handle>", "server name#discriminator handle (from `server list`)").option("--limit <n>", "max members per page").option("--cursor <cursor>", "opaque cursor from a prior page's response (omit for the first page)").exitOverride().configureOutput({ writeOut: () => {}, writeErr: () => {} }).action(async function() {
|
|
73387
73689
|
const localOpts = this.opts();
|
|
73388
73690
|
const globalOpts = program.opts();
|
|
73389
|
-
const
|
|
73390
|
-
printEnvelope({ success:
|
|
73691
|
+
const result2 = await cmdServerMember({ ...globalOpts, ...localOpts });
|
|
73692
|
+
printEnvelope({ success: result2 });
|
|
73391
73693
|
});
|
|
73392
73694
|
server.command("join").description("join a server via an invite link or token").option("--invite <link>", "invite URL or bare token").exitOverride().configureOutput({ writeOut: () => {}, writeErr: () => {} }).action(async function() {
|
|
73393
73695
|
const localOpts = this.opts();
|
|
73394
73696
|
const globalOpts = program.opts();
|
|
73395
|
-
const
|
|
73396
|
-
printEnvelope({ success:
|
|
73697
|
+
const result2 = await cmdServerJoin({ ...globalOpts, ...localOpts });
|
|
73698
|
+
printEnvelope({ success: result2 });
|
|
73397
73699
|
});
|
|
73398
73700
|
server.command("leave").description("leave a server you belong to").option("--server <handle>", "server name#NNNN handle (from `server list`)").exitOverride().configureOutput({ writeOut: () => {}, writeErr: () => {} }).action(async function() {
|
|
73399
73701
|
const localOpts = this.opts();
|
|
73400
73702
|
const globalOpts = program.opts();
|
|
73401
|
-
const
|
|
73402
|
-
printEnvelope({ success:
|
|
73703
|
+
const result2 = await cmdServerLeave({ ...globalOpts, ...localOpts });
|
|
73704
|
+
printEnvelope({ success: result2 });
|
|
73403
73705
|
});
|
|
73404
73706
|
const channel2 = program.command("channel").description("channel operations").exitOverride();
|
|
73405
73707
|
channel2.configureOutput({ writeOut: () => {}, writeErr: () => {} });
|
|
73406
73708
|
channel2.command("list").description("list top-level channels visible to this agent in one server").option("--server <handle>", "server name#discriminator handle (from `server list`)").exitOverride().configureOutput({ writeOut: () => {}, writeErr: () => {} }).action(async function() {
|
|
73407
73709
|
const localOpts = this.opts();
|
|
73408
73710
|
const globalOpts = program.opts();
|
|
73409
|
-
const
|
|
73410
|
-
printEnvelope({ success:
|
|
73711
|
+
const result2 = await cmdChannelList({ ...globalOpts, ...localOpts });
|
|
73712
|
+
printEnvelope({ success: result2 });
|
|
73411
73713
|
});
|
|
73412
73714
|
channel2.command("history").description("fetch a page of messages from a channel, thread, or DM").option("--channel <ref>", "channel/thread/DM ref (path-style)").option("--before <seq>", "messages before this seq").option("--after <seq>", "messages after this seq").option("--around <seq>", "messages around this seq").option("--limit <n>", "max messages to return").exitOverride().configureOutput({ writeOut: () => {}, writeErr: () => {} }).action(async function() {
|
|
73413
73715
|
const localOpts = this.opts();
|
|
73414
73716
|
const globalOpts = program.opts();
|
|
73415
|
-
const
|
|
73416
|
-
printEnvelope({ success:
|
|
73717
|
+
const result2 = await cmdChannelHistory({ ...globalOpts, ...localOpts });
|
|
73718
|
+
printEnvelope({ success: result2 });
|
|
73417
73719
|
});
|
|
73418
73720
|
channel2.command("member").description("fetch the followed members of a channel or thread; public channels return a hint pointing at `alook server member`").option("--channel <ref>", "channel/thread ref (path-style)").exitOverride().configureOutput({ writeOut: () => {}, writeErr: () => {} }).action(async function() {
|
|
73419
73721
|
const localOpts = this.opts();
|
|
73420
73722
|
const globalOpts = program.opts();
|
|
73421
|
-
const
|
|
73422
|
-
printEnvelope({ success:
|
|
73723
|
+
const result2 = await cmdChannelMember({ ...globalOpts, ...localOpts });
|
|
73724
|
+
printEnvelope({ success: result2 });
|
|
73423
73725
|
});
|
|
73424
73726
|
channel2.command("leave").description("leave a thread or private channel/forum").option("--channel <ref>", "channel/thread ref (path-style)").exitOverride().configureOutput({ writeOut: () => {}, writeErr: () => {} }).action(async function() {
|
|
73425
73727
|
const localOpts = this.opts();
|
|
73426
73728
|
const globalOpts = program.opts();
|
|
73427
|
-
const
|
|
73428
|
-
printEnvelope({ success:
|
|
73729
|
+
const result2 = await cmdChannelLeave({ ...globalOpts, ...localOpts });
|
|
73730
|
+
printEnvelope({ success: result2 });
|
|
73429
73731
|
});
|
|
73430
73732
|
const friend = program.command("friend").description("friend operations").exitOverride();
|
|
73431
73733
|
friend.configureOutput({ writeOut: () => {}, writeErr: () => {} });
|
|
73432
73734
|
friend.command("request").description("send a friend request to a user by handle (owner-approval required)").option("--username <name#0042>", "the target's global handle, e.g. Alice#0042").exitOverride().configureOutput({ writeOut: () => {}, writeErr: () => {} }).action(async function() {
|
|
73433
73735
|
const localOpts = this.opts();
|
|
73434
73736
|
const globalOpts = program.opts();
|
|
73435
|
-
const
|
|
73436
|
-
printEnvelope({ success:
|
|
73737
|
+
const result2 = await cmdFriendRequest({ ...globalOpts, ...localOpts });
|
|
73738
|
+
printEnvelope({ success: result2 });
|
|
73437
73739
|
});
|
|
73438
73740
|
friend.command("list").description("list your friends and pending requests (accepted, pendingOutgoing, pendingIncoming)").exitOverride().configureOutput({ writeOut: () => {}, writeErr: () => {} }).action(async function() {
|
|
73439
73741
|
const localOpts = this.opts();
|
|
73440
73742
|
const globalOpts = program.opts();
|
|
73441
|
-
const
|
|
73442
|
-
printEnvelope({ success:
|
|
73743
|
+
const result2 = await cmdFriendList({ ...globalOpts, ...localOpts });
|
|
73744
|
+
printEnvelope({ success: result2 });
|
|
73443
73745
|
});
|
|
73444
73746
|
const setting = program.command("setting").description("account settings").exitOverride();
|
|
73445
73747
|
setting.configureOutput({ writeOut: () => {}, writeErr: () => {} });
|
|
73446
73748
|
setting.command("profile").description("update your public bio and/or avatar").option("--set-bio <text>", "set public bio; pass an empty string to clear it").option("--set-avatar <path>", "upload a png, jpeg, webp, or gif avatar").exitOverride().configureOutput({ writeOut: () => {}, writeErr: () => {} }).action(async function() {
|
|
73447
|
-
const
|
|
73448
|
-
printEnvelope({ success:
|
|
73749
|
+
const result2 = await cmdSettingProfile({ ...program.opts(), ...this.opts() });
|
|
73750
|
+
printEnvelope({ success: result2 });
|
|
73449
73751
|
});
|
|
73450
73752
|
program.command("nap").description("reset your session; optionally wake a fresh session with a handoff (read the nap rule first)").option("--handoff <file>", "path to your handoff note (your note to your reborn self)").exitOverride().configureOutput({ writeOut: () => {}, writeErr: () => {} }).action(async function() {
|
|
73451
73753
|
const localOpts = this.opts();
|
|
73452
73754
|
const globalOpts = program.opts();
|
|
73453
|
-
const
|
|
73454
|
-
printEnvelope({ success:
|
|
73755
|
+
const result2 = await cmdNap({ ...globalOpts, ...localOpts });
|
|
73756
|
+
printEnvelope({ success: result2 });
|
|
73455
73757
|
});
|
|
73456
73758
|
const daemon = program.command("daemon").description("daemon operations").exitOverride();
|
|
73457
73759
|
daemon.configureOutput({ writeOut: () => {}, writeErr: () => {} });
|