@butlerbot/sdk 0.0.37 → 0.0.38
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/index.d.ts +3 -1
- package/dist/index.js +4 -0
- package/dist/modules/jobs.d.ts +17 -1
- package/dist/modules/jobs.js +17 -1
- package/dist/types/jobs/job.d.ts +15 -1
- package/package.json +1 -1
- package/readme.md +5 -2
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 ListJobsOptions, type UpdateJobOptions, type UpdateJobSettingsOptions } from "./modules/jobs";
|
|
5
|
+
import { type CancelJobOptions, type GetJobJournalOptions, type GetJobOptions, type SetPhaseModelOptions, type ListJobsOptions, 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 */
|
|
@@ -54,6 +54,8 @@ export declare class ButlerBotClient {
|
|
|
54
54
|
cancelJob(config: OptionalApiKey<CancelJobOptions>): Promise<import("./types/type_registry").JobCancelResponse>;
|
|
55
55
|
/** Changes one job's name, and its autonomy: how far it may act, until when, and what it always asks about */
|
|
56
56
|
updateJob(config: OptionalApiKey<UpdateJobOptions>): Promise<import("./types/type_registry").JobUpdateResponse>;
|
|
57
|
+
/** Changes the model one phase of a job's plan runs on; only a phase that has not started */
|
|
58
|
+
setPhaseModel(config: OptionalApiKey<SetPhaseModelOptions>): Promise<import("./types/type_registry").JobPhaseModelResponse>;
|
|
57
59
|
/** Changes this user's job settings: their daily allowance and what new jobs start with */
|
|
58
60
|
updateJobSettings(config?: OptionalApiKey<UpdateJobSettingsOptions>): Promise<import("./types/type_registry").JobSettingsResponse>;
|
|
59
61
|
/** A page of the inbox: what Alfred has told or asked this user outside a chat */
|
package/dist/index.js
CHANGED
|
@@ -92,6 +92,10 @@ class ButlerBotClient {
|
|
|
92
92
|
updateJob(config) {
|
|
93
93
|
return (0, jobs_1.updateJob)(this.forRequest(config));
|
|
94
94
|
}
|
|
95
|
+
/** Changes the model one phase of a job's plan runs on; only a phase that has not started */
|
|
96
|
+
setPhaseModel(config) {
|
|
97
|
+
return (0, jobs_1.setPhaseModel)(this.forRequest(config));
|
|
98
|
+
}
|
|
95
99
|
/** Changes this user's job settings: their daily allowance and what new jobs start with */
|
|
96
100
|
updateJobSettings(config = {}) {
|
|
97
101
|
return (0, jobs_1.updateJobSettings)(this.forRequest(config));
|
package/dist/modules/jobs.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { JobAutonomy, JobCancelResponse, JobDetailResponse, JobJournalPage, JobListResponse, JobSettingsResponse, JobSettingsUpdate, JobStatus, JobUpdateResponse } from "../types/jobs";
|
|
1
|
+
import type { JobAutonomy, JobCancelResponse, JobDetailResponse, JobJournalPage, JobListResponse, JobPhaseModelResponse, 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;
|
|
@@ -38,6 +38,15 @@ export type UpdateJobOptions = JobsRequestOptions & {
|
|
|
38
38
|
autonomyUntil?: string | number | null;
|
|
39
39
|
/** Things this job asks about however free it otherwise is. */
|
|
40
40
|
alwaysAsk?: string[];
|
|
41
|
+
/** A ceiling on what the job may spend in all, in dollars. Null clears it. */
|
|
42
|
+
capUsd?: number | null;
|
|
43
|
+
};
|
|
44
|
+
export type SetPhaseModelOptions = JobsRequestOptions & {
|
|
45
|
+
jobId: string;
|
|
46
|
+
/** The phase's id as the plan names it. */
|
|
47
|
+
phaseId: string;
|
|
48
|
+
/** One of the detail's `phaseModels`. */
|
|
49
|
+
model: string;
|
|
41
50
|
};
|
|
42
51
|
export type UpdateJobSettingsOptions = JobsRequestOptions & JobSettingsUpdate;
|
|
43
52
|
/** A page of the caller's jobs, newest first, with what their jobs may spend today. */
|
|
@@ -55,5 +64,12 @@ export declare function getJobJournal(options: GetJobJournalOptions): Promise<Jo
|
|
|
55
64
|
export declare function cancelJob(options: CancelJobOptions): Promise<JobCancelResponse>;
|
|
56
65
|
/** Changes one job's name, and its autonomy: how far it may act, until when, and what it always asks about. */
|
|
57
66
|
export declare function updateJob(options: UpdateJobOptions): Promise<JobUpdateResponse>;
|
|
67
|
+
/**
|
|
68
|
+
* Changes the model one phase of a job's plan runs on.
|
|
69
|
+
*
|
|
70
|
+
* Only a phase that has not started or is blocked: a running or done phase's model is what its
|
|
71
|
+
* work ran on. A model the owner's plan cannot run is a 400 whose body names the ones it can.
|
|
72
|
+
*/
|
|
73
|
+
export declare function setPhaseModel(options: SetPhaseModelOptions): Promise<JobPhaseModelResponse>;
|
|
58
74
|
/** Changes the owner's job settings: their daily allowance and the autonomy new jobs start with. */
|
|
59
75
|
export declare function updateJobSettings(options: UpdateJobSettingsOptions): Promise<JobSettingsResponse>;
|
package/dist/modules/jobs.js
CHANGED
|
@@ -5,6 +5,7 @@ exports.getJob = getJob;
|
|
|
5
5
|
exports.getJobJournal = getJobJournal;
|
|
6
6
|
exports.cancelJob = cancelJob;
|
|
7
7
|
exports.updateJob = updateJob;
|
|
8
|
+
exports.setPhaseModel = setPhaseModel;
|
|
8
9
|
exports.updateJobSettings = updateJobSettings;
|
|
9
10
|
const config_1 = require("../config");
|
|
10
11
|
const url_formatter_1 = require("../util/url_formatter");
|
|
@@ -56,10 +57,25 @@ async function updateJob(options) {
|
|
|
56
57
|
return (0, api_request_1.requestAPI)({
|
|
57
58
|
url,
|
|
58
59
|
method: "PATCH",
|
|
59
|
-
body: body({ title: options.title, autonomy: options.autonomy, autonomyUntil: options.autonomyUntil, alwaysAsk: options.alwaysAsk }),
|
|
60
|
+
body: body({ title: options.title, autonomy: options.autonomy, autonomyUntil: options.autonomyUntil, alwaysAsk: options.alwaysAsk, capUsd: options.capUsd }),
|
|
60
61
|
action: `update job ${options.jobId}`,
|
|
61
62
|
});
|
|
62
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Changes the model one phase of a job's plan runs on.
|
|
66
|
+
*
|
|
67
|
+
* Only a phase that has not started or is blocked: a running or done phase's model is what its
|
|
68
|
+
* work ran on. A model the owner's plan cannot run is a 400 whose body names the ones it can.
|
|
69
|
+
*/
|
|
70
|
+
async function setPhaseModel(options) {
|
|
71
|
+
const url = (0, url_formatter_1.formatURL)(`${jobsBase(options)}/${encodeURIComponent(options.jobId)}/plan/${encodeURIComponent(options.phaseId)}`, {}, { apiKey: options.apiKey, debug: options.debug });
|
|
72
|
+
return (0, api_request_1.requestAPI)({
|
|
73
|
+
url,
|
|
74
|
+
method: "PATCH",
|
|
75
|
+
body: { model: options.model },
|
|
76
|
+
action: `set the model of phase ${options.phaseId} of job ${options.jobId}`,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
63
79
|
/** Changes the owner's job settings: their daily allowance and the autonomy new jobs start with. */
|
|
64
80
|
async function updateJobSettings(options) {
|
|
65
81
|
const endpoint = (options.serverURL || config_1.CONFIG.server) + (options.path || config_1.CONFIG.paths.jobs.settings);
|
package/dist/types/jobs/job.d.ts
CHANGED
|
@@ -31,6 +31,13 @@ export type JobView = {
|
|
|
31
31
|
reviewRounds: number;
|
|
32
32
|
/** What the job has spent in total, in USD. */
|
|
33
33
|
spentUsd: number;
|
|
34
|
+
/**
|
|
35
|
+
* A ceiling on what this job may spend over its whole life, in dollars, or null for none.
|
|
36
|
+
*
|
|
37
|
+
* Measured against everything the job and its sub-jobs have spent. A job that reaches it
|
|
38
|
+
* with work left parks blocked and asks; raising it starts the job again.
|
|
39
|
+
*/
|
|
40
|
+
capUsd: number | null;
|
|
34
41
|
/** What the job has spent today, in USD. */
|
|
35
42
|
spendTodayUsd: number;
|
|
36
43
|
/** How many questions of this job's are waiting on the user. */
|
|
@@ -73,7 +80,7 @@ export type JobAllowanceRefused = {
|
|
|
73
80
|
export type JobAllowance = JobAllowanceGranted | JobAllowanceRefused;
|
|
74
81
|
/** Whether an allowance is a refusal rather than a grant. */
|
|
75
82
|
export declare function isJobAllowanceRefused(allowance: JobAllowance): allowance is JobAllowanceRefused;
|
|
76
|
-
export type JobPlanPhaseKind = "plan" | "work" | "review";
|
|
83
|
+
export type JobPlanPhaseKind = "plan" | "work" | "map" | "review";
|
|
77
84
|
export type JobPlanPhaseStatus = "pending" | "running" | "blocked" | "done";
|
|
78
85
|
/** One phase of a job's plan, as the plan card spells it out. */
|
|
79
86
|
export type JobPlanPhase = {
|
|
@@ -182,6 +189,13 @@ export type JobDetailResponse = {
|
|
|
182
189
|
journalTotal: number;
|
|
183
190
|
/** Questions of this job's nobody has answered yet. */
|
|
184
191
|
openDeliveries: Delivery[];
|
|
192
|
+
/** The model names a phase of this job may be set to: the aliases first, then the tier's models. */
|
|
193
|
+
phaseModels: string[];
|
|
194
|
+
};
|
|
195
|
+
/** A phase after its model was changed. */
|
|
196
|
+
export type JobPhaseModelResponse = {
|
|
197
|
+
success: true;
|
|
198
|
+
phase: JobPlanPhase;
|
|
185
199
|
};
|
|
186
200
|
/** One page of a job's journal. Page 1 is the newest; within a page the entries are in written order. */
|
|
187
201
|
export type JobJournalPage = {
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -332,14 +332,17 @@ const { jobs, allowance, spentTodayUsd } = await client.listJobs({ status: "runn
|
|
|
332
332
|
const { job, plan, journal, journalTotal, openDeliveries, autonomyLine } = await client.getJob({ jobId });
|
|
333
333
|
const { entries, hasMore } = await client.getJobJournal({ jobId, page: 2 });
|
|
334
334
|
|
|
335
|
-
await client.updateJob({ jobId, title: "Flat hunt", autonomy: "free", autonomyUntil: Date.now() + 86_400_000 });
|
|
335
|
+
await client.updateJob({ jobId, title: "Flat hunt", autonomy: "free", autonomyUntil: Date.now() + 86_400_000, capUsd: 5 });
|
|
336
|
+
await client.setPhaseModel({ jobId, phaseId: "search", model: "Butler-Auto-Smart" });
|
|
336
337
|
await client.cancelJob({ jobId });
|
|
337
338
|
```
|
|
338
339
|
|
|
339
340
|
`getJob` carries the newest page of the journal and `journalTotal`; `getJobJournal` pages the rest,
|
|
340
341
|
newest page first, with each page in the order its entries were written and `hasMore` saying whether
|
|
341
342
|
an older page exists. Each entry says which shift wrote it (`shiftIndex`, `shiftKind`) and on which
|
|
342
|
-
model. A job's `title` is a few words of its own, set at start or renamed with `updateJob
|
|
343
|
+
model. A job's `title` is a few words of its own, set at start or renamed with `updateJob`, which
|
|
344
|
+
also takes `capUsd`, a ceiling on what the job may spend in all (null clears it). `setPhaseModel`
|
|
345
|
+
changes the model a phase that has not started runs on, to one of the detail's `phaseModels`.
|
|
343
346
|
|
|
344
347
|
Paging is 1-based, and every listing answers with `page`, `limit` and `total`. A listing also
|
|
345
348
|
carries `allowance` — what this user's jobs may spend today and what is left of it, or
|