@butlerbot/sdk 0.0.38 → 0.0.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config.d.ts +1 -1
- package/dist/config.js +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.js +6 -1
- package/dist/modules/jobs.d.ts +13 -1
- package/dist/modules/jobs.js +13 -0
- package/dist/types/jobs/job.d.ts +26 -0
- package/package.json +1 -1
- package/readme.md +5 -0
package/dist/config.d.ts
CHANGED
|
@@ -60,7 +60,7 @@ export declare const CONFIG: {
|
|
|
60
60
|
};
|
|
61
61
|
};
|
|
62
62
|
jobs: {
|
|
63
|
-
/** The collection. One job is `${base}/${jobId}`, its cancel `${base}/${jobId}/cancel`. */
|
|
63
|
+
/** The collection. One job is `${base}/${jobId}`, its cancel `${base}/${jobId}/cancel` and its resume `${base}/${jobId}/resume`. */
|
|
64
64
|
base: string;
|
|
65
65
|
/** The owner's job settings, which live on the user rather than on a job. */
|
|
66
66
|
settings: string;
|
package/dist/config.js
CHANGED
|
@@ -52,7 +52,7 @@ exports.CONFIG = {
|
|
|
52
52
|
}
|
|
53
53
|
},
|
|
54
54
|
jobs: {
|
|
55
|
-
/** The collection. One job is `${base}/${jobId}`, its cancel `${base}/${jobId}/cancel`. */
|
|
55
|
+
/** The collection. One job is `${base}/${jobId}`, its cancel `${base}/${jobId}/cancel` and its resume `${base}/${jobId}/resume`. */
|
|
56
56
|
base: "/api/jobs",
|
|
57
57
|
/** The owner's job settings, which live on the user rather than on a job. */
|
|
58
58
|
settings: "/api/user/jobs-settings",
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { APIPath } from "./config";
|
|
|
2
2
|
import { Link, LinkOptions } from "./link";
|
|
3
3
|
import { Conversation, ConversationOptions } from "./modules/conversation";
|
|
4
4
|
import { UsagePolicyDataOptions } from "./modules/usage";
|
|
5
|
-
import { type CancelJobOptions, type GetJobJournalOptions, type GetJobOptions, type SetPhaseModelOptions, type ListJobsOptions, type UpdateJobOptions, type UpdateJobSettingsOptions } from "./modules/jobs";
|
|
5
|
+
import { type CancelJobOptions, type GetJobJournalOptions, type GetJobOptions, type SetPhaseModelOptions, type ListJobsOptions, type ResumeJobOptions, type UpdateJobOptions, type UpdateJobSettingsOptions } from "./modules/jobs";
|
|
6
6
|
import { type AnswerDeliveryOptions, type ListDeliveriesOptions } from "./modules/outreach";
|
|
7
7
|
type OptionalApiKey<T> = Omit<T, "apiKey"> & {
|
|
8
8
|
/** Optional API key, defaults to API key specified in client */
|
|
@@ -52,6 +52,8 @@ export declare class ButlerBotClient {
|
|
|
52
52
|
getJobJournal(config: OptionalApiKey<GetJobJournalOptions>): Promise<import("./types/type_registry").JobJournalPage>;
|
|
53
53
|
/** Stops a job. Throws a `ButlerBotAPIError` with `isConflict` when it had already finished */
|
|
54
54
|
cancelJob(config: OptionalApiKey<CancelJobOptions>): Promise<import("./types/type_registry").JobCancelResponse>;
|
|
55
|
+
/** Continues a job parked waiting for budget. Throws a `ButlerBotAPIError` with `isConflict` when it is in any other status */
|
|
56
|
+
resumeJob(config: OptionalApiKey<ResumeJobOptions>): Promise<import("./types/type_registry").JobResumeResponse>;
|
|
55
57
|
/** Changes one job's name, and its autonomy: how far it may act, until when, and what it always asks about */
|
|
56
58
|
updateJob(config: OptionalApiKey<UpdateJobOptions>): Promise<import("./types/type_registry").JobUpdateResponse>;
|
|
57
59
|
/** Changes the model one phase of a job's plan runs on; only a phase that has not started */
|
|
@@ -72,8 +74,8 @@ export type { ConversationOptions };
|
|
|
72
74
|
export type { APIPath };
|
|
73
75
|
export type { ConversationStream, ConversationTransport, TransportTurnRequest, TransportHandlers, } from "./modules/transport";
|
|
74
76
|
export { ButlerBotAPIError } from "./util/api_error";
|
|
75
|
-
export { listJobs, getJob, cancelJob, updateJob, updateJobSettings } from "./modules/jobs";
|
|
76
|
-
export type { JobsRequestOptions, ListJobsOptions, GetJobOptions, CancelJobOptions, UpdateJobOptions, UpdateJobSettingsOptions, } from "./modules/jobs";
|
|
77
|
+
export { listJobs, getJob, cancelJob, resumeJob, updateJob, updateJobSettings } from "./modules/jobs";
|
|
78
|
+
export type { JobsRequestOptions, ListJobsOptions, GetJobOptions, CancelJobOptions, ResumeJobOptions, UpdateJobOptions, UpdateJobSettingsOptions, } from "./modules/jobs";
|
|
77
79
|
export { listDeliveries, answerDelivery } from "./modules/outreach";
|
|
78
80
|
export type { OutreachRequestOptions, ListDeliveriesOptions, AnswerDeliveryOptions, } from "./modules/outreach";
|
|
79
81
|
export { LinkConversationTransport } from "./modules/transport_link";
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.SSEConversationTransport = exports.LinkConversationTransport = exports.answerDelivery = exports.listDeliveries = exports.updateJobSettings = exports.updateJob = exports.cancelJob = exports.getJob = exports.listJobs = exports.ButlerBotAPIError = exports.Conversation = exports.ButlerBotClient = void 0;
|
|
17
|
+
exports.SSEConversationTransport = exports.LinkConversationTransport = exports.answerDelivery = exports.listDeliveries = exports.updateJobSettings = exports.updateJob = exports.resumeJob = exports.cancelJob = exports.getJob = exports.listJobs = exports.ButlerBotAPIError = exports.Conversation = exports.ButlerBotClient = void 0;
|
|
18
18
|
const config_1 = require("./config");
|
|
19
19
|
const link_1 = require("./link");
|
|
20
20
|
const conversation_1 = require("./modules/conversation");
|
|
@@ -88,6 +88,10 @@ class ButlerBotClient {
|
|
|
88
88
|
cancelJob(config) {
|
|
89
89
|
return (0, jobs_1.cancelJob)(this.forRequest(config));
|
|
90
90
|
}
|
|
91
|
+
/** Continues a job parked waiting for budget. Throws a `ButlerBotAPIError` with `isConflict` when it is in any other status */
|
|
92
|
+
resumeJob(config) {
|
|
93
|
+
return (0, jobs_1.resumeJob)(this.forRequest(config));
|
|
94
|
+
}
|
|
91
95
|
/** Changes one job's name, and its autonomy: how far it may act, until when, and what it always asks about */
|
|
92
96
|
updateJob(config) {
|
|
93
97
|
return (0, jobs_1.updateJob)(this.forRequest(config));
|
|
@@ -123,6 +127,7 @@ var jobs_2 = require("./modules/jobs");
|
|
|
123
127
|
Object.defineProperty(exports, "listJobs", { enumerable: true, get: function () { return jobs_2.listJobs; } });
|
|
124
128
|
Object.defineProperty(exports, "getJob", { enumerable: true, get: function () { return jobs_2.getJob; } });
|
|
125
129
|
Object.defineProperty(exports, "cancelJob", { enumerable: true, get: function () { return jobs_2.cancelJob; } });
|
|
130
|
+
Object.defineProperty(exports, "resumeJob", { enumerable: true, get: function () { return jobs_2.resumeJob; } });
|
|
126
131
|
Object.defineProperty(exports, "updateJob", { enumerable: true, get: function () { return jobs_2.updateJob; } });
|
|
127
132
|
Object.defineProperty(exports, "updateJobSettings", { enumerable: true, get: function () { return jobs_2.updateJobSettings; } });
|
|
128
133
|
var outreach_2 = require("./modules/outreach");
|
package/dist/modules/jobs.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { JobAutonomy, JobCancelResponse, JobDetailResponse, JobJournalPage, JobListResponse, JobPhaseModelResponse, JobSettingsResponse, JobSettingsUpdate, JobStatus, JobUpdateResponse } from "../types/jobs";
|
|
1
|
+
import type { JobAutonomy, JobCancelResponse, JobDetailResponse, JobJournalPage, JobListResponse, JobPhaseModelResponse, JobResumeResponse, JobSettingsResponse, JobSettingsUpdate, JobStatus, JobUpdateResponse } from "../types/jobs";
|
|
2
2
|
/** What every jobs call needs: where the server is, and who is asking. */
|
|
3
3
|
export type JobsRequestOptions = {
|
|
4
4
|
serverURL?: string;
|
|
@@ -28,6 +28,9 @@ export type GetJobJournalOptions = JobsRequestOptions & {
|
|
|
28
28
|
export type CancelJobOptions = JobsRequestOptions & {
|
|
29
29
|
jobId: string;
|
|
30
30
|
};
|
|
31
|
+
export type ResumeJobOptions = JobsRequestOptions & {
|
|
32
|
+
jobId: string;
|
|
33
|
+
};
|
|
31
34
|
export type UpdateJobOptions = JobsRequestOptions & {
|
|
32
35
|
jobId: string;
|
|
33
36
|
/** A new short name for the job, a few words at most. */
|
|
@@ -62,6 +65,15 @@ export declare function getJobJournal(options: GetJobJournalOptions): Promise<Jo
|
|
|
62
65
|
* `isConflict` is true and whose `body` still carries the job as it stands.
|
|
63
66
|
*/
|
|
64
67
|
export declare function cancelJob(options: CancelJobOptions): Promise<JobCancelResponse>;
|
|
68
|
+
/**
|
|
69
|
+
* Continues a job that is parked waiting for budget, when there is room for it again.
|
|
70
|
+
*
|
|
71
|
+
* The answer says what happened either way: `resumed` is the job queued again, and otherwise
|
|
72
|
+
* `reason`, `action` and `message` say why it is still parked and what would change that. A
|
|
73
|
+
* job in any other status is a 409: the call throws a `ButlerBotAPIError` whose `isConflict`
|
|
74
|
+
* is true and whose `body` still carries the job as it stands.
|
|
75
|
+
*/
|
|
76
|
+
export declare function resumeJob(options: ResumeJobOptions): Promise<JobResumeResponse>;
|
|
65
77
|
/** Changes one job's name, and its autonomy: how far it may act, until when, and what it always asks about. */
|
|
66
78
|
export declare function updateJob(options: UpdateJobOptions): Promise<JobUpdateResponse>;
|
|
67
79
|
/**
|
package/dist/modules/jobs.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.listJobs = listJobs;
|
|
|
4
4
|
exports.getJob = getJob;
|
|
5
5
|
exports.getJobJournal = getJobJournal;
|
|
6
6
|
exports.cancelJob = cancelJob;
|
|
7
|
+
exports.resumeJob = resumeJob;
|
|
7
8
|
exports.updateJob = updateJob;
|
|
8
9
|
exports.setPhaseModel = setPhaseModel;
|
|
9
10
|
exports.updateJobSettings = updateJobSettings;
|
|
@@ -51,6 +52,18 @@ async function cancelJob(options) {
|
|
|
51
52
|
const url = (0, url_formatter_1.formatURL)(`${jobsBase(options)}/${encodeURIComponent(options.jobId)}/cancel`, {}, { apiKey: options.apiKey, debug: options.debug });
|
|
52
53
|
return (0, api_request_1.requestAPI)({ url, method: "POST", action: `cancel job ${options.jobId}` });
|
|
53
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Continues a job that is parked waiting for budget, when there is room for it again.
|
|
57
|
+
*
|
|
58
|
+
* The answer says what happened either way: `resumed` is the job queued again, and otherwise
|
|
59
|
+
* `reason`, `action` and `message` say why it is still parked and what would change that. A
|
|
60
|
+
* job in any other status is a 409: the call throws a `ButlerBotAPIError` whose `isConflict`
|
|
61
|
+
* is true and whose `body` still carries the job as it stands.
|
|
62
|
+
*/
|
|
63
|
+
async function resumeJob(options) {
|
|
64
|
+
const url = (0, url_formatter_1.formatURL)(`${jobsBase(options)}/${encodeURIComponent(options.jobId)}/resume`, {}, { apiKey: options.apiKey, debug: options.debug });
|
|
65
|
+
return (0, api_request_1.requestAPI)({ url, method: "POST", action: `resume job ${options.jobId}` });
|
|
66
|
+
}
|
|
54
67
|
/** Changes one job's name, and its autonomy: how far it may act, until when, and what it always asks about. */
|
|
55
68
|
async function updateJob(options) {
|
|
56
69
|
const url = (0, url_formatter_1.formatURL)(`${jobsBase(options)}/${encodeURIComponent(options.jobId)}`, {}, { apiKey: options.apiKey, debug: options.debug });
|
package/dist/types/jobs/job.d.ts
CHANGED
|
@@ -220,3 +220,29 @@ export type JobSettingsResponse = {
|
|
|
220
220
|
success: true;
|
|
221
221
|
jobs: JobSettings;
|
|
222
222
|
};
|
|
223
|
+
/**
|
|
224
|
+
* Why a resume answered as it did.
|
|
225
|
+
*
|
|
226
|
+
* `resumed` is the job queued again; the rest are why it was left where it is — the owner's
|
|
227
|
+
* tier does not allow the job to run, today's allowance is spent, or the server refused for a
|
|
228
|
+
* reason of its own.
|
|
229
|
+
*/
|
|
230
|
+
export type JobResumeReason = "resumed" | "over_tier_limit" | "allowance_spent" | "refused";
|
|
231
|
+
/** What the user can do about a job that was not resumed. */
|
|
232
|
+
export type JobResumeAction = "raise_allowance" | "upgrade_tier" | "wait";
|
|
233
|
+
/**
|
|
234
|
+
* A job after a resume was asked for.
|
|
235
|
+
*
|
|
236
|
+
* `resumed` says whether it is queued again; when it is not, `reason` and `action` say why and
|
|
237
|
+
* what would change it, and `wakeAt` is the earliest the runner would pick it up on its own,
|
|
238
|
+
* in epoch milliseconds. `message` is the same thing in a sentence or two, ready to show.
|
|
239
|
+
*/
|
|
240
|
+
export type JobResumeResponse = {
|
|
241
|
+
success: true;
|
|
242
|
+
resumed: boolean;
|
|
243
|
+
reason: JobResumeReason;
|
|
244
|
+
action?: JobResumeAction;
|
|
245
|
+
wakeAt?: number;
|
|
246
|
+
message: string;
|
|
247
|
+
job: JobView;
|
|
248
|
+
};
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -335,6 +335,7 @@ const { entries, hasMore } = await client.getJobJournal({ jobId, page: 2 });
|
|
|
335
335
|
await client.updateJob({ jobId, title: "Flat hunt", autonomy: "free", autonomyUntil: Date.now() + 86_400_000, capUsd: 5 });
|
|
336
336
|
await client.setPhaseModel({ jobId, phaseId: "search", model: "Butler-Auto-Smart" });
|
|
337
337
|
await client.cancelJob({ jobId });
|
|
338
|
+
const { resumed, reason, action, message } = await client.resumeJob({ jobId });
|
|
338
339
|
```
|
|
339
340
|
|
|
340
341
|
`getJob` carries the newest page of the journal and `journalTotal`; `getJobJournal` pages the rest,
|
|
@@ -343,6 +344,10 @@ an older page exists. Each entry says which shift wrote it (`shiftIndex`, `shift
|
|
|
343
344
|
model. A job's `title` is a few words of its own, set at start or renamed with `updateJob`, which
|
|
344
345
|
also takes `capUsd`, a ceiling on what the job may spend in all (null clears it). `setPhaseModel`
|
|
345
346
|
changes the model a phase that has not started runs on, to one of the detail's `phaseModels`.
|
|
347
|
+
`resumeJob` continues a job parked as `waiting_budget` when there is room for it again: it answers
|
|
348
|
+
with `resumed`, a `reason` of `resumed`, `over_tier_limit`, `allowance_spent` or `refused`, an
|
|
349
|
+
`action` of `raise_allowance`, `upgrade_tier` or `wait` when there is one, a `wakeAt` when the job
|
|
350
|
+
would carry on by itself, and a `message` written for the user. A job in any other status is a 409.
|
|
346
351
|
|
|
347
352
|
Paging is 1-based, and every listing answers with `page`, `limit` and `total`. A listing also
|
|
348
353
|
carries `allowance` — what this user's jobs may spend today and what is left of it, or
|