@rackbops/docket-types 0.7.0 → 0.9.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/README.md +54 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/research-answer.d.ts +76 -2
- package/dist/research-answer.d.ts.map +1 -1
- package/dist/research-answer.js +68 -2
- package/dist/research-answer.js.map +1 -1
- package/dist/research-sources.d.ts +77 -0
- package/dist/research-sources.d.ts.map +1 -0
- package/dist/research-sources.js +114 -0
- package/dist/research-sources.js.map +1 -0
- package/dist/research.d.ts +76 -9
- package/dist/research.d.ts.map +1 -1
- package/dist/research.js +399 -74
- package/dist/research.js.map +1 -1
- package/package.json +2 -2
package/dist/research.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { type JobSpec } from "@rackbops/docket-core";
|
|
2
|
-
import { type ResearchAnswer } from "./research-answer.js";
|
|
1
|
+
import { type JobSpec, type TaskType } from "@rackbops/docket-core";
|
|
2
|
+
import { type BlockedPage, type ResearchAnswer } from "./research-answer.js";
|
|
3
|
+
import { type GatheredPage, type ReadSources } from "./research-sources.js";
|
|
3
4
|
/**
|
|
4
5
|
* Category 5 (plan section 1.2 row 5): "look into X and report back once". Execute lane, a `once`
|
|
5
6
|
* schedule, tier 0 only. Two model runs per request, both `claude -p` Jobs the runner executes
|
|
@@ -16,6 +17,28 @@ import { type ResearchAnswer } from "./research-answer.js";
|
|
|
16
17
|
* An optional `deadline` (plan 1.2 row 5) goes into the prompt; a research run that would start
|
|
17
18
|
* after it makes no model call and tells the owner the deadline was missed.
|
|
18
19
|
*
|
|
20
|
+
* With `sources: "sent"` (0.8.0, rackbops-bot-plugins#125), the request answers from pages the
|
|
21
|
+
* person's own browser gathered and the host stored (`research-sources.ts`): each run reads them
|
|
22
|
+
* through the host's `ReadSources` (`researchType({ readSources })`) and quotes them into its
|
|
23
|
+
* prompt, and neither run may fetch BoardGameGeek or eBay. When the run starts is the host's: it
|
|
24
|
+
* moves the run to now once the pages are in. A run that finds no usable page makes no model call
|
|
25
|
+
* and tells the owner so, and so does a host that cannot read them.
|
|
26
|
+
*
|
|
27
|
+
* **A second pass on pages the run could not open** (0.9.0): a research run lists in `blocked` the
|
|
28
|
+
* pages it needed and could not open (BoardGameGeek refuses the runner; eBay is never opened). When
|
|
29
|
+
* the reviewed answer passes, the research run's own draft lists any, the request is a `web` one,
|
|
30
|
+
* and the host can read gathered pages (`readSources`), the owner gets the answer now with a short
|
|
31
|
+
* "Couldn't open:" list. With at least `MIN_SOURCES_WAIT_MS` (an hour) before `sourcesExpiry` (14
|
|
32
|
+
* days, or 10 minutes before a sooner deadline), the DM also says a fuller pass is queued, and the
|
|
33
|
+
* task waits (`awaiting-pages`) on a follow-up at that expiry, so the wait sends nothing, runs
|
|
34
|
+
* nothing and charges nothing; with less, the task ends there. The findings are saved either way.
|
|
35
|
+
* The host's `ready` (README: the contract) moves the once task to now and deletes that follow-up.
|
|
36
|
+
* Then a second research run gets the pages and the earlier answer and returns only new or
|
|
37
|
+
* corrected findings; its reviewer checks them as an update to the earlier answer, against the
|
|
38
|
+
* pages, and the owner gets an "Update to" DM (one line when it adds nothing), its findings tagged
|
|
39
|
+
* `update` beside the first pass's. With no pages, past the deadline, or on a second-pass failure,
|
|
40
|
+
* the task ends with one short line: the first answer stands, uncharged when no run was made.
|
|
41
|
+
*
|
|
19
42
|
* Failures (a usage limit never reaches `finish`: the dispatcher requeues the run):
|
|
20
43
|
*
|
|
21
44
|
* - `schema_miss`, a malformed answer, `timeout`, `error`: retried once in the same phase, at once.
|
|
@@ -36,14 +59,31 @@ export interface ResearchConfig {
|
|
|
36
59
|
context?: string;
|
|
37
60
|
/** When the person needs the answer by, an ISO-8601 instant; past it, nothing is run. */
|
|
38
61
|
deadline?: string;
|
|
62
|
+
/**
|
|
63
|
+
* Where the pages come from: `web` (the default), the runs search and fetch them; `sent`, the
|
|
64
|
+
* person's own browser gathers them and the host stores them (`ReadSources`).
|
|
65
|
+
*/
|
|
66
|
+
sources?: "web" | "sent";
|
|
39
67
|
}
|
|
40
|
-
|
|
68
|
+
/** True when `config` asks for gathered pages. */
|
|
69
|
+
export declare function usesSentSources(config: ResearchConfig): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* `awaiting-pages` (0.9.0): the first answer went out, and the task waits for gathered pages for a
|
|
72
|
+
* second pass; its run is the second pass's research run.
|
|
73
|
+
*/
|
|
74
|
+
export type ResearchPhase = "research" | "review" | "awaiting-pages" | "done";
|
|
41
75
|
/** The current row: which run is next, how often it failed, and the draft once there is one. */
|
|
42
76
|
export interface ResearchState {
|
|
43
77
|
phase: ResearchPhase;
|
|
44
78
|
/** Failed tries in the current phase. */
|
|
45
79
|
failures: number;
|
|
46
80
|
draft: ResearchAnswer | null;
|
|
81
|
+
/** Which pass (0.9.0): 2 once the second pass's research run has answered. Absent: the first. */
|
|
82
|
+
pass?: 1 | 2;
|
|
83
|
+
/** The pages the first pass could not open, as its research run listed them. */
|
|
84
|
+
blocked?: BlockedPage[];
|
|
85
|
+
/** The first pass's reviewed answer, as sent: what the second pass builds on. */
|
|
86
|
+
earlier?: ResearchAnswer;
|
|
47
87
|
}
|
|
48
88
|
export declare const MAX_QUESTION_CHARS = 1000;
|
|
49
89
|
export declare const MAX_CONTEXT_CHARS = 2000;
|
|
@@ -70,7 +110,11 @@ export declare const RESEARCH_TIMEOUT_MS = 600000;
|
|
|
70
110
|
export declare const REVIEW_MAX_TURNS = 8;
|
|
71
111
|
export declare const REVIEW_MAX_BUDGET_USD = 0.5;
|
|
72
112
|
export declare const REVIEW_TIMEOUT_MS = 300000;
|
|
73
|
-
/**
|
|
113
|
+
/**
|
|
114
|
+
* The state as stored, or a fresh one; a review phase with no readable draft starts over (in the
|
|
115
|
+
* second pass, from the wait for pages). A wait for pages with no readable earlier answer has
|
|
116
|
+
* nothing to build on, so it is done. A state stored before 0.9.0 reads as it did.
|
|
117
|
+
*/
|
|
74
118
|
export declare function researchState(value: unknown): ResearchState;
|
|
75
119
|
/** The deadline as an instant, or null when there is none or it does not parse. */
|
|
76
120
|
export declare function deadlineOf(config: ResearchConfig): Date | null;
|
|
@@ -79,9 +123,32 @@ export declare function deadlineOf(config: ResearchConfig): Date | null;
|
|
|
79
123
|
* it or open anything that looks like markup; a JSON parser reads it back unchanged.
|
|
80
124
|
*/
|
|
81
125
|
export declare function draftJson(draft: ResearchAnswer): string;
|
|
82
|
-
/**
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
126
|
+
/**
|
|
127
|
+
* The research run: the spike's prompt (docket-runner spike/cases.json, case `research`), with the
|
|
128
|
+
* gathered pages when `pages` is given (`sources: "sent"`, or a second pass). With `earlier`, the
|
|
129
|
+
* second pass (0.9.0): the answer already sent goes in as escaped JSON between markers, and the
|
|
130
|
+
* run answers with only what the pages add or correct.
|
|
131
|
+
*/
|
|
132
|
+
export declare function researchJob(config: ResearchConfig, pages?: readonly GatheredPage[], earlier?: ResearchAnswer): JobSpec;
|
|
133
|
+
/**
|
|
134
|
+
* The reviewer run: the question, and the draft as escaped JSON between markers; with `pages`
|
|
135
|
+
* (`sources: "sent"`), the same gathered pages the research run had, to check its claims against.
|
|
136
|
+
*/
|
|
137
|
+
export declare function reviewJob(config: ResearchConfig, draft: ResearchAnswer, pages?: readonly GatheredPage[], earlier?: ResearchAnswer): JobSpec;
|
|
138
|
+
/**
|
|
139
|
+
* The shortest wait for pages worth starting (0.9.0): with less than this before the expiry, a
|
|
140
|
+
* person has no real chance to gather pages, so the answer goes out as it is.
|
|
141
|
+
*/
|
|
142
|
+
export declare const MIN_SOURCES_WAIT_MS = 3600000;
|
|
143
|
+
export interface ResearchOptions {
|
|
144
|
+
/** The host's store of gathered pages; without it, a `sources: "sent"` request is not run. */
|
|
145
|
+
readSources?: ReadSources;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* The research type over a host's options: `research` itself has none, so it runs `web` requests
|
|
149
|
+
* only and tells the owner a `sent` one cannot be run here.
|
|
150
|
+
*/
|
|
151
|
+
export declare function researchType(options?: ResearchOptions): TaskType<ResearchConfig>;
|
|
152
|
+
/** The research type with no host options: `web` requests only. */
|
|
153
|
+
export declare const research: TaskType<ResearchConfig>;
|
|
87
154
|
//# sourceMappingURL=research.d.ts.map
|
package/dist/research.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"research.d.ts","sourceRoot":"","sources":["../src/research.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,OAAO,
|
|
1
|
+
{"version":3,"file":"research.d.ts","sourceRoot":"","sources":["../src/research.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,OAAO,EAIZ,KAAK,QAAQ,EACd,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAEL,KAAK,WAAW,EAQhB,KAAK,cAAc,EAIpB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EACL,KAAK,YAAY,EAGjB,KAAK,WAAW,EAGjB,MAAM,uBAAuB,CAAA;AAE9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AAEH,MAAM,WAAW,cAAc;IAC7B,yBAAyB;IACzB,QAAQ,EAAE,MAAM,CAAA;IAChB,iFAAiF;IACjF,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,yFAAyF;IACzF,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;;OAGG;IACH,OAAO,CAAC,EAAE,KAAK,GAAG,MAAM,CAAA;CACzB;AAED,kDAAkD;AAClD,wBAAgB,eAAe,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAE/D;AAED;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,UAAU,GAAG,QAAQ,GAAG,gBAAgB,GAAG,MAAM,CAAA;AAE7E,gGAAgG;AAChG,MAAM,WAAW,aAAa;IAC5B,KAA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