iterate 0.2.7 → 0.3.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 +86 -76
- package/THIRD_PARTY_NOTICES.md +55 -0
- package/bin/iterate.js +11 -3
- package/dist/api-url-B6404M82.mjs +17 -0
- package/dist/api-url-B6404M82.mjs.map +1 -0
- package/dist/app-ref-BipL0feU.mjs +35 -0
- package/dist/app-ref-BipL0feU.mjs.map +1 -0
- package/dist/app-ref-C1CrgXqX.mjs +7 -0
- package/dist/app-ref-C1CrgXqX.mjs.map +1 -0
- package/dist/app-ref-DYai_om1.mjs +7 -0
- package/dist/app-ref-DYai_om1.mjs.map +1 -0
- package/dist/cli-D0c-pDL_.mjs +1010 -0
- package/dist/cli-D0c-pDL_.mjs.map +1 -0
- package/dist/client.d.ts +3 -0
- package/dist/client.mjs +4 -0
- package/dist/cloudflare-BTm90gQ4.mjs +951 -0
- package/dist/cloudflare-BTm90gQ4.mjs.map +1 -0
- package/dist/contract-s4FW4eES.mjs +309 -0
- package/dist/contract-s4FW4eES.mjs.map +1 -0
- package/dist/document-review/index.d.ts +5 -0
- package/dist/document-review/types.d.ts +107 -0
- package/dist/document-review.mjs +7015 -0
- package/dist/document-review.mjs.map +1 -0
- package/dist/durable-object-processor-durability-CNsTjAJS.mjs +205 -0
- package/dist/durable-object-processor-durability-CNsTjAJS.mjs.map +1 -0
- package/dist/idempotency-DleloJNt.mjs +28 -0
- package/dist/idempotency-DleloJNt.mjs.map +1 -0
- package/dist/index.mjs +1 -1
- package/dist/itx/api-url.d.ts +6 -0
- package/dist/itx/itx-node-client.d.ts +65 -0
- package/dist/itx/itx-session.d.ts +215 -0
- package/dist/itx/owned-rpc-session.d.ts +14 -0
- package/dist/itx/query-client.d.ts +10 -0
- package/dist/itx-api.generated.d.ts +6195 -0
- package/dist/itx-session-sjud8GiT.mjs +534 -0
- package/dist/itx-session-sjud8GiT.mjs.map +1 -0
- package/dist/live-state-BJNqOwFw.mjs +299 -0
- package/dist/live-state-BJNqOwFw.mjs.map +1 -0
- package/dist/next/api.d.ts +479 -0
- package/dist/next/api.mjs +0 -0
- package/dist/next/app-server.d.ts +44 -0
- package/dist/next/app-server.mjs +479 -0
- package/dist/next/app-server.mjs.map +1 -0
- package/dist/next/app-session.d.ts +49 -0
- package/dist/next/app-session.mjs +238 -0
- package/dist/next/app-session.mjs.map +1 -0
- package/dist/next/app.d.ts +29 -0
- package/dist/next/app.mjs +141 -0
- package/dist/next/app.mjs.map +1 -0
- package/dist/next/client/live-state.d.ts +63 -0
- package/dist/next/client/oauth.d.ts +12 -0
- package/dist/next/client/react.d.ts +109 -0
- package/dist/next/client/socket.d.ts +6 -0
- package/dist/next/client.mjs +156 -0
- package/dist/next/client.mjs.map +1 -0
- package/dist/next/expression.d.ts +146 -0
- package/dist/next/expression.mjs +399 -0
- package/dist/next/expression.mjs.map +1 -0
- package/dist/next/lib.d.ts +56 -0
- package/dist/next/lib.mjs +199 -0
- package/dist/next/lib.mjs.map +1 -0
- package/dist/next/oauth-scopes.d.ts +32 -0
- package/dist/next/oauth-scopes.mjs +40 -0
- package/dist/next/oauth-scopes.mjs.map +1 -0
- package/dist/next/oauth.mjs +29 -0
- package/dist/next/oauth.mjs.map +1 -0
- package/dist/next/principal.d.ts +64 -0
- package/dist/next/principal.mjs +98 -0
- package/dist/next/principal.mjs.map +1 -0
- package/dist/next/project-ingress.d.ts +37 -0
- package/dist/next/project-ingress.mjs +75 -0
- package/dist/next/project-ingress.mjs.map +1 -0
- package/dist/next/react.mjs +285 -0
- package/dist/next/react.mjs.map +1 -0
- package/dist/next/sdk/auth.d.ts +5 -0
- package/dist/next/sdk/index.d.ts +112 -0
- package/dist/next/sdk.mjs +139 -0
- package/dist/next/sdk.mjs.map +1 -0
- package/dist/next/stream/processor.d.ts +378 -0
- package/dist/next/stream/processor.mjs +582 -0
- package/dist/next/stream/processor.mjs.map +1 -0
- package/dist/next/stream/run.d.ts +58 -0
- package/dist/next/stream/run.mjs +40 -0
- package/dist/next/stream/run.mjs.map +1 -0
- package/dist/next-node.d.ts +15 -0
- package/dist/next-node.mjs +51 -0
- package/dist/next-node.mjs.map +1 -0
- package/dist/node.d.ts +3 -0
- package/dist/node.mjs +185 -0
- package/dist/node.mjs.map +1 -0
- package/dist/processor-host-capabilities-BMFH3KTM.mjs +56 -0
- package/dist/processor-host-capabilities-BMFH3KTM.mjs.map +1 -0
- package/dist/processors/cloudflare.d.ts +3 -0
- package/dist/processors/durable-object-processor-durability.d.ts +79 -0
- package/dist/processors/event-consumption-metrics.d.ts +82 -0
- package/dist/processors/idempotency.d.ts +13 -0
- package/dist/processors/index.d.ts +12 -0
- package/dist/processors/processor-contracts.d.ts +342 -0
- package/dist/processors/processor-facet.d.ts +186 -0
- package/dist/processors/processor-host-capabilities.d.ts +60 -0
- package/dist/processors/prompt-sections.d.ts +17 -0
- package/dist/processors/rpc-types.d.ts +515 -0
- package/dist/processors/schemas.d.ts +102 -0
- package/dist/processors/stream-handle.d.ts +45 -0
- package/dist/processors/stream-processor-keepalive.d.ts +95 -0
- package/dist/processors/stream-processor-registry.d.ts +233 -0
- package/dist/processors/stream-processor-runner.d.ts +289 -0
- package/dist/processors/stream-processor.d.ts +339 -0
- package/dist/processors/stream-runtime-metrics.d.ts +107 -0
- package/dist/processors/testing.d.ts +302 -0
- package/dist/processors-BoNyeBfQ.mjs +10 -0
- package/dist/processors-BoNyeBfQ.mjs.map +1 -0
- package/dist/processors-cloudflare.mjs +3 -0
- package/dist/processors-testing.mjs +435 -0
- package/dist/processors-testing.mjs.map +1 -0
- package/dist/processors.mjs +52 -0
- package/dist/processors.mjs.map +1 -0
- package/dist/protocol-DnK_f2m6.mjs +251 -0
- package/dist/protocol-DnK_f2m6.mjs.map +1 -0
- package/dist/sdk/capnweb/index.d.ts +2 -0
- package/dist/sdk/capnweb/live-state/compact.d.ts +5 -0
- package/dist/sdk/capnweb/live-state/diff.d.ts +41 -0
- package/dist/sdk/capnweb/live-state/engine.d.ts +44 -0
- package/dist/sdk/capnweb/live-state/index.d.ts +41 -0
- package/dist/sdk/capnweb/live-state/protocol.d.ts +87 -0
- package/dist/sdk/capnweb/live-state/retain.d.ts +23 -0
- package/dist/sdk/capnweb/live-state/store.d.ts +20 -0
- package/dist/sdk/capnweb/live-state/types.d.ts +11 -0
- package/dist/sdk/capnweb/react.d.ts +45 -0
- package/dist/sdk/capnweb/react.mjs +316 -0
- package/dist/sdk/capnweb/react.mjs.map +1 -0
- package/dist/sdk/capnweb.mjs +4 -0
- package/dist/sdk/itx/react.d.ts +191 -0
- package/dist/sdk/itx/react.mjs +383 -0
- package/dist/sdk/itx/react.mjs.map +1 -0
- package/dist/sdk-DMB-IM11.mjs +933 -0
- package/dist/sdk-DMB-IM11.mjs.map +1 -0
- package/dist/sdk.d.ts +339 -0
- package/dist/sdk.mjs +2 -0
- package/dist/serve-itx.d.ts +46 -0
- package/dist/starter-apps/flake-dashboard/app-ref.d.ts +31 -0
- package/dist/starter-apps/flake-dashboard/configured-worker.mjs +1055 -0
- package/dist/starter-apps/flake-dashboard/configured-worker.mjs.map +1 -0
- package/dist/starter-apps/flake-dashboard/contract.d.ts +4839 -0
- package/dist/starter-apps/flake-dashboard/contract.mjs +2 -0
- package/dist/starter-apps/flake-dashboard/index.d.ts +17 -0
- package/dist/starter-apps/flake-dashboard/index.mjs +56 -0
- package/dist/starter-apps/flake-dashboard/index.mjs.map +1 -0
- package/dist/starter-apps/flake-dashboard/worker.d.ts +4607 -0
- package/dist/starter-apps/github-ai-linter/ai-linter.d.ts +8914 -0
- package/dist/starter-apps/github-ai-linter/configured-worker.mjs +17987 -0
- package/dist/starter-apps/github-ai-linter/configured-worker.mjs.map +1 -0
- package/dist/starter-apps/github-ai-linter/contract.d.ts +9193 -0
- package/dist/starter-apps/github-ai-linter/index.d.ts +10 -0
- package/dist/starter-apps/github-ai-linter/index.mjs +36 -0
- package/dist/starter-apps/github-ai-linter/index.mjs.map +1 -0
- package/dist/starter-apps/github-ai-linter/prompt.d.ts +13 -0
- package/dist/starter-apps/github-ai-linter/review-bot.d.ts +808 -0
- package/dist/starter-apps/github-ai-linter/rules.d.ts +34 -0
- package/dist/starter-apps/github-ai-linter/worker-ref.d.ts +19 -0
- package/dist/starter-apps/github-ai-linter/worker.d.ts +19 -0
- package/dist/starter-apps/github-ai-linter/worker.mjs +947 -0
- package/dist/starter-apps/github-ai-linter/worker.mjs.map +1 -0
- package/dist/starter-apps/guestbook/app-ref.d.ts +27 -0
- package/dist/starter-apps/guestbook/client.d.ts +7 -0
- package/dist/starter-apps/guestbook/client.mjs +59 -0
- package/dist/starter-apps/guestbook/configured-worker.mjs +205 -0
- package/dist/starter-apps/guestbook/configured-worker.mjs.map +1 -0
- package/dist/starter-apps/guestbook/index.d.ts +9 -0
- package/dist/starter-apps/guestbook/index.mjs +31 -0
- package/dist/starter-apps/guestbook/index.mjs.map +1 -0
- package/dist/starter-apps/guestbook/processor.d.ts +2267 -0
- package/dist/starter-apps/guestbook/worker.d.ts +26 -0
- package/dist/starter-apps/guestbook/worker.mjs +191 -0
- package/dist/starter-apps/guestbook/worker.mjs.map +1 -0
- package/dist/starter-apps/media/configured-worker.mjs +577 -0
- package/dist/starter-apps/media/configured-worker.mjs.map +1 -0
- package/dist/starter-apps/media/index.mjs +36 -0
- package/dist/starter-apps/media/index.mjs.map +1 -0
- package/dist/starter-apps/media/ref.mjs +20 -0
- package/dist/starter-apps/media/ref.mjs.map +1 -0
- package/dist/starter-apps/media/worker.mjs +579 -0
- package/dist/starter-apps/media/worker.mjs.map +1 -0
- package/dist/starter-apps/notes/configured-worker.mjs +6134 -0
- package/dist/starter-apps/notes/configured-worker.mjs.map +1 -0
- package/dist/starter-apps/notes/index.mjs +23 -0
- package/dist/starter-apps/notes/index.mjs.map +1 -0
- package/dist/starter-apps/notes/ref.mjs +21 -0
- package/dist/starter-apps/notes/ref.mjs.map +1 -0
- package/dist/starter-apps/notes/worker.mjs +427 -0
- package/dist/starter-apps/notes/worker.mjs.map +1 -0
- package/dist/starter-apps/todo/client.mjs +59 -0
- package/dist/starter-apps/todo/configured-worker.mjs +2864 -0
- package/dist/starter-apps/todo/configured-worker.mjs.map +1 -0
- package/dist/starter-apps/todo/index.d.ts +8 -0
- package/dist/starter-apps/todo/index.mjs +29 -0
- package/dist/starter-apps/todo/index.mjs.map +1 -0
- package/dist/stream-processor-keepalive-DAQTP6m3.mjs +2082 -0
- package/dist/stream-processor-keepalive-DAQTP6m3.mjs.map +1 -0
- package/dist/usingCtx-inzbY1Qz.mjs +57 -0
- package/dist/usingCtx-mZx5nsAW.mjs +11800 -0
- package/dist/usingCtx-mZx5nsAW.mjs.map +1 -0
- package/dist/worker-ref-DZxPDmb_.mjs +390 -0
- package/dist/worker-ref-DZxPDmb_.mjs.map +1 -0
- package/menubar/Iterate.entitlements +12 -0
- package/menubar/Iterate.swift +914 -0
- package/menubar/IterateIcon.swift +145 -0
- package/menubar/README.md +28 -0
- package/menubar/build-menubar-app.sh +59 -0
- package/package.json +235 -18
- package/dist/cli-DMS4kJph.mjs +0 -868
- package/dist/cli-DMS4kJph.mjs.map +0 -1
- package/dist/config-DtnR7Lv7.mjs +0 -170
- package/dist/config-DtnR7Lv7.mjs.map +0 -1
- package/dist/index.d.mts.map +0 -1
- package/dist/stream-tui/agent-chat-terminal.d.mts +0 -1
- package/dist/stream-tui/agent-chat-terminal.mjs +0 -933
- package/dist/stream-tui/agent-chat-terminal.mjs.map +0 -1
|
@@ -0,0 +1,479 @@
|
|
|
1
|
+
import type { Ai } from "@cloudflare/workers-types";
|
|
2
|
+
import type { FacetHandle, InvokeHandle, ItxExpressionInput } from "./expression.ts";
|
|
3
|
+
import type { ConsentScope } from "./oauth-scopes.ts";
|
|
4
|
+
import type { Principal } from "./principal.ts";
|
|
5
|
+
import type { IngressRouting } from "./project-ingress.ts";
|
|
6
|
+
import type { StreamEvent, StreamEventInput } from "./stream/processor.ts";
|
|
7
|
+
/** What `authenticate` accepts: the browser (its login cookie rode the upgrade), a device or script
|
|
8
|
+
* (its bearer token did — or, on a socket opened bare, presented here as `token`: a static page on
|
|
9
|
+
* another origin cannot put a header on a WebSocket), or the operator (the deployment's admin
|
|
10
|
+
* secret, verified in-band). */
|
|
11
|
+
export type SessionCredentials = {
|
|
12
|
+
type: "from-server-cookie";
|
|
13
|
+
} | {
|
|
14
|
+
type: "bearer";
|
|
15
|
+
token?: string;
|
|
16
|
+
} | {
|
|
17
|
+
type: "admin-secret";
|
|
18
|
+
secret: string;
|
|
19
|
+
as?: {
|
|
20
|
+
email: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
/** One page of a context's durable log (`readEvents`). */
|
|
24
|
+
export interface StreamPage {
|
|
25
|
+
events: StreamEvent[];
|
|
26
|
+
scannedThroughOffset: number;
|
|
27
|
+
/** True iff the scan reached the durable mark: nothing more to read until the next commit. */
|
|
28
|
+
atHead: boolean;
|
|
29
|
+
}
|
|
30
|
+
/** `waitForEvent`'s filter: an event type (or one of a list), a floor, a timeout. */
|
|
31
|
+
export type WaitForEventFilter = {
|
|
32
|
+
type?: string | string[];
|
|
33
|
+
afterOffset?: number;
|
|
34
|
+
timeoutMs?: number;
|
|
35
|
+
};
|
|
36
|
+
/** The `rewrite-rule-configured` event's payload — what `provide` takes, what `itx.append` writes
|
|
37
|
+
* durably: make `match` mean `target` (an expression, or `null` to deny). `description` is the one
|
|
38
|
+
* line a model reads for the name; it rides the row into `rewriteRules.list()`. */
|
|
39
|
+
export type RewriteRuleConfigured = {
|
|
40
|
+
match: ItxExpressionInput;
|
|
41
|
+
target: ItxExpressionInput | null;
|
|
42
|
+
/** What the name means here, in one line (≤ 500 chars). */
|
|
43
|
+
description?: string;
|
|
44
|
+
};
|
|
45
|
+
/** One row of `rewriteRules.list()` — the tree a context can spell. `context` is the path the row
|
|
46
|
+
* was read from: this context for its own rows and its implicit rows, the target context for the
|
|
47
|
+
* rows a bare hop row (`itx ⇒ itx.builtins.cd(path)`) reaches. A mask lists as `target: null`. */
|
|
48
|
+
export type RewriteRuleListEntry = {
|
|
49
|
+
match: string;
|
|
50
|
+
target: string | null;
|
|
51
|
+
description?: string;
|
|
52
|
+
context: string;
|
|
53
|
+
};
|
|
54
|
+
/** One row of `subscriptions.list()` / `processors.list()`. */
|
|
55
|
+
export type SubscriptionListEntry = {
|
|
56
|
+
name: string;
|
|
57
|
+
target: string;
|
|
58
|
+
consumes?: string[];
|
|
59
|
+
configuredAtOffset: number;
|
|
60
|
+
afterOffset?: number;
|
|
61
|
+
/** Set when this row hosts a facet (a processor). `restarts`: how many times the platform failed
|
|
62
|
+
* the facet at its start and the context restarted it under a fresh loaded identity (a platform
|
|
63
|
+
* defect the context works around; the count is the cheap way to ask "how often, here"). */
|
|
64
|
+
hostedFacet?: {
|
|
65
|
+
name: string;
|
|
66
|
+
className: string;
|
|
67
|
+
cacheKey?: string;
|
|
68
|
+
restarts: number;
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
/** A loaded worker's source: its modules, literally, or an itx expression that produces them (then
|
|
72
|
+
* `cacheKey` names the build, and the caller owns "same key ⇒ same code"). */
|
|
73
|
+
export type WorkerSource = Record<string, string> | ItxExpressionInput;
|
|
74
|
+
/** What hosts a class as a durable facet — `facets.get(name, spec)`, `processors.enable(name, spec)`. */
|
|
75
|
+
export type FacetSpec = {
|
|
76
|
+
source: WorkerSource;
|
|
77
|
+
cacheKey?: string;
|
|
78
|
+
className: string;
|
|
79
|
+
};
|
|
80
|
+
/** What `schedules.set` answers: the definition's identity, to cancel exactly it. */
|
|
81
|
+
export type ScheduleReceipt = {
|
|
82
|
+
key: string;
|
|
83
|
+
scheduledAtOffset: number;
|
|
84
|
+
};
|
|
85
|
+
/** A secret's material: one string (`getSecret("/secrets/<name>")` is the whole value) or a JSON
|
|
86
|
+
* object whose string fields `getSecret("/secrets/<name>", { field: "a.b" })` picks — the
|
|
87
|
+
* multidimensional shape a credential exchange needs (`{ username, password, accessToken }`,
|
|
88
|
+
* `{ clientId, clientSecret, refreshToken, accessToken }`). A JSON STRING still works as an object
|
|
89
|
+
* (`set(name, JSON.stringify({...}))`). */
|
|
90
|
+
export type SecretMaterial = string | Record<string, unknown>;
|
|
91
|
+
/** How a token endpoint wants the client credential — the RFC 8414 `token_endpoint_auth_methods_supported`
|
|
92
|
+
* registry values, so a provider's discovery document pastes straight in: `client_secret_basic`
|
|
93
|
+
* (HTTP Basic — Google, Slack, the petshop; the default), `client_secret_post` (`client_id` +
|
|
94
|
+
* `client_secret` as form fields — GitHub, Linear), `none` (a public client: `client_id` alone,
|
|
95
|
+
* PKCE stands in for the secret). RFC 6749 §2.3.1 forbids sending two forms at once. */
|
|
96
|
+
export type ClientAuth = "client_secret_basic" | "client_secret_post" | "none";
|
|
97
|
+
/** How the secret's facet re-mints an expired credential, in its own trusted code: the
|
|
98
|
+
* exchange reads this secret's own material, POSTs to an endpoint within the pin, and writes the
|
|
99
|
+
* answer back into the material — `accessToken` (and a rotated `refreshToken`). Triggered on a 401
|
|
100
|
+
* from the pinned host, and on first use when the placeholder's field is not there yet. */
|
|
101
|
+
export type SecretRefresh =
|
|
102
|
+
/** RFC 6749 §6, the refresh_token grant: `refreshToken` + `clientId` (+ `clientSecret` for a
|
|
103
|
+
* confidential client) from the material → `accessToken` (+ the newest `refreshToken`). Google,
|
|
104
|
+
* GitHub, an MCP server's authorization server, the petshop fixture. */
|
|
105
|
+
{
|
|
106
|
+
kind: "oauth-refresh-token";
|
|
107
|
+
tokenEndpoint: string;
|
|
108
|
+
clientAuth?: ClientAuth;
|
|
109
|
+
}
|
|
110
|
+
/** The username/password → session-token archetype's one instance so far, Waitrose's login: POST
|
|
111
|
+
* the Android app's `NewSession` GraphQL mutation with `username`/`password` from the material →
|
|
112
|
+
* `accessToken`. Waitrose has no refresh grant — re-login IS the refresh — so one strategy covers
|
|
113
|
+
* the first-use mint and the 401 re-mint. Vendor-specific on purpose: a caller-supplied login
|
|
114
|
+
* template would put an arbitrary request body in trusted code; a second vendor of this shape
|
|
115
|
+
* earns the generalization, not before. */
|
|
116
|
+
| {
|
|
117
|
+
kind: "waitrose-session";
|
|
118
|
+
graphqlUrl: string;
|
|
119
|
+
};
|
|
120
|
+
/** A secret's catalog entry — `secrets.list()` — its path, the pin, the strategy's KIND and when
|
|
121
|
+
* it was first set; never a value (the owner root's fold of the `secret/set` certificates). */
|
|
122
|
+
export type SecretCatalogEntry = {
|
|
123
|
+
path: string;
|
|
124
|
+
urls: string[];
|
|
125
|
+
refresh?: SecretRefresh["kind"];
|
|
126
|
+
createdAt: string;
|
|
127
|
+
};
|
|
128
|
+
/** The input an agent gives `itx.secrets.collectFromUser`: the write-only secret path, the
|
|
129
|
+
* origins its material may reach, and the short explanation the authenticated collection form
|
|
130
|
+
* shows its user. */
|
|
131
|
+
export type CollectSecretInput = {
|
|
132
|
+
path: string;
|
|
133
|
+
egress: {
|
|
134
|
+
urls: string[];
|
|
135
|
+
};
|
|
136
|
+
description?: string;
|
|
137
|
+
};
|
|
138
|
+
/** A secret collection link. Sending this asks the person to authenticate to the intended
|
|
139
|
+
* Iterate instance; it is not itself permission to write a secret. */
|
|
140
|
+
export type CollectSecretLink = {
|
|
141
|
+
path: string;
|
|
142
|
+
url: string;
|
|
143
|
+
};
|
|
144
|
+
/** A context (a project, a user, an organization): every `itx` root, reached through `invoke`. */
|
|
145
|
+
export interface IterateContextApi {
|
|
146
|
+
invoke(call: ItxExpressionInput, ...args: unknown[]): Promise<unknown>;
|
|
147
|
+
/** Another context of this project, by path (`..` and `/` allowed; the global namespace is not). */
|
|
148
|
+
cd(path: string): IterateContextApi;
|
|
149
|
+
/** Durable batches appended after a deadline (`afterMs`), at an instant (`at`) or on an interval
|
|
150
|
+
* (`everyMs`); a key set again is replaced; a receipt cancels exactly the definition it names. */
|
|
151
|
+
schedules: {
|
|
152
|
+
set(input: {
|
|
153
|
+
key: string | [string, string];
|
|
154
|
+
when: {
|
|
155
|
+
at: string;
|
|
156
|
+
} | {
|
|
157
|
+
afterMs: number;
|
|
158
|
+
} | {
|
|
159
|
+
everyMs: number;
|
|
160
|
+
};
|
|
161
|
+
events: StreamEventInput[];
|
|
162
|
+
}, options?: {
|
|
163
|
+
idempotencyKey?: string;
|
|
164
|
+
}): Promise<ScheduleReceipt>;
|
|
165
|
+
cancel(schedule: string | [string, string] | ScheduleReceipt): Promise<StreamEvent[]>;
|
|
166
|
+
};
|
|
167
|
+
whoami(): {
|
|
168
|
+
projectId: string;
|
|
169
|
+
path: string;
|
|
170
|
+
projectSlug?: string;
|
|
171
|
+
projectUrl?: string;
|
|
172
|
+
} | Promise<{
|
|
173
|
+
projectId: string;
|
|
174
|
+
path: string;
|
|
175
|
+
projectSlug?: string;
|
|
176
|
+
projectUrl?: string;
|
|
177
|
+
}>;
|
|
178
|
+
append(...events: StreamEventInput[]): Promise<StreamEvent[]>;
|
|
179
|
+
readEvents(afterOffset?: number, limit?: number, options?: {
|
|
180
|
+
includeEphemeral?: boolean;
|
|
181
|
+
}): Promise<StreamPage>;
|
|
182
|
+
waitForEvent(filter?: WaitForEventFilter): Promise<StreamEvent>;
|
|
183
|
+
fetch(request: Request): Promise<Response>;
|
|
184
|
+
kv: {
|
|
185
|
+
get(key: string): Promise<string | null>;
|
|
186
|
+
put(key: string, value: string): Promise<{
|
|
187
|
+
ok: true;
|
|
188
|
+
}>;
|
|
189
|
+
delete(key: string): Promise<{
|
|
190
|
+
ok: true;
|
|
191
|
+
}>;
|
|
192
|
+
list(prefix?: string): Promise<{
|
|
193
|
+
keys: string[];
|
|
194
|
+
}>;
|
|
195
|
+
};
|
|
196
|
+
/** The project's secrets, WRITE-ONLY: a secret IS its path (`/secrets/<name>`, the name
|
|
197
|
+
* `[a-zA-Z0-9._-]+`), and the path is what an outbound request's placeholder spells —
|
|
198
|
+
* `getSecret("/secrets/<name>")` in a URL or a header substitutes to the value at egress, and only
|
|
199
|
+
* towards the ORIGINS in `urls` (required: a secret is always pinned). `set` stores a string or a
|
|
200
|
+
* JSON object (`refresh` names the strategy that re-mints an expiring credential); `delete`
|
|
201
|
+
* forgets it (re-settable); `list` is the catalog — paths, pins, strategy kinds, when first set —
|
|
202
|
+
* never a value. Every change is one fact on the secret's path (`secret/set`, `secret/deleted`),
|
|
203
|
+
* attributed to the caller and cross-posted to the root, so the log says who set what and when. */
|
|
204
|
+
secrets: {
|
|
205
|
+
set(path: string, material: SecretMaterial, options: {
|
|
206
|
+
urls: string[];
|
|
207
|
+
refresh?: SecretRefresh;
|
|
208
|
+
}): Promise<{
|
|
209
|
+
path: string;
|
|
210
|
+
}>;
|
|
211
|
+
delete(path: string): Promise<{
|
|
212
|
+
path: string;
|
|
213
|
+
}>;
|
|
214
|
+
list(): Promise<SecretCatalogEntry[]>;
|
|
215
|
+
/** Build the authenticated Dash link where a person enters a value an agent must never see in
|
|
216
|
+
* chat. The link fixes the project, platform instance, secret path and egress pin. If called
|
|
217
|
+
* from an agent context, a successful submission messages that same agent with the path only. */
|
|
218
|
+
collectFromUser(input: CollectSecretInput): Promise<CollectSecretLink>;
|
|
219
|
+
};
|
|
220
|
+
/** The table this context resolves against, described — the tree a model reads. `list()` follows a
|
|
221
|
+
* bare hop row into the context it names (a Durable Object hop, hence async). */
|
|
222
|
+
rewriteRules: {
|
|
223
|
+
list(): Promise<RewriteRuleListEntry[]>;
|
|
224
|
+
get(match: string): Promise<RewriteRuleListEntry | null>;
|
|
225
|
+
resolve(call: ItxExpressionInput): string[];
|
|
226
|
+
};
|
|
227
|
+
facets: {
|
|
228
|
+
get(name: string, spec?: FacetSpec): FacetHandle;
|
|
229
|
+
};
|
|
230
|
+
subscriptions: {
|
|
231
|
+
list(): SubscriptionListEntry[];
|
|
232
|
+
get(name: string): SubscriptionListEntry | null;
|
|
233
|
+
};
|
|
234
|
+
processors: {
|
|
235
|
+
enable(name: string, spec?: (FacetSpec & {
|
|
236
|
+
consumes?: string[];
|
|
237
|
+
}) | {
|
|
238
|
+
consumes?: string[];
|
|
239
|
+
}): Promise<{
|
|
240
|
+
name: string;
|
|
241
|
+
}>;
|
|
242
|
+
disable(name: string): Promise<void>;
|
|
243
|
+
list(): SubscriptionListEntry[];
|
|
244
|
+
/** A hosted processor's claim on this context's alarm: "revive me by `at`" (a facet with a
|
|
245
|
+
* `runInBackground` attempt in flight), or `null` to release it. */
|
|
246
|
+
claim(name: string, at: number | null): Promise<void>;
|
|
247
|
+
};
|
|
248
|
+
workers: {
|
|
249
|
+
get(spec: {
|
|
250
|
+
source: WorkerSource;
|
|
251
|
+
cacheKey?: string;
|
|
252
|
+
className?: string;
|
|
253
|
+
props?: unknown;
|
|
254
|
+
}): InvokeHandle;
|
|
255
|
+
};
|
|
256
|
+
/** A subscription: a pure itx expression, or a live callback lent to the registry (what live state
|
|
257
|
+
* uses); `null` removes the row. The handle's dispose removes it too. */
|
|
258
|
+
subscribe(input: {
|
|
259
|
+
name?: string;
|
|
260
|
+
target: ItxExpressionInput | ((events: unknown[], range: unknown) => void) | null;
|
|
261
|
+
consumes?: string[];
|
|
262
|
+
afterOffset?: number;
|
|
263
|
+
}): Promise<{
|
|
264
|
+
[Symbol.dispose](): void;
|
|
265
|
+
}>;
|
|
266
|
+
/** A rewrite rule of this context, session-scoped (the handle's dispose removes it): the event's
|
|
267
|
+
* payload `{ match, target, description? }`, or the shorthand `(match, target)`. `target` is an
|
|
268
|
+
* expression, or null to deny. The durable spelling is the same payload through `itx.append`. */
|
|
269
|
+
provide(input: RewriteRuleConfigured): Promise<{
|
|
270
|
+
[Symbol.dispose](): void;
|
|
271
|
+
}>;
|
|
272
|
+
provide(match: ItxExpressionInput, target: unknown): Promise<{
|
|
273
|
+
[Symbol.dispose](): void;
|
|
274
|
+
}>;
|
|
275
|
+
/** A script — the text of `async (itx) => { … }` — run once against this context, on its log:
|
|
276
|
+
* `context/run-requested` under the caller, the context's runner, `run-settled` (JSON in, JSON
|
|
277
|
+
* out); resolves with the result or rejects with the settlement's error. Never re-run. */
|
|
278
|
+
run(script: string): Promise<unknown>;
|
|
279
|
+
/** The project's repos, workspaces and agents as domain objects — one shape each: `get(path)` is
|
|
280
|
+
* the entity's facet on the context at `path` (its verbs, plus the typed `append` on that
|
|
281
|
+
* context), `list()` the project catalog, `create(path)` the creation saga on that path (the
|
|
282
|
+
* parent link the caller's context writes first, then the processor row, the request, the
|
|
283
|
+
* terminal fact — created, or create-failed thrown), `delete(path)` the deletion saga (the
|
|
284
|
+
* request, `deleted` cross-posted to `/`, the row disabled). A relative `path` means the caller's. */
|
|
285
|
+
repos: {
|
|
286
|
+
get(path: string): InvokeHandle;
|
|
287
|
+
list(): Promise<{
|
|
288
|
+
path: string;
|
|
289
|
+
createdAt: string;
|
|
290
|
+
}[]>;
|
|
291
|
+
create(path: string): Promise<{
|
|
292
|
+
path: string;
|
|
293
|
+
}>;
|
|
294
|
+
delete(path: string): Promise<{
|
|
295
|
+
path: string;
|
|
296
|
+
}>;
|
|
297
|
+
};
|
|
298
|
+
workspaces: {
|
|
299
|
+
get(path: string): InvokeHandle;
|
|
300
|
+
list(): Promise<{
|
|
301
|
+
path: string;
|
|
302
|
+
createdAt: string;
|
|
303
|
+
}[]>;
|
|
304
|
+
create(path: string): Promise<{
|
|
305
|
+
path: string;
|
|
306
|
+
}>;
|
|
307
|
+
delete(path: string): Promise<{
|
|
308
|
+
path: string;
|
|
309
|
+
}>;
|
|
310
|
+
};
|
|
311
|
+
/** Workers AI under this context's capability rules. */
|
|
312
|
+
ai: Ai;
|
|
313
|
+
/** Files stored in the project's object store. */
|
|
314
|
+
files: {
|
|
315
|
+
get(path: string): InvokeHandle & {
|
|
316
|
+
put(input: {
|
|
317
|
+
contentType?: string;
|
|
318
|
+
data: Uint8Array | ArrayBuffer | string;
|
|
319
|
+
}): Promise<{
|
|
320
|
+
path: string;
|
|
321
|
+
contentType: string;
|
|
322
|
+
size: number;
|
|
323
|
+
}>;
|
|
324
|
+
bytes(): Promise<Uint8Array>;
|
|
325
|
+
head(): Promise<{
|
|
326
|
+
path: string;
|
|
327
|
+
contentType: string;
|
|
328
|
+
size: number;
|
|
329
|
+
} | null>;
|
|
330
|
+
delete(): Promise<void>;
|
|
331
|
+
url(input?: {
|
|
332
|
+
method?: "GET" | "PUT";
|
|
333
|
+
expiresInSeconds?: number;
|
|
334
|
+
}): Promise<{
|
|
335
|
+
url: string;
|
|
336
|
+
expiresAt: string;
|
|
337
|
+
}>;
|
|
338
|
+
};
|
|
339
|
+
list(prefix?: string): Promise<{
|
|
340
|
+
path: string;
|
|
341
|
+
contentType: string;
|
|
342
|
+
size: number;
|
|
343
|
+
}[]>;
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
/** One OAuth grant as `grants.list()` shows it: a session, a connected app, a minted token. */
|
|
347
|
+
export interface GrantRecord {
|
|
348
|
+
id: string;
|
|
349
|
+
clientId?: string;
|
|
350
|
+
logoUri?: string;
|
|
351
|
+
clientDomain?: string;
|
|
352
|
+
name: string;
|
|
353
|
+
kind: string;
|
|
354
|
+
createdAt: number;
|
|
355
|
+
expiresAt: number | null;
|
|
356
|
+
lastUsedAt: number | null;
|
|
357
|
+
cleanupPending: boolean;
|
|
358
|
+
expired: boolean;
|
|
359
|
+
/** The grant this very session rides on. */
|
|
360
|
+
current?: boolean;
|
|
361
|
+
}
|
|
362
|
+
/** What the consent screen shows for an authorization request. */
|
|
363
|
+
export type ConsentAnswer = {
|
|
364
|
+
kind: "consent";
|
|
365
|
+
query: string;
|
|
366
|
+
clientName: string;
|
|
367
|
+
email: string;
|
|
368
|
+
projects: ProjectRecord[];
|
|
369
|
+
orgs: OrgRecord[];
|
|
370
|
+
projectBound: boolean;
|
|
371
|
+
/** the scopes the request asked for, each with the page's copy (oauth-scopes.ts) */
|
|
372
|
+
scopes: ConsentScope[];
|
|
373
|
+
denyLocation: string;
|
|
374
|
+
/** how projects are reached over HTTP (project-ingress.ts) — the page composes a project's URL */
|
|
375
|
+
ingressRouting: IngressRouting;
|
|
376
|
+
/** the onboarding step's first draft of an organization name, from the person's name or email */
|
|
377
|
+
suggestedOrganizationName: string;
|
|
378
|
+
} | {
|
|
379
|
+
kind: "redirect";
|
|
380
|
+
location: string;
|
|
381
|
+
} | {
|
|
382
|
+
kind: "invalid";
|
|
383
|
+
description: string;
|
|
384
|
+
};
|
|
385
|
+
/** An organization as the session lists it: its minted id, its free-text name, the person's role
|
|
386
|
+
* in it, and how many projects it holds (every one of them, not only those this grant lists). */
|
|
387
|
+
export interface OrgRecord {
|
|
388
|
+
id: string;
|
|
389
|
+
name: string;
|
|
390
|
+
role?: string;
|
|
391
|
+
projects: number;
|
|
392
|
+
}
|
|
393
|
+
/** A project as the catalog lists it: addressed by `id` everywhere (`projects.get`, a grant's list,
|
|
394
|
+
* an MCP call's `project`, an app's URL); `slug` is the label of its hostnames and its name to a
|
|
395
|
+
* person. The id is the one stable identifier. */
|
|
396
|
+
export interface ProjectRecord {
|
|
397
|
+
id: string;
|
|
398
|
+
slug: string;
|
|
399
|
+
orgId: string;
|
|
400
|
+
}
|
|
401
|
+
/** The session `authenticate` vends: who is calling, and the contexts they reach. */
|
|
402
|
+
export interface IterateSessionApi {
|
|
403
|
+
whoami(): Principal;
|
|
404
|
+
/** Safe bootstrap data for every app, regardless of which host serves it. */
|
|
405
|
+
info(): {
|
|
406
|
+
principal: Principal;
|
|
407
|
+
scopes: string[];
|
|
408
|
+
platformOrigin: string;
|
|
409
|
+
/** how projects are reached over HTTP (project-ingress.ts `projectUrlOf`); null ⇒ no ingress */
|
|
410
|
+
ingressRouting: IngressRouting;
|
|
411
|
+
/** the MCP server's origin (the dash's connect page) — "" when this deployment serves none */
|
|
412
|
+
mcpOrigin: string;
|
|
413
|
+
};
|
|
414
|
+
/** The organizations this session reaches. */
|
|
415
|
+
orgs(): Promise<OrgRecord[]>;
|
|
416
|
+
/** A new organization — `organizations:write`; the person is its owner. */
|
|
417
|
+
createOrg(name: string): Promise<OrgRecord>;
|
|
418
|
+
/** Rename an organization the person owns — `organizations:write`. */
|
|
419
|
+
updateOrg(orgId: string, input: {
|
|
420
|
+
name: string;
|
|
421
|
+
}): Promise<OrgRecord>;
|
|
422
|
+
/** Delete an organization the person owns, while it holds no project — `organizations:write`. */
|
|
423
|
+
deleteOrg(orgId: string): Promise<void>;
|
|
424
|
+
/** OAuth grants this session may manage (a signed-in person's): list, end, mint one for a device. */
|
|
425
|
+
grants: {
|
|
426
|
+
list(cursor?: string): Promise<{
|
|
427
|
+
items: GrantRecord[];
|
|
428
|
+
cursor?: string;
|
|
429
|
+
projects: ProjectRecord[];
|
|
430
|
+
canMintToken: boolean;
|
|
431
|
+
}>;
|
|
432
|
+
end(grantId: string): Promise<unknown>;
|
|
433
|
+
endCurrent(): Promise<unknown>;
|
|
434
|
+
mint(input: unknown): Promise<{
|
|
435
|
+
token: string;
|
|
436
|
+
expiresAt: number;
|
|
437
|
+
}>;
|
|
438
|
+
};
|
|
439
|
+
/** The consent screen's methods (the OAuth authorize flow): describe a request, approve it. */
|
|
440
|
+
consent: {
|
|
441
|
+
describe(query: string): Promise<ConsentAnswer>;
|
|
442
|
+
approve(input: {
|
|
443
|
+
query: string;
|
|
444
|
+
projects: string[];
|
|
445
|
+
}): Promise<{
|
|
446
|
+
redirectTo: string;
|
|
447
|
+
} | {
|
|
448
|
+
error: string;
|
|
449
|
+
}>;
|
|
450
|
+
};
|
|
451
|
+
projects: {
|
|
452
|
+
list(): Promise<ProjectRecord[]>;
|
|
453
|
+
/** the project's root context, by its slug or its id */
|
|
454
|
+
get(project: string): Promise<IterateContextApi>;
|
|
455
|
+
/** Config repository presets available on this platform. */
|
|
456
|
+
templates(): Promise<{
|
|
457
|
+
label: string;
|
|
458
|
+
reference: string;
|
|
459
|
+
}[]>;
|
|
460
|
+
/** a new project: `project` is slugged into its hostname label, its id is minted — the returned
|
|
461
|
+
* context's `whoami()` says it, so does `list()` */
|
|
462
|
+
create(input: {
|
|
463
|
+
project: string;
|
|
464
|
+
orgId?: string;
|
|
465
|
+
configRepoTemplate?: string;
|
|
466
|
+
/** Operator-only recovery: retain the source project identity from a project seed. */
|
|
467
|
+
restoreProjectId?: string;
|
|
468
|
+
}): Promise<IterateContextApi>;
|
|
469
|
+
};
|
|
470
|
+
organizations: {
|
|
471
|
+
get(orgId: string): Promise<IterateContextApi>;
|
|
472
|
+
};
|
|
473
|
+
user: IterateContextApi;
|
|
474
|
+
logout(): unknown;
|
|
475
|
+
}
|
|
476
|
+
/** THE `/api` ROOT — the one thing a fresh capnweb connection holds. */
|
|
477
|
+
export interface IterateApi {
|
|
478
|
+
authenticate(credentials: SessionCredentials): Promise<IterateSessionApi>;
|
|
479
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { BrowserHost, BrowserSession } from "./app-session.ts";
|
|
2
|
+
export declare function appSession(namespace: DurableObjectNamespace<BrowserSession>, request: Request): DurableObjectStub<BrowserSession> | null;
|
|
3
|
+
/** Start one ordinary app session; the caller publishes its cookie after its own
|
|
4
|
+
* sign-in step succeeds. The issuer uses this same code/PKCE flow internally. */
|
|
5
|
+
export declare function startAppSession(sessions: DurableObjectNamespace<BrowserSession>, host: BrowserHost, next: string): Promise<{
|
|
6
|
+
session: DurableObjectStub<BrowserSession>;
|
|
7
|
+
location: string;
|
|
8
|
+
setCookie: string;
|
|
9
|
+
}>;
|
|
10
|
+
/** What an issuer a person names must be: an https ORIGIN (a path or query is dropped, not refused),
|
|
11
|
+
* not an IP literal, not loopback, and not under one of this deployment's own zones (`denyZones` —
|
|
12
|
+
* a project host on our wildcard is userspace and could serve a look-alike issuer) — unless it IS
|
|
13
|
+
* the deployment's default issuer, which is always allowed as it is. Pure: the discovery check that
|
|
14
|
+
* the origin really answers as that issuer is `issuerAnswersAt`. */
|
|
15
|
+
export declare function issuerOriginOf(candidate: string, options: {
|
|
16
|
+
defaultIssuer: string;
|
|
17
|
+
denyZones?: readonly string[];
|
|
18
|
+
}): {
|
|
19
|
+
origin: string;
|
|
20
|
+
} | {
|
|
21
|
+
error: string;
|
|
22
|
+
};
|
|
23
|
+
type AppAuth = {
|
|
24
|
+
/** Public app branding; relative logo paths resolve against this app's origin. */
|
|
25
|
+
client?: {
|
|
26
|
+
name: string;
|
|
27
|
+
logoUri: string;
|
|
28
|
+
};
|
|
29
|
+
sessions: DurableObjectNamespace<BrowserSession>;
|
|
30
|
+
/** The deployment's own issuer — where a browser with no session signs in. */
|
|
31
|
+
issuer: string;
|
|
32
|
+
/** Its `/api`. */
|
|
33
|
+
resource: string;
|
|
34
|
+
/** Platform dispatches in process to avoid /api recursion; other apps pass fetch. */
|
|
35
|
+
api: (request: Request) => Promise<Response> | Response;
|
|
36
|
+
/** The issuer proves identity before establishing its own ordinary app session. */
|
|
37
|
+
loginPage?: string;
|
|
38
|
+
/** Zones no connectable issuer may live under (`issuerOriginOf`): this deployment's own, whose
|
|
39
|
+
* project hosts are userspace. The default issuer is exempt. */
|
|
40
|
+
denyZones?: readonly string[];
|
|
41
|
+
};
|
|
42
|
+
/** The same OAuth client and /api proxy on a platform host or a separate app worker. */
|
|
43
|
+
export declare function appAuth(request: Request, config: AppAuth): Promise<Response | null>;
|
|
44
|
+
export {};
|