@heedwork/engine 0.0.0-stage → 0.2.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/dist/agent-auth.d.ts +9 -0
- package/dist/api-response.d.ts +8 -0
- package/dist/app.d.ts +28 -0
- package/dist/auth.d.ts +18 -0
- package/dist/basic-limits.d.ts +13 -0
- package/dist/command-api.d.ts +14 -0
- package/dist/command-provider.d.ts +43 -0
- package/dist/command-tools.d.ts +177 -0
- package/dist/human-api.d.ts +4 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +5192 -0
- package/dist/judge.d.ts +12 -0
- package/dist/mcp.d.ts +25 -0
- package/dist/oauth-consent.d.ts +1 -0
- package/dist/oauth-storage.d.ts +65 -0
- package/dist/oauth.d.ts +3 -0
- package/dist/seams.d.ts +107 -0
- package/dist/session.d.ts +6 -0
- package/dist/signed-cookie.d.ts +6 -0
- package/dist/token-admin.d.ts +5 -0
- package/dist/token-secrets.d.ts +8 -0
- package/dist/web-push.d.ts +38 -0
- package/dist/worker.d.ts +10 -0
- package/dist/workspace-export.d.ts +7 -0
- package/dist/workspace-migrations.d.ts +1 -0
- package/dist/workspace.d.ts +331 -0
- package/package.json +36 -4
- package/README.md +0 -3
package/dist/judge.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AppContext } from "./app.js";
|
|
2
|
+
import type { getWorkspaceStub } from "./workspace.js";
|
|
3
|
+
export interface JudgingInput {
|
|
4
|
+
item_id: string;
|
|
5
|
+
status_event_id: number;
|
|
6
|
+
title: string;
|
|
7
|
+
criteria: string[];
|
|
8
|
+
evidence: string | null;
|
|
9
|
+
note: string | null;
|
|
10
|
+
guidance: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function scheduleJudge(app: AppContext, workspaceId: string, workspace: ReturnType<typeof getWorkspaceStub>, input: JudgingInput): void;
|
package/dist/mcp.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Actor } from "@heedwork/core";
|
|
2
|
+
import type { Workspace } from "./workspace.js";
|
|
3
|
+
import type { LimitAction, Limits } from "./seams.js";
|
|
4
|
+
import type { JudgingInput } from "./judge.js";
|
|
5
|
+
type Agent = Extract<Actor, {
|
|
6
|
+
kind: "agent";
|
|
7
|
+
}>;
|
|
8
|
+
type McpWorkspace = Pick<Workspace, "getCanvas" | "getGuidance" | "addItem" | "updateExistingItem" | "reportProgress" | "updateItem" | "setDependency" | "flagHandoff" | "reopenItem" | "setGuidance">;
|
|
9
|
+
type McpContext = {
|
|
10
|
+
workspaceId: string;
|
|
11
|
+
limits: Limits;
|
|
12
|
+
recordWrite: (operation: string) => void;
|
|
13
|
+
recordJudgingInput: (input: JudgingInput) => void;
|
|
14
|
+
oauth: boolean;
|
|
15
|
+
};
|
|
16
|
+
export type McpLimitCheck = (action: LimitAction) => Promise<{
|
|
17
|
+
ok: true;
|
|
18
|
+
pushCap?: number;
|
|
19
|
+
} | {
|
|
20
|
+
ok: false;
|
|
21
|
+
reason: string;
|
|
22
|
+
}>;
|
|
23
|
+
export declare function mcpLimits(check: McpLimitCheck): Limits;
|
|
24
|
+
export declare function handleMcp(request: Request, actor: Agent, workspace: McpWorkspace, context: McpContext): Promise<Response>;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function consentPage(client: string, redirectUri: string, workspace: string, csrf: string): Response;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { ConnectedApp, Scope } from "@heedwork/core";
|
|
2
|
+
type ClientAuth = "none" | "client_secret_basic" | "client_secret_post";
|
|
3
|
+
export interface OAuthClient {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
redirectUris: string[];
|
|
7
|
+
authMethod: ClientAuth;
|
|
8
|
+
secretHash: string | null;
|
|
9
|
+
refresh: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface OAuthAuthorization {
|
|
12
|
+
client: Pick<OAuthClient, "id" | "name" | "authMethod" | "secretHash" | "refresh">;
|
|
13
|
+
redirectUri: string;
|
|
14
|
+
challenge: string;
|
|
15
|
+
resource: string;
|
|
16
|
+
state: string | null;
|
|
17
|
+
}
|
|
18
|
+
type ConsentDecision = {
|
|
19
|
+
label: string;
|
|
20
|
+
scope: Scope;
|
|
21
|
+
} | null;
|
|
22
|
+
export interface OAuthExchange {
|
|
23
|
+
clientId: string;
|
|
24
|
+
authMethod: ClientAuth;
|
|
25
|
+
clientSecretHash: string | null;
|
|
26
|
+
resource: string;
|
|
27
|
+
secret: string;
|
|
28
|
+
grant: {
|
|
29
|
+
type: "code";
|
|
30
|
+
redirectUri: string;
|
|
31
|
+
challenge: string;
|
|
32
|
+
} | {
|
|
33
|
+
type: "refresh";
|
|
34
|
+
scope: string | null;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export declare const CONSENT_SECONDS: number;
|
|
38
|
+
export declare class OAuthStorage {
|
|
39
|
+
private readonly storage;
|
|
40
|
+
private readonly workspaceId;
|
|
41
|
+
constructor(storage: DurableObjectStorage, workspaceId: string | undefined);
|
|
42
|
+
register(client: OAuthClient): void;
|
|
43
|
+
findClient(id: string): OAuthClient | null;
|
|
44
|
+
beginConsent(csrf: string, userId: string, request: OAuthAuthorization): Promise<void>;
|
|
45
|
+
finishConsent(csrf: string, userId: string, resource: string, decision: ConsentDecision): Promise<{
|
|
46
|
+
authorization: OAuthAuthorization;
|
|
47
|
+
code: null;
|
|
48
|
+
} | {
|
|
49
|
+
authorization: OAuthAuthorization;
|
|
50
|
+
code: string;
|
|
51
|
+
} | null>;
|
|
52
|
+
exchange(input: OAuthExchange): Promise<{
|
|
53
|
+
error: string;
|
|
54
|
+
} | {
|
|
55
|
+
scope: "steer" | "report";
|
|
56
|
+
refresh_token?: string | undefined;
|
|
57
|
+
access_token: string;
|
|
58
|
+
token_type: string;
|
|
59
|
+
expires_in: number;
|
|
60
|
+
error?: undefined;
|
|
61
|
+
}>;
|
|
62
|
+
list(): ConnectedApp[];
|
|
63
|
+
revoke(id: string): boolean;
|
|
64
|
+
}
|
|
65
|
+
export {};
|
package/dist/oauth.d.ts
ADDED
package/dist/seams.d.ts
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { JudgeConfiguration, JudgeLimitAction, JudgeUsage, WorkspaceUser } from "@heedwork/core";
|
|
2
|
+
import type { CommandProvider } from "./command-provider.js";
|
|
3
|
+
export interface WorkspaceSession {
|
|
4
|
+
workspaceId: string;
|
|
5
|
+
user: WorkspaceUser;
|
|
6
|
+
role: string;
|
|
7
|
+
}
|
|
8
|
+
/** Resolves browser sessions and routes agent tokens without opening a Workspace. */
|
|
9
|
+
export interface AuthProvider {
|
|
10
|
+
/** Return the signed-in user and their current workspace, or null. */
|
|
11
|
+
session(request: Request): Promise<WorkspaceSession | null>;
|
|
12
|
+
/** Handle host sign-in routes under /auth/. */
|
|
13
|
+
handleAuthRoute(request: Request): Promise<Response>;
|
|
14
|
+
/** Start browser sign-in and resume at the given same-origin path.
|
|
15
|
+
* Defaults to /auth/login with a returnTo query parameter. */
|
|
16
|
+
signIn?(request: Request, returnTo: string): Response | Promise<Response>;
|
|
17
|
+
/** Route a full bearer token to an existing workspace without a Durable Object lookup. */
|
|
18
|
+
workspaceForToken(token: string): Promise<string | null>;
|
|
19
|
+
}
|
|
20
|
+
export type LimitAction = "item.create" | "project.create" | "token.create" | "command" | "transcribe" | JudgeLimitAction | "push" | "connect";
|
|
21
|
+
export type LimitDecision = {
|
|
22
|
+
ok: true;
|
|
23
|
+
} | {
|
|
24
|
+
ok: false;
|
|
25
|
+
reason: string;
|
|
26
|
+
};
|
|
27
|
+
/** Authorizes workspace actions and supplies a user-facing reason on refusal. */
|
|
28
|
+
export interface Limits {
|
|
29
|
+
check(workspaceId: string, action: LimitAction): Promise<LimitDecision>;
|
|
30
|
+
}
|
|
31
|
+
export type UsageEvent = {
|
|
32
|
+
type: "command";
|
|
33
|
+
model: string;
|
|
34
|
+
inputTokens: number | null;
|
|
35
|
+
outputTokens: number | null;
|
|
36
|
+
} | {
|
|
37
|
+
type: "transcribe";
|
|
38
|
+
seconds: number;
|
|
39
|
+
} | JudgeUsage | {
|
|
40
|
+
type: "push";
|
|
41
|
+
count: number;
|
|
42
|
+
} | {
|
|
43
|
+
type: "agent.write";
|
|
44
|
+
operation: string;
|
|
45
|
+
};
|
|
46
|
+
/** Receives usage in a background task registered with waitUntil. */
|
|
47
|
+
export interface UsageSink {
|
|
48
|
+
record(workspaceId: string, event: UsageEvent): Promise<void>;
|
|
49
|
+
}
|
|
50
|
+
export interface CommandConfiguration {
|
|
51
|
+
command?: CommandProvider;
|
|
52
|
+
transcribe?(audio: Uint8Array): Promise<string>;
|
|
53
|
+
}
|
|
54
|
+
export interface CommandKeys {
|
|
55
|
+
configuration: CommandConfiguration | null;
|
|
56
|
+
managed: boolean;
|
|
57
|
+
}
|
|
58
|
+
/** Resolves model access per workspace and indicates whether the host manages its keys. */
|
|
59
|
+
export interface KeyProvider {
|
|
60
|
+
commandProvider(workspaceId: string): Promise<CommandKeys>;
|
|
61
|
+
}
|
|
62
|
+
export interface JudgeProvider {
|
|
63
|
+
judge(workspaceId: string): JudgeConfiguration | undefined | Promise<JudgeConfiguration | undefined>;
|
|
64
|
+
}
|
|
65
|
+
export interface JudgeEnv {
|
|
66
|
+
JUDGE_URL?: string;
|
|
67
|
+
JUDGE_API_KEY?: string;
|
|
68
|
+
JUDGE_MODEL?: string;
|
|
69
|
+
}
|
|
70
|
+
export declare function envJudge(env: JudgeEnv): JudgeProvider;
|
|
71
|
+
export interface AppSeams {
|
|
72
|
+
auth: AuthProvider;
|
|
73
|
+
limits: Limits;
|
|
74
|
+
usage: UsageSink;
|
|
75
|
+
keys: KeyProvider;
|
|
76
|
+
judge?: JudgeProvider;
|
|
77
|
+
}
|
|
78
|
+
/** Self-hosted deployments do not meter usage. */
|
|
79
|
+
export declare const noUsage: UsageSink;
|
|
80
|
+
export declare function recordUsage(ctx: Pick<ExecutionContext, "waitUntil">, sink: UsageSink, workspaceId: string, event: UsageEvent): void;
|
|
81
|
+
export declare class LimitError extends Error {
|
|
82
|
+
readonly action: LimitAction;
|
|
83
|
+
readonly status: number;
|
|
84
|
+
readonly code: string;
|
|
85
|
+
readonly retryAfter?: number | undefined;
|
|
86
|
+
constructor(action: LimitAction, reason: string, status?: number, code?: string, retryAfter?: number | undefined);
|
|
87
|
+
get detail(): {
|
|
88
|
+
code: string;
|
|
89
|
+
message: string;
|
|
90
|
+
limit: LimitAction;
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
export declare function checkLimit(limits: Limits, workspaceId: string, action: LimitAction): Promise<{
|
|
94
|
+
ok: true;
|
|
95
|
+
}>;
|
|
96
|
+
export declare function withItemCreateLimit<T>(limits: Limits, workspaceId: string, add: () => T | Promise<T>, updateExisting?: () => T | null | Promise<T | null>): Promise<T>;
|
|
97
|
+
export declare class OpenLimitRefusal {
|
|
98
|
+
readonly error: LimitError;
|
|
99
|
+
readonly ok = false;
|
|
100
|
+
constructor(error: LimitError);
|
|
101
|
+
get reason(): string;
|
|
102
|
+
}
|
|
103
|
+
export declare class OpenPushAllowance {
|
|
104
|
+
readonly cap: number;
|
|
105
|
+
readonly ok = true;
|
|
106
|
+
constructor(cap: number);
|
|
107
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AuthProvider, Limits, WorkspaceSession } from "./seams.js";
|
|
2
|
+
export interface HumanActor extends WorkspaceSession {
|
|
3
|
+
kind: "human";
|
|
4
|
+
}
|
|
5
|
+
export declare function hasAppOrigin(request: Request, url: URL): boolean;
|
|
6
|
+
export declare function requireSession(request: Request, url: URL, auth: AuthProvider, limits: Limits, handle: (actor: HumanActor) => Response | Promise<Response>): Promise<Response>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function encodeBase64Url(bytes: Uint8Array): string;
|
|
2
|
+
export declare function decodeBase64Url(value: string): Uint8Array<ArrayBuffer>;
|
|
3
|
+
export declare function decodeJson(value: string): unknown;
|
|
4
|
+
export declare function clearCookie(name: string): string;
|
|
5
|
+
export declare function signCookie(name: string, claims: object, secret: string, maxAge: number): Promise<string>;
|
|
6
|
+
export declare function readSignedCookie(request: Request, name: string, secret: string): Promise<Record<string, unknown> | null>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare function newTokenSecret(): string;
|
|
2
|
+
export declare function isTokenSecret(secret: string): boolean;
|
|
3
|
+
export declare function hashSecret(secret: string): Promise<string>;
|
|
4
|
+
export declare function equalSecretHashes(left: string, right: string): boolean;
|
|
5
|
+
export declare function tokenParts(token: string, prefix?: string): {
|
|
6
|
+
workspaceId: string;
|
|
7
|
+
secret: string;
|
|
8
|
+
} | null;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { PushSubscription, VapidKeys } from "@block65/webcrypto-web-push";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
export interface PushEnv {
|
|
4
|
+
VAPID_PUBLIC_KEY?: string;
|
|
5
|
+
VAPID_PRIVATE_KEY?: string;
|
|
6
|
+
VAPID_SUBJECT?: string;
|
|
7
|
+
PUSH_RATE_LIMIT_PER_HOUR?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const PushEndpointSchema: z.ZodObject<{
|
|
10
|
+
endpoint: z.ZodURL;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
export declare const PushSubscriptionSchema: z.ZodObject<{
|
|
13
|
+
endpoint: z.ZodURL;
|
|
14
|
+
keys: z.ZodObject<{
|
|
15
|
+
p256dh: z.ZodBase64URL;
|
|
16
|
+
auth: z.ZodBase64URL;
|
|
17
|
+
}, z.core.$strip>;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
export type PushSubscriptionInput = z.infer<typeof PushSubscriptionSchema>;
|
|
20
|
+
export type HandoffPush = {
|
|
21
|
+
title: string;
|
|
22
|
+
body: string;
|
|
23
|
+
url: string;
|
|
24
|
+
};
|
|
25
|
+
export declare function vapidKeys(env: PushEnv): VapidKeys | undefined;
|
|
26
|
+
export declare function preparePush(data: HandoffPush, subscription: PushSubscription, vapid: VapidKeys): Promise<{
|
|
27
|
+
headers: {
|
|
28
|
+
authorization: string;
|
|
29
|
+
ttl: string;
|
|
30
|
+
urgency?: "high" | "low" | "normal";
|
|
31
|
+
topic?: string;
|
|
32
|
+
"content-encoding": string;
|
|
33
|
+
"content-length": string;
|
|
34
|
+
"content-type": string;
|
|
35
|
+
};
|
|
36
|
+
method: string;
|
|
37
|
+
body: Uint8Array<ArrayBuffer>;
|
|
38
|
+
}>;
|
package/dist/worker.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AppEnv } from "./app.js";
|
|
2
|
+
import type { AuthEnv } from "./auth.js";
|
|
3
|
+
import type { BasicLimitsEnv } from "./basic-limits.js";
|
|
4
|
+
import type { EnvKeysEnv } from "./command-provider.js";
|
|
5
|
+
import type { JudgeEnv } from "./seams.js";
|
|
6
|
+
export { Workspace } from "./workspace.js";
|
|
7
|
+
declare const _default: {
|
|
8
|
+
fetch(request: Request, env: AppEnv & AuthEnv & BasicLimitsEnv & EnvKeysEnv & JudgeEnv, ctx: ExecutionContext): Promise<Response>;
|
|
9
|
+
};
|
|
10
|
+
export default _default;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Event, Settings } from "@heedwork/core";
|
|
2
|
+
export type EventRow = Omit<Event, "actor"> & {
|
|
3
|
+
actor: string;
|
|
4
|
+
actor_user: string | null;
|
|
5
|
+
};
|
|
6
|
+
export declare function readEvent({ actor_user, ...event }: EventRow): Event;
|
|
7
|
+
export declare function streamWorkspaceExport(sql: SqlStorage, { timezone, guidance, guidance_updated_at }: Settings, wasReset: () => boolean): ReadableStream<Uint8Array>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function migrateWorkspace(storage: DurableObjectStorage): void;
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
import { DurableObject } from "cloudflare:workers";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import type { CommandChange } from "@heedwork/core";
|
|
4
|
+
import type { HistoryPage, HistoryQuery } from "@heedwork/core";
|
|
5
|
+
import type { JudgeAgreement, JudgedDetail } from "@heedwork/core";
|
|
6
|
+
import type { JudgingInput } from "./judge.js";
|
|
7
|
+
import { CanvasQuerySchema } from "@heedwork/core";
|
|
8
|
+
import type { Actor, AddItemInput, DependencyOperationResult, FlagHandoffInput, HandoffOperationResult, ItemIdInput, ItemOperationResult, ReopenItemInput, ReportProgressInput, SetDependencyInput, UpdateItemInput } from "@heedwork/core";
|
|
9
|
+
import { MoveProjectSchema } from "@heedwork/core";
|
|
10
|
+
import type { Dependency, Event, Guidance, Item, Project, Scope, Settings, Token, TokenMetadata, WorkspaceUser } from "@heedwork/core";
|
|
11
|
+
import type { PushEnv, PushSubscriptionInput } from "./web-push.js";
|
|
12
|
+
import type { OAuthAuthorization, OAuthClient, OAuthExchange } from "./oauth-storage.js";
|
|
13
|
+
import type { McpLimitCheck } from "./mcp.js";
|
|
14
|
+
import type { Limits, UsageSink } from "./seams.js";
|
|
15
|
+
export declare function getWorkspaceStub(env: {
|
|
16
|
+
WORKSPACE: DurableObjectNamespace<Workspace>;
|
|
17
|
+
}, workspaceId: string): DurableObjectStub<Workspace<PushEnv>>;
|
|
18
|
+
export declare function addItemWithLimit(workspace: () => Pick<Workspace | ReturnType<typeof getWorkspaceStub>, "addItem" | "updateExistingItem">, actor: Actor, input: AddItemInput, limits: Limits, workspaceId: string): Promise<ItemOperationResult | (Promise<{
|
|
19
|
+
item_id: string;
|
|
20
|
+
items: {
|
|
21
|
+
id: string;
|
|
22
|
+
project_id: string;
|
|
23
|
+
parent_id: string | null;
|
|
24
|
+
external_key: string | null;
|
|
25
|
+
title: string;
|
|
26
|
+
tags: string;
|
|
27
|
+
acceptance: string;
|
|
28
|
+
depth: number;
|
|
29
|
+
priority: number;
|
|
30
|
+
scheduled_on: string | null;
|
|
31
|
+
sort_key: number | null;
|
|
32
|
+
layout_pos: string;
|
|
33
|
+
locked_fields: string;
|
|
34
|
+
time_type: "fixed" | "flexible" | "deadline";
|
|
35
|
+
time_at: string | null;
|
|
36
|
+
status: "queued" | "active" | "blocked" | "done" | "cancelled";
|
|
37
|
+
handoff: 0 | 1;
|
|
38
|
+
handoff_note: string | null;
|
|
39
|
+
reopen_count: number;
|
|
40
|
+
reopen_reason: string | null;
|
|
41
|
+
agent_name: string | null;
|
|
42
|
+
created_by: "human" | "agent";
|
|
43
|
+
ref_url: string | null;
|
|
44
|
+
note: string | null;
|
|
45
|
+
hidden: 0 | 1;
|
|
46
|
+
last_heartbeat_at: string | null;
|
|
47
|
+
completed_at: string | null;
|
|
48
|
+
completed_band: "today" | "this-week" | "later" | "backlog" | null;
|
|
49
|
+
created_at: string;
|
|
50
|
+
updated_at: string;
|
|
51
|
+
demo?: 0 | 1 | undefined;
|
|
52
|
+
}[];
|
|
53
|
+
ignored_fields: ("evidence" | "acceptance" | "priority" | "scheduled_on" | "sort_key" | "layout_pos")[];
|
|
54
|
+
guidance_updated_at: string | null;
|
|
55
|
+
} & Disposable> & Pick<{
|
|
56
|
+
item_id: Promise<string>;
|
|
57
|
+
items: Promise<{
|
|
58
|
+
id: string;
|
|
59
|
+
project_id: string;
|
|
60
|
+
parent_id: string | null;
|
|
61
|
+
external_key: string | null;
|
|
62
|
+
title: string;
|
|
63
|
+
tags: string;
|
|
64
|
+
acceptance: string;
|
|
65
|
+
depth: number;
|
|
66
|
+
priority: number;
|
|
67
|
+
scheduled_on: string | null;
|
|
68
|
+
sort_key: number | null;
|
|
69
|
+
layout_pos: string;
|
|
70
|
+
locked_fields: string;
|
|
71
|
+
time_type: "fixed" | "flexible" | "deadline";
|
|
72
|
+
time_at: string | null;
|
|
73
|
+
status: "queued" | "active" | "blocked" | "done" | "cancelled";
|
|
74
|
+
handoff: 0 | 1;
|
|
75
|
+
handoff_note: string | null;
|
|
76
|
+
reopen_count: number;
|
|
77
|
+
reopen_reason: string | null;
|
|
78
|
+
agent_name: string | null;
|
|
79
|
+
created_by: "human" | "agent";
|
|
80
|
+
ref_url: string | null;
|
|
81
|
+
note: string | null;
|
|
82
|
+
hidden: 0 | 1;
|
|
83
|
+
last_heartbeat_at: string | null;
|
|
84
|
+
completed_at: string | null;
|
|
85
|
+
completed_band: "today" | "this-week" | "later" | "backlog" | null;
|
|
86
|
+
created_at: string;
|
|
87
|
+
updated_at: string;
|
|
88
|
+
demo?: 0 | 1 | undefined;
|
|
89
|
+
}[] & Disposable> & Pick<(Promise<{
|
|
90
|
+
id: string;
|
|
91
|
+
project_id: string;
|
|
92
|
+
parent_id: string | null;
|
|
93
|
+
external_key: string | null;
|
|
94
|
+
title: string;
|
|
95
|
+
tags: string;
|
|
96
|
+
acceptance: string;
|
|
97
|
+
depth: number;
|
|
98
|
+
priority: number;
|
|
99
|
+
scheduled_on: string | null;
|
|
100
|
+
sort_key: number | null;
|
|
101
|
+
layout_pos: string;
|
|
102
|
+
locked_fields: string;
|
|
103
|
+
time_type: "fixed" | "flexible" | "deadline";
|
|
104
|
+
time_at: string | null;
|
|
105
|
+
status: "queued" | "active" | "blocked" | "done" | "cancelled";
|
|
106
|
+
handoff: 0 | 1;
|
|
107
|
+
handoff_note: string | null;
|
|
108
|
+
reopen_count: number;
|
|
109
|
+
reopen_reason: string | null;
|
|
110
|
+
agent_name: string | null;
|
|
111
|
+
created_by: "human" | "agent";
|
|
112
|
+
ref_url: string | null;
|
|
113
|
+
note: string | null;
|
|
114
|
+
hidden: 0 | 1;
|
|
115
|
+
last_heartbeat_at: string | null;
|
|
116
|
+
completed_at: string | null;
|
|
117
|
+
completed_band: "today" | "this-week" | "later" | "backlog" | null;
|
|
118
|
+
created_at: string;
|
|
119
|
+
updated_at: string;
|
|
120
|
+
demo?: 0 | 1 | undefined;
|
|
121
|
+
} & Disposable> & Pick<{
|
|
122
|
+
id: Promise<string>;
|
|
123
|
+
project_id: Promise<string>;
|
|
124
|
+
parent_id: Promise<null> | Promise<string>;
|
|
125
|
+
external_key: Promise<null> | Promise<string>;
|
|
126
|
+
title: Promise<string>;
|
|
127
|
+
tags: Promise<string>;
|
|
128
|
+
acceptance: Promise<string>;
|
|
129
|
+
depth: Promise<number>;
|
|
130
|
+
priority: Promise<number>;
|
|
131
|
+
scheduled_on: Promise<null> | Promise<string>;
|
|
132
|
+
sort_key: Promise<null> | Promise<number>;
|
|
133
|
+
layout_pos: Promise<string>;
|
|
134
|
+
locked_fields: Promise<string>;
|
|
135
|
+
time_type: Promise<"fixed"> | Promise<"flexible"> | Promise<"deadline">;
|
|
136
|
+
time_at: Promise<null> | Promise<string>;
|
|
137
|
+
status: Promise<"queued"> | Promise<"active"> | Promise<"blocked"> | Promise<"done"> | Promise<"cancelled">;
|
|
138
|
+
handoff: Promise<0> | Promise<1>;
|
|
139
|
+
handoff_note: Promise<null> | Promise<string>;
|
|
140
|
+
reopen_count: Promise<number>;
|
|
141
|
+
reopen_reason: Promise<null> | Promise<string>;
|
|
142
|
+
agent_name: Promise<null> | Promise<string>;
|
|
143
|
+
created_by: Promise<"human"> | Promise<"agent">;
|
|
144
|
+
ref_url: Promise<null> | Promise<string>;
|
|
145
|
+
note: Promise<null> | Promise<string>;
|
|
146
|
+
hidden: Promise<0> | Promise<1>;
|
|
147
|
+
last_heartbeat_at: Promise<null> | Promise<string>;
|
|
148
|
+
completed_at: Promise<null> | Promise<string>;
|
|
149
|
+
completed_band: Promise<null> | Promise<"today"> | Promise<"this-week"> | Promise<"later"> | Promise<"backlog">;
|
|
150
|
+
created_at: Promise<string>;
|
|
151
|
+
updated_at: Promise<string>;
|
|
152
|
+
demo?: Promise<undefined> | Promise<0> | Promise<1> | undefined;
|
|
153
|
+
}, "title" | "note" | "status" | "id" | "demo" | "handoff" | "created_at" | "acceptance" | "priority" | "scheduled_on" | "sort_key" | "layout_pos" | "parent_id" | "project_id" | "external_key" | "tags" | "depth" | "locked_fields" | "time_type" | "time_at" | "handoff_note" | "reopen_count" | "reopen_reason" | "agent_name" | "created_by" | "ref_url" | "hidden" | "last_heartbeat_at" | "completed_at" | "completed_band" | "updated_at">)[], number | "values" | "map" | "push" | "concat" | "indexOf" | "lastIndexOf" | "slice" | "includes" | "at" | "length" | "keys" | "toString" | "toLocaleString" | "pop" | "join" | "reverse" | "shift" | "sort" | "splice" | "unshift" | "every" | "some" | "forEach" | "filter" | "reduce" | "reduceRight" | "find" | "findIndex" | "fill" | "copyWithin" | "entries" | "flatMap" | "flat" | "findLast" | "findLastIndex" | "toReversed" | "toSorted" | "toSpliced" | "with">;
|
|
154
|
+
ignored_fields: Promise<("evidence" | "acceptance" | "priority" | "scheduled_on" | "sort_key" | "layout_pos")[] & Disposable> & Pick<(Promise<"evidence"> | Promise<"acceptance"> | Promise<"priority"> | Promise<"scheduled_on"> | Promise<"sort_key"> | Promise<"layout_pos">)[], number | "values" | "map" | "push" | "concat" | "indexOf" | "lastIndexOf" | "slice" | "includes" | "at" | "length" | "keys" | "toString" | "toLocaleString" | "pop" | "join" | "reverse" | "shift" | "sort" | "splice" | "unshift" | "every" | "some" | "forEach" | "filter" | "reduce" | "reduceRight" | "find" | "findIndex" | "fill" | "copyWithin" | "entries" | "flatMap" | "flat" | "findLast" | "findLastIndex" | "toReversed" | "toSorted" | "toSpliced" | "with">;
|
|
155
|
+
guidance_updated_at: Promise<null> | Promise<string>;
|
|
156
|
+
}, keyof ItemOperationResult>)>;
|
|
157
|
+
type ItemPatch = Partial<Omit<Item, "id" | "created_at" | "updated_at">>;
|
|
158
|
+
export type WorkspaceEnv = PushEnv;
|
|
159
|
+
export declare function socketUpgrade(request: Request, user: WorkspaceUser, role: string): Request<unknown, CfProperties<unknown>>;
|
|
160
|
+
type CommandItemUndo = {
|
|
161
|
+
id: string;
|
|
162
|
+
before: ItemPatch;
|
|
163
|
+
after: ItemPatch;
|
|
164
|
+
};
|
|
165
|
+
type CommandUndo = {
|
|
166
|
+
type: "items";
|
|
167
|
+
root: string;
|
|
168
|
+
rows: CommandItemUndo[];
|
|
169
|
+
} | {
|
|
170
|
+
type: "project";
|
|
171
|
+
id: string;
|
|
172
|
+
before: Project["hidden"];
|
|
173
|
+
after: Project["hidden"];
|
|
174
|
+
} | {
|
|
175
|
+
type: "guidance";
|
|
176
|
+
before: string;
|
|
177
|
+
after: string;
|
|
178
|
+
} | ({
|
|
179
|
+
type: "dependency";
|
|
180
|
+
} & SetDependencyInput);
|
|
181
|
+
type CommandEffect = {
|
|
182
|
+
changes: CommandChange[];
|
|
183
|
+
undo?: CommandUndo;
|
|
184
|
+
};
|
|
185
|
+
export declare class SteerScopeError extends Error {
|
|
186
|
+
}
|
|
187
|
+
export declare class Workspace<Bindings extends WorkspaceEnv = WorkspaceEnv> extends DurableObject<Bindings> {
|
|
188
|
+
#private;
|
|
189
|
+
/** A host can supply its Limits seam for hibernating socket mutations. */
|
|
190
|
+
protected get socketLimits(): Limits | undefined;
|
|
191
|
+
/** A host can supply its UsageSink to meter successful background push deliveries. */
|
|
192
|
+
protected get pushUsage(): UsageSink;
|
|
193
|
+
/** Hosted auth can revoke grants kept outside this Durable Object's storage. */
|
|
194
|
+
protected revokeWorkspaceGrants?(): Promise<void>;
|
|
195
|
+
constructor(ctx: DurableObjectState, env: Bindings);
|
|
196
|
+
fetch(request: Request): Response;
|
|
197
|
+
webSocketMessage(socket: WebSocket, message: string | ArrayBuffer): Promise<void>;
|
|
198
|
+
reserveCommandQuota(kind: "command" | "transcribe", limit: number): boolean;
|
|
199
|
+
getCommandContext(): {
|
|
200
|
+
items: {
|
|
201
|
+
acceptance?: string[] | undefined;
|
|
202
|
+
ref_url?: string | undefined;
|
|
203
|
+
id: string;
|
|
204
|
+
title: string;
|
|
205
|
+
project: string;
|
|
206
|
+
status: "queued" | "active" | "blocked" | "done" | "cancelled";
|
|
207
|
+
parent_id: string | null;
|
|
208
|
+
band: "today" | "this-week" | "later" | "backlog" | "done-today" | "tomorrow" | null;
|
|
209
|
+
}[];
|
|
210
|
+
may_have_more: boolean;
|
|
211
|
+
guidance: string;
|
|
212
|
+
guidance_updated_at: string | null;
|
|
213
|
+
today: string;
|
|
214
|
+
timezone: string;
|
|
215
|
+
projects: {
|
|
216
|
+
id: string;
|
|
217
|
+
name: string;
|
|
218
|
+
hidden: 0 | 1;
|
|
219
|
+
}[];
|
|
220
|
+
projects_may_have_more: boolean;
|
|
221
|
+
};
|
|
222
|
+
executeCommandTool(name: string, input: unknown, user?: WorkspaceUser, allowItemCreation?: boolean): Promise<{
|
|
223
|
+
content: string;
|
|
224
|
+
isError: boolean;
|
|
225
|
+
effects: CommandEffect[];
|
|
226
|
+
needsItemCreation?: true;
|
|
227
|
+
}>;
|
|
228
|
+
saveCommandUndo(effects: CommandEffect[]): string | undefined;
|
|
229
|
+
getSettings(): Settings;
|
|
230
|
+
/** Returns a streamed JSON export for trusted host callers. */
|
|
231
|
+
exportWorkspace(): ReadableStream<Uint8Array>;
|
|
232
|
+
/** Wipes workspace storage and seeds a fresh Inbox for trusted host callers. */
|
|
233
|
+
resetWorkspace(): Promise<void>;
|
|
234
|
+
dismissOnboarding(): void;
|
|
235
|
+
createToken(label: string, scope?: Token["scope"], default_project_id?: string | null): Promise<TokenMetadata & {
|
|
236
|
+
token: string;
|
|
237
|
+
}>;
|
|
238
|
+
listTokens(): TokenMetadata[];
|
|
239
|
+
revokeToken(id: string): boolean;
|
|
240
|
+
verifyToken(secret: string): Promise<Extract<Actor, {
|
|
241
|
+
kind: "agent";
|
|
242
|
+
}> | null>;
|
|
243
|
+
registerOAuthClient(client: OAuthClient): void;
|
|
244
|
+
findOAuthClient(id: string): OAuthClient | null;
|
|
245
|
+
beginOAuthConsent(csrf: string, userId: string, authorization: OAuthAuthorization): Promise<void>;
|
|
246
|
+
finishOAuthConsent(csrf: string, userId: string, resource: string, decision: {
|
|
247
|
+
label: string;
|
|
248
|
+
scope: Scope;
|
|
249
|
+
} | null): Promise<{
|
|
250
|
+
authorization: OAuthAuthorization;
|
|
251
|
+
code: null;
|
|
252
|
+
} | {
|
|
253
|
+
authorization: OAuthAuthorization;
|
|
254
|
+
code: string;
|
|
255
|
+
} | null>;
|
|
256
|
+
exchangeOAuthToken(input: OAuthExchange): Promise<{
|
|
257
|
+
error: string;
|
|
258
|
+
} | {
|
|
259
|
+
scope: "steer" | "report";
|
|
260
|
+
refresh_token?: string | undefined;
|
|
261
|
+
access_token: string;
|
|
262
|
+
token_type: string;
|
|
263
|
+
expires_in: number;
|
|
264
|
+
error?: undefined;
|
|
265
|
+
}>;
|
|
266
|
+
listConnectedApps(): import("@heedwork/core").ConnectedApp[];
|
|
267
|
+
revokeConnectedApp(id: string): boolean;
|
|
268
|
+
mcp(request: Request, secret: string, check: McpLimitCheck): Promise<{
|
|
269
|
+
response: Response;
|
|
270
|
+
writes: never[];
|
|
271
|
+
judgingInputs?: undefined;
|
|
272
|
+
} | {
|
|
273
|
+
response: Response;
|
|
274
|
+
writes: string[];
|
|
275
|
+
judgingInputs: JudgingInput[];
|
|
276
|
+
}>;
|
|
277
|
+
setTimezone(timezone: string, initializeOnly?: boolean): void;
|
|
278
|
+
getGuidance(): Guidance;
|
|
279
|
+
getHistory(input: HistoryQuery): HistoryPage;
|
|
280
|
+
getItem(input: ItemIdInput): Item;
|
|
281
|
+
getItemEvents(input: ItemIdInput): Event[];
|
|
282
|
+
getJudgeAgreement(): JudgeAgreement;
|
|
283
|
+
appendJudgedEvent(itemId: string, input: JudgedDetail): void;
|
|
284
|
+
getCanvas(input?: z.input<typeof CanvasQuerySchema>): {
|
|
285
|
+
guidance: string;
|
|
286
|
+
guidance_updated_at: string | null;
|
|
287
|
+
items: {
|
|
288
|
+
acceptance?: string[] | undefined;
|
|
289
|
+
id: string;
|
|
290
|
+
title: string;
|
|
291
|
+
project: string;
|
|
292
|
+
status: "queued" | "active" | "blocked" | "done" | "cancelled";
|
|
293
|
+
parent_id: string | null;
|
|
294
|
+
ref_url: string | null;
|
|
295
|
+
agent_name: string | null;
|
|
296
|
+
band: "today" | "this-week" | "later" | "backlog" | "done-today" | "tomorrow" | null;
|
|
297
|
+
}[];
|
|
298
|
+
};
|
|
299
|
+
setGuidance(actor: Actor, guidance: string): Guidance;
|
|
300
|
+
listProjects(): Project[];
|
|
301
|
+
createProject(input: Pick<Project, "name"> & Partial<Omit<Project, "id" | "name">>): Project;
|
|
302
|
+
loadDemoData(): void;
|
|
303
|
+
removeDemoData(): void;
|
|
304
|
+
updateProject(id: string, input: Partial<Omit<Project, "id">>): Project;
|
|
305
|
+
deleteProject(id: string): void;
|
|
306
|
+
moveProject(input: z.input<typeof MoveProjectSchema>): void;
|
|
307
|
+
addItem(actor: Actor, input: AddItemInput): ItemOperationResult;
|
|
308
|
+
updateExistingItem(actor: Actor, input: AddItemInput): ItemOperationResult | null;
|
|
309
|
+
updateItem(actor: Actor, input: UpdateItemInput): ItemOperationResult;
|
|
310
|
+
reportProgress(actor: Actor, input: ReportProgressInput): ItemOperationResult & {
|
|
311
|
+
judgingInput?: JudgingInput;
|
|
312
|
+
};
|
|
313
|
+
flagHandoff(actor: Actor, input: FlagHandoffInput, pushCap?: number | null): Promise<HandoffOperationResult>;
|
|
314
|
+
getPushStatus(input: PushSubscriptionInput): {
|
|
315
|
+
registered: boolean;
|
|
316
|
+
};
|
|
317
|
+
subscribePush(input: PushSubscriptionInput): {
|
|
318
|
+
ok: true;
|
|
319
|
+
};
|
|
320
|
+
unsubscribePush(input: {
|
|
321
|
+
endpoint: string;
|
|
322
|
+
}): {
|
|
323
|
+
ok: true;
|
|
324
|
+
};
|
|
325
|
+
clearHandoff(actor: Actor, input: ItemIdInput): ItemOperationResult;
|
|
326
|
+
reopenItem(actor: Actor, input: ReopenItemInput): ItemOperationResult;
|
|
327
|
+
deleteItem(actor: Actor, input: ItemIdInput): ItemOperationResult;
|
|
328
|
+
listDependencies(): Dependency[];
|
|
329
|
+
setDependency(actor: Actor, input: SetDependencyInput): DependencyOperationResult;
|
|
330
|
+
}
|
|
331
|
+
export {};
|