@locusai/cli 0.14.4 → 0.15.0
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/bin/agent/worker.js +202 -4
- package/bin/locus.js +14546 -1462
- package/package.json +4 -3
package/bin/agent/worker.js
CHANGED
|
@@ -14343,6 +14343,32 @@ var init_auth = __esm(() => {
|
|
|
14343
14343
|
});
|
|
14344
14344
|
});
|
|
14345
14345
|
|
|
14346
|
+
// ../shared/src/models/autonomy.ts
|
|
14347
|
+
var RiskLevel, ChangeCategory, AutonomyRuleSchema;
|
|
14348
|
+
var init_autonomy = __esm(() => {
|
|
14349
|
+
init_zod();
|
|
14350
|
+
((RiskLevel2) => {
|
|
14351
|
+
RiskLevel2["LOW"] = "LOW";
|
|
14352
|
+
RiskLevel2["HIGH"] = "HIGH";
|
|
14353
|
+
})(RiskLevel ||= {});
|
|
14354
|
+
((ChangeCategory2) => {
|
|
14355
|
+
ChangeCategory2["FIX"] = "FIX";
|
|
14356
|
+
ChangeCategory2["REFACTOR"] = "REFACTOR";
|
|
14357
|
+
ChangeCategory2["STYLE"] = "STYLE";
|
|
14358
|
+
ChangeCategory2["DEPENDENCY"] = "DEPENDENCY";
|
|
14359
|
+
ChangeCategory2["FEATURE"] = "FEATURE";
|
|
14360
|
+
ChangeCategory2["ARCHITECTURE"] = "ARCHITECTURE";
|
|
14361
|
+
ChangeCategory2["DATABASE"] = "DATABASE";
|
|
14362
|
+
ChangeCategory2["AUTH"] = "AUTH";
|
|
14363
|
+
ChangeCategory2["API"] = "API";
|
|
14364
|
+
})(ChangeCategory ||= {});
|
|
14365
|
+
AutonomyRuleSchema = exports_external.object({
|
|
14366
|
+
category: exports_external.enum(ChangeCategory),
|
|
14367
|
+
riskLevel: exports_external.enum(RiskLevel),
|
|
14368
|
+
autoExecute: exports_external.boolean()
|
|
14369
|
+
});
|
|
14370
|
+
});
|
|
14371
|
+
|
|
14346
14372
|
// ../shared/src/models/aws-instance.ts
|
|
14347
14373
|
var InstanceAction, AwsCredentialsSchema, IntegrationSchema, AwsInstanceSchema, CreateAwsInstanceSchema, UpdateAwsInstanceSchema, SaveAwsCredentialsSchema, ProvisionAwsInstanceSchema, InstanceActionBodySchema, InstanceIdParamSchema, CIDR_REGEX, UpdateSecurityRulesSchema;
|
|
14348
14374
|
var init_aws_instance = __esm(() => {
|
|
@@ -14564,6 +14590,71 @@ var init_invitation = __esm(() => {
|
|
|
14564
14590
|
});
|
|
14565
14591
|
});
|
|
14566
14592
|
|
|
14593
|
+
// ../shared/src/models/job.ts
|
|
14594
|
+
var JobType, JobStatus, JobSeverity, JobScheduleSchema, JobConfigSchema, JobRunResultSchema, JobRunSchema, CreateJobRunSchema, UpdateJobRunSchema;
|
|
14595
|
+
var init_job = __esm(() => {
|
|
14596
|
+
init_zod();
|
|
14597
|
+
((JobType2) => {
|
|
14598
|
+
JobType2["LINT_SCAN"] = "LINT_SCAN";
|
|
14599
|
+
JobType2["DEPENDENCY_CHECK"] = "DEPENDENCY_CHECK";
|
|
14600
|
+
JobType2["TODO_CLEANUP"] = "TODO_CLEANUP";
|
|
14601
|
+
JobType2["FLAKY_TEST_DETECTION"] = "FLAKY_TEST_DETECTION";
|
|
14602
|
+
JobType2["CUSTOM"] = "CUSTOM";
|
|
14603
|
+
})(JobType ||= {});
|
|
14604
|
+
((JobStatus2) => {
|
|
14605
|
+
JobStatus2["IDLE"] = "IDLE";
|
|
14606
|
+
JobStatus2["RUNNING"] = "RUNNING";
|
|
14607
|
+
JobStatus2["COMPLETED"] = "COMPLETED";
|
|
14608
|
+
JobStatus2["FAILED"] = "FAILED";
|
|
14609
|
+
JobStatus2["CANCELLED"] = "CANCELLED";
|
|
14610
|
+
})(JobStatus ||= {});
|
|
14611
|
+
((JobSeverity2) => {
|
|
14612
|
+
JobSeverity2["AUTO_EXECUTE"] = "AUTO_EXECUTE";
|
|
14613
|
+
JobSeverity2["REQUIRE_APPROVAL"] = "REQUIRE_APPROVAL";
|
|
14614
|
+
})(JobSeverity ||= {});
|
|
14615
|
+
JobScheduleSchema = exports_external.object({
|
|
14616
|
+
cronExpression: exports_external.string(),
|
|
14617
|
+
enabled: exports_external.boolean(),
|
|
14618
|
+
lastRunAt: exports_external.string().optional(),
|
|
14619
|
+
nextRunAt: exports_external.string().optional()
|
|
14620
|
+
});
|
|
14621
|
+
JobConfigSchema = exports_external.object({
|
|
14622
|
+
type: exports_external.enum(JobType),
|
|
14623
|
+
schedule: JobScheduleSchema,
|
|
14624
|
+
severity: exports_external.enum(JobSeverity),
|
|
14625
|
+
enabled: exports_external.boolean(),
|
|
14626
|
+
options: exports_external.record(exports_external.string(), exports_external.any())
|
|
14627
|
+
});
|
|
14628
|
+
JobRunResultSchema = exports_external.object({
|
|
14629
|
+
summary: exports_external.string(),
|
|
14630
|
+
filesChanged: exports_external.number(),
|
|
14631
|
+
prUrl: exports_external.string().optional(),
|
|
14632
|
+
errors: exports_external.array(exports_external.string()).optional()
|
|
14633
|
+
});
|
|
14634
|
+
JobRunSchema = exports_external.object({
|
|
14635
|
+
id: exports_external.string(),
|
|
14636
|
+
jobType: exports_external.enum(JobType),
|
|
14637
|
+
status: exports_external.enum(JobStatus),
|
|
14638
|
+
startedAt: exports_external.string(),
|
|
14639
|
+
completedAt: exports_external.string().optional(),
|
|
14640
|
+
result: JobRunResultSchema.optional(),
|
|
14641
|
+
workspaceId: exports_external.string()
|
|
14642
|
+
});
|
|
14643
|
+
CreateJobRunSchema = exports_external.object({
|
|
14644
|
+
jobType: exports_external.enum(JobType),
|
|
14645
|
+
status: exports_external.enum(JobStatus).optional().default("RUNNING" /* RUNNING */),
|
|
14646
|
+
startedAt: exports_external.string().optional(),
|
|
14647
|
+
error: exports_external.string().optional(),
|
|
14648
|
+
result: JobRunResultSchema.optional()
|
|
14649
|
+
});
|
|
14650
|
+
UpdateJobRunSchema = exports_external.object({
|
|
14651
|
+
status: exports_external.enum(JobStatus).optional(),
|
|
14652
|
+
result: JobRunResultSchema.optional(),
|
|
14653
|
+
error: exports_external.string().nullable().optional(),
|
|
14654
|
+
completedAt: exports_external.string().optional()
|
|
14655
|
+
});
|
|
14656
|
+
});
|
|
14657
|
+
|
|
14567
14658
|
// ../shared/src/models/organization.ts
|
|
14568
14659
|
var OrganizationSchema, CreateOrganizationSchema, UpdateOrganizationSchema, AddMemberSchema, MembershipWithUserSchema, OrgIdParamSchema, MembershipIdParamSchema, OrganizationResponseSchema, OrganizationsResponseSchema, MembersResponseSchema, MembershipResponseSchema;
|
|
14569
14660
|
var init_organization = __esm(() => {
|
|
@@ -14661,6 +14752,49 @@ var init_sprint = __esm(() => {
|
|
|
14661
14752
|
});
|
|
14662
14753
|
});
|
|
14663
14754
|
|
|
14755
|
+
// ../shared/src/models/suggestion.ts
|
|
14756
|
+
var SuggestionStatus, SuggestionType, SuggestionSchema, CreateSuggestionSchema, UpdateSuggestionStatusSchema;
|
|
14757
|
+
var init_suggestion = __esm(() => {
|
|
14758
|
+
init_zod();
|
|
14759
|
+
((SuggestionStatus2) => {
|
|
14760
|
+
SuggestionStatus2["NEW"] = "NEW";
|
|
14761
|
+
SuggestionStatus2["NOTIFIED"] = "NOTIFIED";
|
|
14762
|
+
SuggestionStatus2["ACTED_ON"] = "ACTED_ON";
|
|
14763
|
+
SuggestionStatus2["SKIPPED"] = "SKIPPED";
|
|
14764
|
+
SuggestionStatus2["EXPIRED"] = "EXPIRED";
|
|
14765
|
+
})(SuggestionStatus ||= {});
|
|
14766
|
+
((SuggestionType2) => {
|
|
14767
|
+
SuggestionType2["CODE_FIX"] = "CODE_FIX";
|
|
14768
|
+
SuggestionType2["DEPENDENCY_UPDATE"] = "DEPENDENCY_UPDATE";
|
|
14769
|
+
SuggestionType2["NEXT_STEP"] = "NEXT_STEP";
|
|
14770
|
+
SuggestionType2["REFACTOR"] = "REFACTOR";
|
|
14771
|
+
SuggestionType2["TEST_FIX"] = "TEST_FIX";
|
|
14772
|
+
})(SuggestionType ||= {});
|
|
14773
|
+
SuggestionSchema = exports_external.object({
|
|
14774
|
+
id: exports_external.string(),
|
|
14775
|
+
type: exports_external.enum(SuggestionType),
|
|
14776
|
+
status: exports_external.enum(SuggestionStatus),
|
|
14777
|
+
title: exports_external.string(),
|
|
14778
|
+
description: exports_external.string(),
|
|
14779
|
+
jobRunId: exports_external.string().optional(),
|
|
14780
|
+
workspaceId: exports_external.string(),
|
|
14781
|
+
createdAt: exports_external.string(),
|
|
14782
|
+
expiresAt: exports_external.string(),
|
|
14783
|
+
metadata: exports_external.record(exports_external.string(), exports_external.any()).optional()
|
|
14784
|
+
});
|
|
14785
|
+
CreateSuggestionSchema = exports_external.object({
|
|
14786
|
+
type: exports_external.enum(SuggestionType),
|
|
14787
|
+
title: exports_external.string().min(1, "Title is required"),
|
|
14788
|
+
description: exports_external.string().min(1, "Description is required"),
|
|
14789
|
+
jobRunId: exports_external.string().uuid().optional(),
|
|
14790
|
+
metadata: exports_external.record(exports_external.string(), exports_external.any()).optional(),
|
|
14791
|
+
expiresAt: exports_external.string().optional()
|
|
14792
|
+
});
|
|
14793
|
+
UpdateSuggestionStatusSchema = exports_external.object({
|
|
14794
|
+
status: exports_external.enum(SuggestionStatus)
|
|
14795
|
+
});
|
|
14796
|
+
});
|
|
14797
|
+
|
|
14664
14798
|
// ../shared/src/models/task.ts
|
|
14665
14799
|
var AcceptanceItemSchema, TaskSchema, CreateTaskSchema, UpdateTaskSchema, AddCommentSchema, DispatchTaskSchema, TaskIdParamSchema, TaskQuerySchema, TaskResponseSchema, TasksResponseSchema;
|
|
14666
14800
|
var init_task = __esm(() => {
|
|
@@ -14800,13 +14934,16 @@ var init_models = __esm(() => {
|
|
|
14800
14934
|
init_activity();
|
|
14801
14935
|
init_agent();
|
|
14802
14936
|
init_auth();
|
|
14937
|
+
init_autonomy();
|
|
14803
14938
|
init_aws_instance();
|
|
14804
14939
|
init_ci();
|
|
14805
14940
|
init_doc();
|
|
14806
14941
|
init_doc_group();
|
|
14807
14942
|
init_invitation();
|
|
14943
|
+
init_job();
|
|
14808
14944
|
init_organization();
|
|
14809
14945
|
init_sprint();
|
|
14946
|
+
init_suggestion();
|
|
14810
14947
|
init_task();
|
|
14811
14948
|
init_user();
|
|
14812
14949
|
init_workspace();
|
|
@@ -15572,6 +15709,7 @@ class ClaudeRunner {
|
|
|
15572
15709
|
currentToolName;
|
|
15573
15710
|
activeTools = new Map;
|
|
15574
15711
|
activeProcess = null;
|
|
15712
|
+
aborted = false;
|
|
15575
15713
|
timeoutMs;
|
|
15576
15714
|
constructor(projectPath, model = DEFAULT_MODEL[PROVIDER.CLAUDE], log, timeoutMs) {
|
|
15577
15715
|
this.model = model;
|
|
@@ -15584,6 +15722,7 @@ class ClaudeRunner {
|
|
|
15584
15722
|
}
|
|
15585
15723
|
abort() {
|
|
15586
15724
|
if (this.activeProcess && !this.activeProcess.killed) {
|
|
15725
|
+
this.aborted = true;
|
|
15587
15726
|
this.activeProcess.kill("SIGTERM");
|
|
15588
15727
|
this.activeProcess = null;
|
|
15589
15728
|
}
|
|
@@ -15642,6 +15781,7 @@ class ClaudeRunner {
|
|
|
15642
15781
|
return args;
|
|
15643
15782
|
}
|
|
15644
15783
|
async* runStream(prompt) {
|
|
15784
|
+
this.aborted = false;
|
|
15645
15785
|
const args = this.buildCliArgs();
|
|
15646
15786
|
const env = getAugmentedEnv({
|
|
15647
15787
|
FORCE_COLOR: "1",
|
|
@@ -15736,7 +15876,7 @@ class ClaudeRunner {
|
|
|
15736
15876
|
process.stderr.write(`${stderrBuffer}
|
|
15737
15877
|
`);
|
|
15738
15878
|
}
|
|
15739
|
-
if (code !== 0 && !errorMessage) {
|
|
15879
|
+
if (code !== 0 && !errorMessage && !this.aborted) {
|
|
15740
15880
|
const detail = stderrFull.trim() || lastResultContent.trim();
|
|
15741
15881
|
errorMessage = this.createExecutionError(code, detail).message;
|
|
15742
15882
|
this.eventEmitter?.emitErrorOccurred(errorMessage, `EXIT_${code}`);
|
|
@@ -15881,6 +16021,7 @@ class ClaudeRunner {
|
|
|
15881
16021
|
return null;
|
|
15882
16022
|
}
|
|
15883
16023
|
executeRun(prompt) {
|
|
16024
|
+
this.aborted = false;
|
|
15884
16025
|
return new Promise((resolve2, reject) => {
|
|
15885
16026
|
const args = this.buildCliArgs();
|
|
15886
16027
|
const env = getAugmentedEnv({
|
|
@@ -15933,7 +16074,7 @@ class ClaudeRunner {
|
|
|
15933
16074
|
}
|
|
15934
16075
|
process.stdout.write(`
|
|
15935
16076
|
`);
|
|
15936
|
-
if (code === 0) {
|
|
16077
|
+
if (code === 0 || this.aborted) {
|
|
15937
16078
|
resolve2(finalResult);
|
|
15938
16079
|
} else {
|
|
15939
16080
|
const detail = errorOutput.trim() || finalResult.trim();
|
|
@@ -16004,6 +16145,7 @@ class CodexRunner {
|
|
|
16004
16145
|
log;
|
|
16005
16146
|
reasoningEffort;
|
|
16006
16147
|
activeProcess = null;
|
|
16148
|
+
aborted = false;
|
|
16007
16149
|
eventEmitter;
|
|
16008
16150
|
currentToolName;
|
|
16009
16151
|
timeoutMs;
|
|
@@ -16019,11 +16161,13 @@ class CodexRunner {
|
|
|
16019
16161
|
}
|
|
16020
16162
|
abort() {
|
|
16021
16163
|
if (this.activeProcess && !this.activeProcess.killed) {
|
|
16164
|
+
this.aborted = true;
|
|
16022
16165
|
this.activeProcess.kill("SIGTERM");
|
|
16023
16166
|
this.activeProcess = null;
|
|
16024
16167
|
}
|
|
16025
16168
|
}
|
|
16026
16169
|
async run(prompt) {
|
|
16170
|
+
this.aborted = false;
|
|
16027
16171
|
const maxRetries = 3;
|
|
16028
16172
|
let lastError = null;
|
|
16029
16173
|
for (let attempt = 1;attempt <= maxRetries; attempt++) {
|
|
@@ -16139,7 +16283,7 @@ class CodexRunner {
|
|
|
16139
16283
|
});
|
|
16140
16284
|
codex.on("close", (code) => {
|
|
16141
16285
|
this.activeProcess = null;
|
|
16142
|
-
if (code === 0) {
|
|
16286
|
+
if (code === 0 || this.aborted) {
|
|
16143
16287
|
const result = this.readOutput(outputPath, finalOutput);
|
|
16144
16288
|
this.cleanupTempFile(outputPath);
|
|
16145
16289
|
if (result && finalContent.trim().length === 0) {
|
|
@@ -16252,7 +16396,7 @@ class CodexRunner {
|
|
|
16252
16396
|
});
|
|
16253
16397
|
codex.on("close", (code) => {
|
|
16254
16398
|
this.activeProcess = null;
|
|
16255
|
-
if (code === 0) {
|
|
16399
|
+
if (code === 0 || this.aborted) {
|
|
16256
16400
|
const result = this.readOutput(outputPath, output);
|
|
16257
16401
|
this.cleanupTempFile(outputPath);
|
|
16258
16402
|
resolve2(result);
|
|
@@ -31616,6 +31760,29 @@ var init_invitations = __esm(() => {
|
|
|
31616
31760
|
};
|
|
31617
31761
|
});
|
|
31618
31762
|
|
|
31763
|
+
// ../sdk/src/modules/jobs.ts
|
|
31764
|
+
var JobsModule;
|
|
31765
|
+
var init_jobs = __esm(() => {
|
|
31766
|
+
JobsModule = class JobsModule extends BaseModule {
|
|
31767
|
+
async create(workspaceId, data) {
|
|
31768
|
+
const { data: res } = await this.api.post(`/workspaces/${workspaceId}/job-runs`, data);
|
|
31769
|
+
return res.jobRun;
|
|
31770
|
+
}
|
|
31771
|
+
async list(workspaceId, params) {
|
|
31772
|
+
const { data } = await this.api.get(`/workspaces/${workspaceId}/job-runs`, { params });
|
|
31773
|
+
return data.jobRuns;
|
|
31774
|
+
}
|
|
31775
|
+
async get(workspaceId, id) {
|
|
31776
|
+
const { data } = await this.api.get(`/workspaces/${workspaceId}/job-runs/${id}`);
|
|
31777
|
+
return data.jobRun;
|
|
31778
|
+
}
|
|
31779
|
+
async update(workspaceId, id, data) {
|
|
31780
|
+
const { data: res } = await this.api.patch(`/workspaces/${workspaceId}/job-runs/${id}`, data);
|
|
31781
|
+
return res.jobRun;
|
|
31782
|
+
}
|
|
31783
|
+
};
|
|
31784
|
+
});
|
|
31785
|
+
|
|
31619
31786
|
// ../sdk/src/modules/organizations.ts
|
|
31620
31787
|
var OrganizationsModule;
|
|
31621
31788
|
var init_organizations = __esm(() => {
|
|
@@ -31698,6 +31865,29 @@ var init_sprints = __esm(() => {
|
|
|
31698
31865
|
};
|
|
31699
31866
|
});
|
|
31700
31867
|
|
|
31868
|
+
// ../sdk/src/modules/suggestions.ts
|
|
31869
|
+
var SuggestionsModule;
|
|
31870
|
+
var init_suggestions = __esm(() => {
|
|
31871
|
+
SuggestionsModule = class SuggestionsModule extends BaseModule {
|
|
31872
|
+
async create(workspaceId, data) {
|
|
31873
|
+
const { data: res } = await this.api.post(`/workspaces/${workspaceId}/suggestions`, data);
|
|
31874
|
+
return res.suggestion;
|
|
31875
|
+
}
|
|
31876
|
+
async list(workspaceId, params) {
|
|
31877
|
+
const { data } = await this.api.get(`/workspaces/${workspaceId}/suggestions`, { params });
|
|
31878
|
+
return data.suggestions;
|
|
31879
|
+
}
|
|
31880
|
+
async get(workspaceId, id) {
|
|
31881
|
+
const { data } = await this.api.get(`/workspaces/${workspaceId}/suggestions/${id}`);
|
|
31882
|
+
return data.suggestion;
|
|
31883
|
+
}
|
|
31884
|
+
async updateStatus(workspaceId, id, status) {
|
|
31885
|
+
const { data } = await this.api.patch(`/workspaces/${workspaceId}/suggestions/${id}/status`, status);
|
|
31886
|
+
return data.suggestion;
|
|
31887
|
+
}
|
|
31888
|
+
};
|
|
31889
|
+
});
|
|
31890
|
+
|
|
31701
31891
|
// ../sdk/src/modules/tasks.ts
|
|
31702
31892
|
var TasksModule;
|
|
31703
31893
|
var init_tasks = __esm(() => {
|
|
@@ -31882,6 +32072,8 @@ class LocusClient {
|
|
|
31882
32072
|
docs;
|
|
31883
32073
|
ci;
|
|
31884
32074
|
instances;
|
|
32075
|
+
jobs;
|
|
32076
|
+
suggestions;
|
|
31885
32077
|
constructor(config2) {
|
|
31886
32078
|
this.emitter = new LocusEmitter;
|
|
31887
32079
|
this.api = axios_default.create({
|
|
@@ -31902,6 +32094,8 @@ class LocusClient {
|
|
|
31902
32094
|
this.docs = new DocsModule(this.api, this.emitter);
|
|
31903
32095
|
this.ci = new CiModule(this.api, this.emitter);
|
|
31904
32096
|
this.instances = new InstancesModule(this.api, this.emitter);
|
|
32097
|
+
this.jobs = new JobsModule(this.api, this.emitter);
|
|
32098
|
+
this.suggestions = new SuggestionsModule(this.api, this.emitter);
|
|
31905
32099
|
if (config2.retryOptions) {
|
|
31906
32100
|
this.setupRetryInterceptor(config2.retryOptions);
|
|
31907
32101
|
}
|
|
@@ -31969,8 +32163,10 @@ var init_src2 = __esm(() => {
|
|
|
31969
32163
|
init_docs();
|
|
31970
32164
|
init_instances();
|
|
31971
32165
|
init_invitations();
|
|
32166
|
+
init_jobs();
|
|
31972
32167
|
init_organizations();
|
|
31973
32168
|
init_sprints();
|
|
32169
|
+
init_suggestions();
|
|
31974
32170
|
init_tasks();
|
|
31975
32171
|
init_workspaces();
|
|
31976
32172
|
init_discussion_types();
|
|
@@ -31980,8 +32176,10 @@ var init_src2 = __esm(() => {
|
|
|
31980
32176
|
init_docs();
|
|
31981
32177
|
init_instances();
|
|
31982
32178
|
init_invitations();
|
|
32179
|
+
init_jobs();
|
|
31983
32180
|
init_organizations();
|
|
31984
32181
|
init_sprints();
|
|
32182
|
+
init_suggestions();
|
|
31985
32183
|
init_tasks();
|
|
31986
32184
|
init_workspaces();
|
|
31987
32185
|
});
|