- MCP
- code on this site's /mcp
- CLI
- none: the JSON below is the answer
- JSON
- /christopher/abso-core/files/server/src/issues/index.ts?format=json
64 linestrials 97% · speed 3%Last change trials in version 151, 1 version changed it
1// Issues, asks and news for the open server: one IssueProject Durable Object per project (bound as ISSUES_DO,
2// named by the project's name), reached through issuesFetch from the Worker's /issues/p/:project/... routes.
3// The logic is in serve.ts, store.ts and routes.ts, which run under node --test without Cloudflare's runtime.
4//
5// GET /issues/p/:project/issues[?status=&agent=&parent=&label=&open=1] issues, most recently updated first
6// GET /issues/p/:project/issue/:n one issue with its comments, edits and asks
7// GET /issues/p/:project/search?q=[&limit=] full-text search
8// GET /issues/p/:project/labels | changes | waiting[?of=] | ask/:n | asked?by= | answered?of=
9// GET /issues/p/:project/a/:agent/waiting | asked | drafts | news[?before=]
10// POST /issues/p/:project/a/:agent/issue | ask | answer/:n | ack/:n | reply/:n | withdraw/:n
11// POST /issues/p/:project/a/:agent/issue/:n/comment | edit | drop | reopen | done
12// POST /issues/p/:project/a/:agent/draft | draft/:n/open | draft/:n/delete | news/read
14import { DurableObject } from "cloudflare:workers";
15import { type IssuesEnv, IssuesObject } from "./serve.ts";
16import type { News } from "./store.ts";
18export {
19 type IssueNews,
20 type IssuesAuth,
21 type IssuesEnv,
22 issuesFetch,
23 type NamespaceLike,
24 type ProjectHooks,
25 type WaitUntil,
26} from "./serve.ts";
28/** One project's issues, in its own SQLite. */
29export class IssueProject extends DurableObject<IssuesEnv> {
30 private readonly issues: IssuesObject;
32 constructor(ctx: DurableObjectState, env: IssuesEnv) {
33 super(ctx, env);
34 // The migrations are synchronous SQL, so they finish here, before the object takes any request.
35 this.issues = new IssuesObject(
36 { sql: ctx.storage.sql, transactionSync: (action) => ctx.storage.transactionSync(action) },
37 env,
38 );
39 }
41 async fetch(request: Request): Promise<Response> {
42 return this.issues.fetch(request);
43 }
45 /** A start note names the issue; `change` is the note's log position. A missing or closed issue is ignored. */
46 async claim(agent: string, issue: number, change: number): Promise<void> {
47 this.issues.store.claim(agent, issue, change);
48 }
50 /** The start note ended without finishing the issue. */
51 async unclaim(agent: string, issue: number): Promise<void> {
52 this.issues.store.unclaim(agent, issue);
53 }
55 /** publish --done finished the issue in `version`: done, and its news for the project to deliver. */
56 async done(agent: string, issue: number, version: number): Promise<{ news?: News }> {
57 return this.issues.store.done(agent, issue, version);
58 }
60 /** How many schema migrations this object has run. */
61 async schema(): Promise<{ migrations: number }> {
62 return { migrations: this.issues.migrations() };
63 }
64}