@nathanstephenson/flow 0.1.10-beta.1 → 0.1.10-beta.10
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 +52 -22
- package/build/backend-worker-chunks/{chunk-CYE5L6Z5.mjs → chunk-3KDHJA5P.mjs} +41 -10
- package/build/backend-worker-chunks/{chunk-UQDH2COY.mjs → chunk-K774KOGL.mjs} +2 -7
- package/build/backend-worker-chunks/chunk-LAEUXDNH.mjs +130 -0
- package/build/backend-worker-chunks/{chunk-MLOUI3ZM.mjs → chunk-NZZME2I3.mjs} +6 -1
- package/build/backend-worker-chunks/claude-JG2FXYBQ.mjs +35859 -0
- package/build/backend-worker-chunks/{pi-UKRC4DDM.mjs → pi-KJSP23AO.mjs} +2091 -92
- package/build/backend-worker.mjs +69 -122
- package/build/workflow-runtime.cjs +12 -12
- package/dist/backend/claude/background-calls.js +7 -3
- package/dist/backend/claude/import.js +415 -0
- package/dist/backend/claude/index.js +188 -25
- package/dist/backend/claude/subagents.js +41 -9
- package/dist/backend/claude/todo-list.js +114 -0
- package/dist/backend/claude/workflow-parent.js +1 -1
- package/dist/backend/diff-excerpt-instructions.js +8 -0
- package/dist/backend/fake/index.js +54 -6
- package/dist/backend/mcp.js +4 -1
- package/dist/backend/pi/agent-permissions.js +1 -1
- package/dist/backend/pi/cache-warming.js +8 -0
- package/dist/backend/pi/canonical-json.js +120 -0
- package/dist/backend/pi/compaction-model.js +3 -2
- package/dist/backend/pi/host-auth.js +258 -0
- package/dist/backend/pi/import.js +269 -0
- package/dist/backend/pi/index.js +118 -20
- package/dist/backend/pi/model-auth.js +159 -0
- package/dist/backend/pi/model-catalog.js +120 -0
- package/dist/backend/pi/model-config.js +5 -0
- package/dist/backend/pi/model-selection.js +32 -0
- package/dist/backend/pi/plan-limits.js +41 -0
- package/dist/backend/pi/state.js +19 -1
- package/dist/backend/pi/subagents.js +7 -3
- package/dist/backend/pi/todo-list.js +23 -0
- package/dist/backend/pi/work.js +9 -1
- package/dist/backend/pi/workflow-parent.js +1 -1
- package/dist/backend/pi/workflow-subagent.js +4 -3
- package/dist/backend/plan-limits.js +17 -0
- package/dist/backend/session-tools.js +1 -1
- package/dist/backend/worker/claude-state.js +48 -0
- package/dist/backend/worker/entry.js +42 -8
- package/dist/backend/worker/index.js +131 -15
- package/dist/backend/worker/launcher.js +11 -4
- package/dist/backend/worker/protocol.js +2 -1
- package/dist/backend/worker/rpc.js +13 -0
- package/dist/backend/worker/sandbox-mcp.js +18 -7
- package/dist/backend/workflow-tools.js +9 -7
- package/dist/build-id +1 -1
- package/dist/cli/application.js +48 -42
- package/dist/cli/bootstrap.js +2 -2
- package/dist/cli/host-control.js +1 -1
- package/dist/cli/install-guard.js +2 -2
- package/dist/cli/main.js +4 -4
- package/dist/cli/systemd-update.js +3 -3
- package/dist/cli/update.js +6 -6
- package/dist/cli/web-update.js +6 -6
- package/dist/client/connection.js +46 -0
- package/dist/client/context-usage.js +3 -4
- package/dist/client/diff.js +40 -0
- package/dist/client/enquiry.js +0 -6
- package/dist/client/markdown.js +3 -2
- package/dist/client/model-choices.js +1 -1
- package/dist/client/permission.js +1 -2
- package/dist/client/project-name.js +3 -1
- package/dist/client/reduce.js +77 -3
- package/dist/client/relative-time.js +1 -1
- package/dist/client/scope-kind.js +6 -3
- package/dist/client/search.js +1 -1
- package/dist/client/status.js +1 -1
- package/dist/client/subagent-tree.js +49 -0
- package/dist/client/tool-chains.js +1 -1
- package/dist/client/tool-summary.js +28 -18
- package/dist/daemon/changes.js +128 -0
- package/dist/daemon/commit.js +84 -0
- package/dist/daemon/config-store.js +8 -3
- package/dist/daemon/config.js +105 -4
- package/dist/daemon/diff-excerpts.js +52 -0
- package/dist/daemon/git-state.js +197 -0
- package/dist/daemon/git.js +53 -10
- package/dist/daemon/github-image.js +18 -0
- package/dist/daemon/github.js +54 -0
- package/dist/daemon/host-control-routes.js +1 -1
- package/dist/daemon/host.js +940 -119
- package/dist/daemon/http.js +4 -1
- package/dist/daemon/log.js +3 -0
- package/dist/daemon/mcp-auth.js +1 -1
- package/dist/daemon/models.js +2 -2
- package/dist/daemon/pi-model-cache.js +44 -0
- package/dist/daemon/pull-request.js +223 -138
- package/dist/daemon/push.js +43 -0
- package/dist/daemon/repository.js +123 -0
- package/dist/daemon/runtime.js +103 -22
- package/dist/daemon/secret-store.js +1 -1
- package/dist/daemon/server.js +111 -14
- package/dist/daemon/skills.js +24 -0
- package/dist/daemon/spend-ledger.js +118 -0
- package/dist/daemon/stack-metadata.js +12 -5
- package/dist/daemon/stack.js +162 -657
- package/dist/daemon/store.js +2 -0
- package/dist/daemon/summariser.js +30 -12
- package/dist/daemon/tour.js +56 -0
- package/dist/daemon/whisper.js +144 -0
- package/dist/daemon/workflow-authoring-scope-checks.js +1 -1
- package/dist/daemon/workflow-authoring-scope.js +1 -1
- package/dist/daemon/workflow-builder-files.js +2 -2
- package/dist/daemon/workflow-builder-guidance.js +1 -1
- package/dist/daemon/workflow-builder-routes.js +2 -2
- package/dist/daemon/workflow-builder.js +44 -17
- package/dist/daemon/workflow-environment.js +193 -0
- package/dist/daemon/workflow-execution-launch.js +77 -0
- package/dist/daemon/workflow-execution-resources.js +76 -0
- package/dist/daemon/workflow-execution-routes.js +12 -9
- package/dist/daemon/workflow-execution-values.js +128 -0
- package/dist/daemon/workflow-executions.js +400 -311
- package/dist/daemon/workflow-mcp-authoring-routes.js +2 -2
- package/dist/daemon/workflow-mcp-authoring.js +4 -4
- package/dist/daemon/workflow-mcp.js +1 -1
- package/dist/daemon/workflow-routes.js +60 -2
- package/dist/daemon/workflow-schedule-driver.js +251 -0
- package/dist/daemon/workflow-schedule-routes.js +137 -0
- package/dist/daemon/workflow-schedules.js +342 -0
- package/dist/isolation/filesystem.js +6 -2
- package/dist/isolation/sandbox.js +61 -18
- package/dist/isolation/shared-sandbox.js +3 -3
- package/dist/isolation/toolchain-assets.js +1 -1
- package/dist/protocol/events.js +3 -0
- package/dist/protocol/plan-limits.js +1 -0
- package/dist/protocol/settings.js +1 -0
- package/dist/protocol/spend.js +2 -0
- package/dist/protocol/stack.js +12 -39
- package/dist/protocol/workflow-schedules.js +1 -0
- package/dist/workflows/calls.js +53 -0
- package/dist/workflows/errors.js +2 -0
- package/dist/workflows/executors.js +6 -5
- package/dist/workflows/graph.js +83 -9
- package/dist/workflows/invocations.js +23 -0
- package/dist/workflows/mcp.js +1 -1
- package/dist/workflows/owner.js +45 -0
- package/dist/workflows/records.js +127 -11
- package/dist/workflows/recovery.js +38 -2
- package/dist/workflows/runtime-settings.js +16 -16
- package/dist/workflows/runtime.js +2 -2
- package/dist/workflows/schedule-errors.js +2 -0
- package/dist/workflows/schedule-store.js +385 -0
- package/dist/workflows/scheduler.js +367 -96
- package/dist/workflows/schedules.js +130 -0
- package/dist/workflows/schema.js +3 -1
- package/dist/workflows/store.js +126 -13
- package/package.json +10 -6
- package/web/dist/assets/index-C76t-z4w.css +2 -0
- package/web/dist/assets/{index-DRfeO6GJ.js → index-WPfbYVQ4.js} +39 -23
- package/web/dist/assets/{switch-DIogWclb.js → select-C5Ly2OpB.js} +1 -1
- package/web/dist/assets/{settings-mcp-Clp_jMWW.js → settings-mcp-BF-yqpeQ.js} +1 -1
- package/web/dist/assets/{settings-secrets-BIO_hXZ1.js → settings-secrets-WLarr2QP.js} +1 -1
- package/web/dist/assets/settings-workflows-DdcdRWFD.js +23 -0
- package/web/dist/assets/workflow-api-GjAmHc22.js +6 -0
- package/web/dist/assets/workflows-BhY3Uibo.js +149 -0
- package/web/dist/assets/workflows-pane-DElCcEpN.js +1 -0
- package/web/dist/index.html +6 -5
- package/build/backend-worker-chunks/claude-UXZDJKZQ.mjs +0 -30816
- package/dist/daemon/publish.js +0 -289
- package/dist/tui/app.js +0 -612
- package/dist/tui/keys.js +0 -90
- package/dist/tui/render.js +0 -411
- package/web/dist/assets/index-DgQFpKbn.css +0 -2
- package/web/dist/assets/settings-workflows-H-6eCff3.js +0 -23
- package/web/dist/assets/workflow-api-BfExddae.js +0 -6
- package/web/dist/assets/workflow-editors-CsbVx4WJ.js +0 -139
- package/web/dist/assets/workflows-Bv0sj7d0.js +0 -7
- package/web/dist/assets/workflows-pane-DHm44w7P.js +0 -1
- /package/dist/protocol/{publish.js → imports.js} +0 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { run, GIT_READ_TIMEOUT_MS, GIT_WRITE_TIMEOUT_MS } from "./git.js";
|
|
2
|
+
import { api, gh } from "./github.js";
|
|
3
|
+
const unfinished = ["IN_PROGRESS", "PENDING", "QUEUED", "WAITING", "REQUESTED", "EXPECTED"];
|
|
4
|
+
function completed(counts) {
|
|
5
|
+
return [...counts?.checkRunCountsByState ?? [], ...counts?.statusContextCountsByState ?? []].filter(entry => !unfinished.includes(entry.state)).reduce((sum, entry) => sum + entry.count, 0);
|
|
6
|
+
}
|
|
7
|
+
const identities = new Map();
|
|
8
|
+
export async function git(scope, args, write = false) {
|
|
9
|
+
const result = await run(scope, args, write ? GIT_WRITE_TIMEOUT_MS : GIT_READ_TIMEOUT_MS);
|
|
10
|
+
if (!result.ok) {
|
|
11
|
+
if (result.failure.message.includes("ENOENT"))
|
|
12
|
+
throw new Error("Git is missing. Install git on the Session Host.");
|
|
13
|
+
throw new Error(`Git ${result.failure.attempted} failed: ${result.failure.message}`);
|
|
14
|
+
}
|
|
15
|
+
return result.value;
|
|
16
|
+
}
|
|
17
|
+
async function config(scope, key) {
|
|
18
|
+
const result = await run(scope, ["config", "--get", key], GIT_READ_TIMEOUT_MS);
|
|
19
|
+
const value = result.ok ? result.value.trim() : "";
|
|
20
|
+
return value && value !== "." ? value : undefined;
|
|
21
|
+
}
|
|
22
|
+
async function pushRemote(scope, branch) {
|
|
23
|
+
const remotes = (await git(scope, ["remote"])).trim().split("\n").filter(Boolean);
|
|
24
|
+
if (remotes.length === 0)
|
|
25
|
+
return undefined;
|
|
26
|
+
const keys = branch ? [`branch.${branch}.pushRemote`, "remote.pushDefault", `branch.${branch}.remote`] : ["remote.pushDefault"];
|
|
27
|
+
for (const key of keys) {
|
|
28
|
+
const configured = await config(scope, key);
|
|
29
|
+
if (configured)
|
|
30
|
+
return configured;
|
|
31
|
+
}
|
|
32
|
+
if (remotes.includes("origin"))
|
|
33
|
+
return "origin";
|
|
34
|
+
if (remotes.length === 1)
|
|
35
|
+
return remotes[0];
|
|
36
|
+
throw new Error("Cannot identify the push remote for this branch. Set branch.<name>.pushRemote or remote.pushDefault.");
|
|
37
|
+
}
|
|
38
|
+
async function view(scope, repo, github) {
|
|
39
|
+
const info = JSON.parse(await github(scope, ["repo", "view", repo, "--json", "id,defaultBranchRef,isFork,parent"]));
|
|
40
|
+
if (!info.id)
|
|
41
|
+
throw new Error(`GitHub did not return the ID of ${repo}.`);
|
|
42
|
+
if (!info.defaultBranchRef?.name)
|
|
43
|
+
throw new Error(`GitHub has no default branch for ${repo}. Create it first.`);
|
|
44
|
+
return { ...info, id: info.id, defaultBranch: info.defaultBranchRef.name };
|
|
45
|
+
}
|
|
46
|
+
export function githubRepository(url) {
|
|
47
|
+
return /^(?:https:\/\/github\.com\/|git@github\.com:|ssh:\/\/git@github\.com\/)([A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+?)(?:\.git)?$/.exec(url)?.[1];
|
|
48
|
+
}
|
|
49
|
+
export async function localRepository(scope, branch) {
|
|
50
|
+
const remote = await pushRemote(scope, branch);
|
|
51
|
+
if (!remote)
|
|
52
|
+
return undefined;
|
|
53
|
+
const url = (await git(scope, ["remote", "get-url", "--push", remote])).trim();
|
|
54
|
+
const cached = identities.get(`${scope}\0${remote}\0${url}`)?.base.defaultBranch;
|
|
55
|
+
const head = await run(scope, ["symbolic-ref", "--quiet", "--short", `refs/remotes/${remote}/HEAD`], GIT_READ_TIMEOUT_MS);
|
|
56
|
+
const local = head.ok ? head.value.trim().slice(remote.length + 1) : undefined;
|
|
57
|
+
return { remote, github: githubRepository(url) !== undefined, defaultBranches: [...new Set([cached, local].filter((name) => Boolean(name)))] };
|
|
58
|
+
}
|
|
59
|
+
export async function resolveRepository(scope, branch, github = gh) {
|
|
60
|
+
const remote = await pushRemote(scope, branch);
|
|
61
|
+
if (!remote)
|
|
62
|
+
throw new Error("No remote is configured. Add a GitHub remote.");
|
|
63
|
+
const url = (await git(scope, ["remote", "get-url", "--push", remote])).trim();
|
|
64
|
+
const repo = githubRepository(url);
|
|
65
|
+
if (!repo)
|
|
66
|
+
throw new Error("This remote is not a supported github.com repository URL.");
|
|
67
|
+
const key = `${scope}\0${remote}\0${url}`;
|
|
68
|
+
let identity = identities.get(key);
|
|
69
|
+
if (!identity) {
|
|
70
|
+
await github(scope, ["auth", "status", "--hostname", "github.com"]);
|
|
71
|
+
const head = await view(scope, repo, github);
|
|
72
|
+
const parent = head.isFork && head.parent ? `${head.parent.owner.login}/${head.parent.name}` : undefined;
|
|
73
|
+
const base = parent ? await view(scope, parent, github) : head;
|
|
74
|
+
identity = { head: { repo, id: head.id }, base: { repo: parent ?? repo, id: base.id, defaultBranch: base.defaultBranch } };
|
|
75
|
+
identities.set(key, identity);
|
|
76
|
+
}
|
|
77
|
+
return { remote, url, ...identity };
|
|
78
|
+
}
|
|
79
|
+
export function releaseRepositories(kept) {
|
|
80
|
+
for (const key of identities.keys())
|
|
81
|
+
if (!kept.has(key.split("\0")[0]))
|
|
82
|
+
identities.delete(key);
|
|
83
|
+
}
|
|
84
|
+
function checks(rollup) {
|
|
85
|
+
if (!rollup)
|
|
86
|
+
return "none";
|
|
87
|
+
if (rollup.state === "SUCCESS")
|
|
88
|
+
return "passing";
|
|
89
|
+
if (rollup.state === "FAILURE" || rollup.state === "ERROR")
|
|
90
|
+
return "failing";
|
|
91
|
+
return "pending";
|
|
92
|
+
}
|
|
93
|
+
const candidateFields = "id number url title baseRefName headRefOid baseRefOid headRefName state isDraft reviewDecision updatedAt closedAt headRepository{id} commits(last:1){nodes{commit{statusCheckRollup{state contexts(first:0){checkRunCountsByState{state count} statusContextCountsByState{state count}}}}}} reviewThreads(first:100){nodes{isResolved}}";
|
|
94
|
+
function resolved(repo, pr) {
|
|
95
|
+
return {
|
|
96
|
+
repo, id: pr.id, number: pr.number, url: pr.url, title: pr.title, baseBranch: pr.baseRefName, headRefOid: pr.headRefOid, baseRefOid: pr.baseRefOid, headRefName: pr.headRefName, headRepository: pr.headRepository, state: pr.state, isDraft: pr.isDraft,
|
|
97
|
+
checks: checks(pr.commits.nodes[0]?.commit.statusCheckRollup), checksCompleted: completed(pr.commits.nodes[0]?.commit.statusCheckRollup?.contexts), reviewDecision: pr.reviewDecision,
|
|
98
|
+
unresolvedThreads: pr.reviewThreads.nodes.filter(thread => !thread.isResolved).length, updatedAt: pr.updatedAt,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
export async function resolvePullRequest(scope, repository, branch, github = gh) {
|
|
102
|
+
const [owner, name] = repository.base.repo.split("/");
|
|
103
|
+
const data = await api(scope, github, `query($owner:String!,$name:String!,$branch:String!){repository(owner:$owner,name:$name){pullRequests(headRefName:$branch,first:100,orderBy:{field:UPDATED_AT,direction:DESC}){nodes{${candidateFields}}}}}`, { owner: owner, name: name, branch });
|
|
104
|
+
const matches = data.repository.pullRequests.nodes.filter(pr => pr.headRepository?.id === repository.head.id);
|
|
105
|
+
matches.sort((a, b) => Number(b.state === "OPEN") - Number(a.state === "OPEN") || (b.closedAt ?? b.updatedAt).localeCompare(a.closedAt ?? a.updatedAt));
|
|
106
|
+
return matches[0] && resolved(repository.base.repo, matches[0]);
|
|
107
|
+
}
|
|
108
|
+
export async function pullRequestByNumber(scope, repo, number, github = gh) {
|
|
109
|
+
const [owner, name] = repo.split("/");
|
|
110
|
+
const data = await api(scope, github, `query($owner:String!,$name:String!,$number:Int!){repository(owner:$owner,name:$name){pullRequest(number:$number){${candidateFields}}}}`, { owner: owner, name: name, number });
|
|
111
|
+
return data.repository.pullRequest ? resolved(repo, data.repository.pullRequest) : undefined;
|
|
112
|
+
}
|
|
113
|
+
export const writers = ["ADMIN", "MAINTAIN", "WRITE"];
|
|
114
|
+
export const mergeSettingsFields = "isArchived viewerPermission mergeCommitAllowed squashMergeAllowed rebaseMergeAllowed";
|
|
115
|
+
export function mergeMethods(repository) {
|
|
116
|
+
if (repository.isArchived || !writers.includes(repository.viewerPermission ?? ""))
|
|
117
|
+
return [];
|
|
118
|
+
return [
|
|
119
|
+
...(repository.mergeCommitAllowed ? ["MERGE"] : []),
|
|
120
|
+
...(repository.squashMergeAllowed ? ["SQUASH"] : []),
|
|
121
|
+
...(repository.rebaseMergeAllowed ? ["REBASE"] : []),
|
|
122
|
+
];
|
|
123
|
+
}
|
package/dist/daemon/runtime.js
CHANGED
|
@@ -1,19 +1,25 @@
|
|
|
1
|
-
import { registerBackends } from
|
|
2
|
-
import { createOidcGateFromEnv, readOrCreateToken } from
|
|
3
|
-
import { ConfigStore } from
|
|
4
|
-
import { SecretStore } from
|
|
5
|
-
import { WorkflowStore } from
|
|
6
|
-
import { WorkflowExecutionService } from
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
1
|
+
import { registerBackends } from '../backend/registry.js';
|
|
2
|
+
import { createOidcGateFromEnv, readOrCreateToken } from './auth.js';
|
|
3
|
+
import { ConfigStore } from './config-store.js';
|
|
4
|
+
import { SecretStore } from './secret-store.js';
|
|
5
|
+
import { WorkflowStore } from '../workflows/store.js';
|
|
6
|
+
import { WorkflowExecutionService } from './workflow-executions.js';
|
|
7
|
+
import { WorkflowScheduleStore } from '../workflows/schedule-store.js';
|
|
8
|
+
import { WorkflowScheduleService } from './workflow-schedules.js';
|
|
9
|
+
import { scheduleDriver } from './workflow-schedule-driver.js';
|
|
10
|
+
import { WorkflowBuilderService } from './workflow-builder.js';
|
|
11
|
+
import { workflowCatalogue } from './workflow-routes.js';
|
|
12
|
+
import { WorkflowMcpAuthoringService } from './workflow-mcp-authoring.js';
|
|
13
|
+
import { SessionHost } from './host.js';
|
|
14
|
+
import { includedProjects } from './projects.js';
|
|
15
|
+
import { McpAuth } from './mcp-auth.js';
|
|
16
|
+
import { serve } from './server.js';
|
|
17
|
+
import { ShellRegistry } from './shell.js';
|
|
18
|
+
import { WhisperService } from './whisper.js';
|
|
19
|
+
import { TranscriptStore } from './store.js';
|
|
20
|
+
import { acquireHost, readHost, oidcFingerprint } from './ownership.js';
|
|
21
|
+
import { WebUpdateController } from '../cli/web-update.js';
|
|
22
|
+
import { trimTimings } from './timings.js';
|
|
17
23
|
export async function startRuntime(options) {
|
|
18
24
|
const ownership = acquireHost(options.root);
|
|
19
25
|
const root = ownership.root;
|
|
@@ -45,21 +51,43 @@ export async function startRuntime(options) {
|
|
|
45
51
|
store, resolveSecret: name => secrets.resolve(name), retention: config.retention,
|
|
46
52
|
mcpConnections: config.mcpConnections, mcpAuth,
|
|
47
53
|
filesystemIsolationMode: config.filesystemIsolationMode, sandboxSupport: config.sandboxSupport,
|
|
48
|
-
sandboxSharing: config.sandboxSharing, projectRoot: config.projectRoot,
|
|
54
|
+
sandboxSharing: config.sandboxSharing, updateSourceBranch: config.updateSourceBranch, projectRoot: config.projectRoot,
|
|
55
|
+
projectPaths: () => includedProjects(config.rawProjectRoot(), config.projectInclude()).map(project => project.path),
|
|
49
56
|
standingAuthorisations: config.standingAuthorisations, allowTool: config.allowTool,
|
|
50
57
|
defaultBackend: config.defaultBackend, defaultModel: config.defaultModel,
|
|
51
|
-
defaultEffort: config.defaultEffort, defaultPermissionMode: config.defaultPermissionMode, autoCompaction: config.autoCompaction, compactionModel: config.compactionModel, summaryModel: config.summaryModel,
|
|
58
|
+
defaultEffort: config.defaultEffort, defaultPermissionMode: config.defaultPermissionMode, autoCompaction: config.autoCompaction, compactionModel: config.compactionModel, summaryModel: config.summaryModel, tourModel: config.tourModel,
|
|
52
59
|
});
|
|
53
60
|
const shells = new ShellRegistry();
|
|
61
|
+
const dictation = new WhisperService({ stateRoot: root });
|
|
62
|
+
void dictation.restart(config.dictation());
|
|
63
|
+
let workflowSchedules;
|
|
64
|
+
let workflowExecutions;
|
|
54
65
|
let workflowBuilders;
|
|
55
66
|
let workflowMcpAuthoring;
|
|
56
67
|
let running;
|
|
57
68
|
let oidc;
|
|
58
69
|
let sweep;
|
|
70
|
+
let gitPoll;
|
|
71
|
+
let gitPolling;
|
|
59
72
|
let reaping = Promise.resolve();
|
|
60
73
|
let stopping;
|
|
61
74
|
const stop = () => stopping ??= (async () => {
|
|
62
75
|
clearInterval(sweep);
|
|
76
|
+
clearInterval(gitPoll);
|
|
77
|
+
dictation.stop();
|
|
78
|
+
const scheduledErrors = [];
|
|
79
|
+
try {
|
|
80
|
+
await workflowSchedules?.stopAdmission();
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
scheduledErrors.push(error);
|
|
84
|
+
}
|
|
85
|
+
try {
|
|
86
|
+
await workflowExecutions?.stopScheduled();
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
scheduledErrors.push(error);
|
|
90
|
+
}
|
|
63
91
|
const interrupt = async () => { await Promise.all([host.shutdown(), workflowBuilders?.shutdown(), workflowMcpAuthoring?.shutdown(), shells.killAll(), reaping]); };
|
|
64
92
|
if (running)
|
|
65
93
|
await running.stopAdmission(interrupt);
|
|
@@ -77,24 +105,76 @@ export async function startRuntime(options) {
|
|
|
77
105
|
oidc?.dispose();
|
|
78
106
|
}
|
|
79
107
|
ownership.release();
|
|
108
|
+
if (scheduledErrors.length)
|
|
109
|
+
throw new AggregateError(scheduledErrors, 'Scheduled workflow cleanup failed');
|
|
80
110
|
})();
|
|
81
111
|
cleanup = stop;
|
|
82
112
|
registerBackends(host);
|
|
83
113
|
trimTimings(root);
|
|
84
114
|
void host.models(config.projectRoot() ?? process.cwd());
|
|
85
115
|
const workflows = new WorkflowStore(root);
|
|
86
|
-
|
|
116
|
+
store.onSessionDeleted = sessionId => workflows.deleteOwner({ kind: 'session', sessionId });
|
|
117
|
+
workflowExecutions = new WorkflowExecutionService(host, workflows, secrets, config, options.workflowRuntime());
|
|
87
118
|
workflowMcpAuthoring = new WorkflowMcpAuthoringService({ host, config, scope: process.cwd() });
|
|
88
119
|
workflowBuilders = new WorkflowBuilderService({
|
|
89
120
|
host, config, scope: process.cwd(), stateRoot: root,
|
|
90
121
|
validateDefinition: definition => workflowExecutions.validateDefinitionCredentials(definition),
|
|
122
|
+
workflowCatalogue: () => workflowCatalogue(workflows),
|
|
123
|
+
workflowDefinition: id => { try {
|
|
124
|
+
return workflows.getDefinition(id);
|
|
125
|
+
}
|
|
126
|
+
catch {
|
|
127
|
+
return undefined;
|
|
128
|
+
} },
|
|
91
129
|
mcpCatalogue: (scope, projectId, scopeIdentity) => workflowMcpAuthoring.catalogue(projectId, { scope, scopeIdentity }),
|
|
92
130
|
mcpTool: (scope, projectId, scopeIdentity, connectionId, toolName) => workflowMcpAuthoring.tool(projectId, connectionId, toolName, { scope, scopeIdentity }),
|
|
93
131
|
});
|
|
132
|
+
try {
|
|
133
|
+
const schedules = new WorkflowScheduleStore(root);
|
|
134
|
+
workflowSchedules = new WorkflowScheduleService(schedules, scheduleDriver({ host, config, workflows, executions: workflowExecutions, schedules, transcripts: store }));
|
|
135
|
+
workflowExecutions.onScheduledResult = async (record) => { workflowSchedules.result(record); };
|
|
136
|
+
}
|
|
137
|
+
catch {
|
|
138
|
+
workflowExecutions.scheduledOwnershipAvailable = false;
|
|
139
|
+
console.error('Workflow Schedule initialization failed. Scheduling is disabled. Other Session Host services will continue.');
|
|
140
|
+
}
|
|
94
141
|
await host.load();
|
|
142
|
+
try {
|
|
143
|
+
await workflowSchedules?.start();
|
|
144
|
+
}
|
|
145
|
+
catch {
|
|
146
|
+
console.error('Workflow Schedule reconciliation failed. Other Session Host services will continue.');
|
|
147
|
+
}
|
|
95
148
|
workflowExecutions.reconcile();
|
|
96
|
-
|
|
149
|
+
reaping = reaping.then(async () => {
|
|
150
|
+
try {
|
|
151
|
+
await workflowSchedules?.prune();
|
|
152
|
+
}
|
|
153
|
+
catch {
|
|
154
|
+
console.error('Workflow Schedule retention failed. Cleanup will be retried.');
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
sweep = setInterval(() => {
|
|
158
|
+
reaping = reaping.then(async () => {
|
|
159
|
+
try {
|
|
160
|
+
await host.reap();
|
|
161
|
+
}
|
|
162
|
+
catch {
|
|
163
|
+
console.error('Agent Session Reaping failed. The next sweep will retry.');
|
|
164
|
+
}
|
|
165
|
+
try {
|
|
166
|
+
await workflowSchedules?.prune();
|
|
167
|
+
}
|
|
168
|
+
catch {
|
|
169
|
+
console.error('Workflow Schedule retention failed. The next sweep will retry.');
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
}, 60 * 60 * 1000);
|
|
97
173
|
sweep.unref();
|
|
174
|
+
gitPoll = setInterval(() => {
|
|
175
|
+
gitPolling ??= host.pollGitState().finally(() => { gitPolling = undefined; });
|
|
176
|
+
}, 30_000);
|
|
177
|
+
gitPoll.unref();
|
|
98
178
|
host.onSessionClosed(sessionId => shells.killFor(sessionId));
|
|
99
179
|
const token = readOrCreateToken(root);
|
|
100
180
|
oidc = await createOidcGateFromEnv(root);
|
|
@@ -102,7 +182,7 @@ export async function startRuntime(options) {
|
|
|
102
182
|
instanceId: ownership.instanceId, pid: process.pid, version: options.version, url: '', token, mode: options.mode,
|
|
103
183
|
settings: { port: options.port ?? 0, address: options.address ?? '127.0.0.1', cwd: process.cwd(), oidc: oidcFingerprint() },
|
|
104
184
|
};
|
|
105
|
-
const hasActiveWork = () => host.hasActiveWork() || workflowBuilders.hasActiveWork() || workflowMcpAuthoring.hasActiveWork() || shells.hasLiveShells() || host.list().some(session => workflowExecutions.list(session.id).occupied);
|
|
185
|
+
const hasActiveWork = () => !!workflowSchedules?.hasActiveWork() || host.hasActiveWork() || workflowBuilders.hasActiveWork() || workflowMcpAuthoring.hasActiveWork() || shells.hasLiveShells() || host.list().some(session => workflowExecutions.list(session.id).occupied);
|
|
106
186
|
const updates = new WebUpdateController({
|
|
107
187
|
root,
|
|
108
188
|
installedVersion: options.version,
|
|
@@ -115,7 +195,8 @@ export async function startRuntime(options) {
|
|
|
115
195
|
running = await serve({
|
|
116
196
|
control: { identity, stop, hasActiveWork },
|
|
117
197
|
updates,
|
|
118
|
-
host, token, shells, config, mcpAuth, store, workflows, secrets, workflowExecutions, workflowBuilders, workflowMcpAuthoring,
|
|
198
|
+
host, token, shells, config, dictation, mcpAuth, store, workflows, secrets, workflowExecutions, workflowBuilders, workflowMcpAuthoring,
|
|
199
|
+
...(workflowSchedules === undefined ? {} : { workflowSchedules }),
|
|
119
200
|
assets: options.assets(), scope: process.cwd(),
|
|
120
201
|
...(oidc === undefined ? {} : { oidc }),
|
|
121
202
|
...(options.port === undefined ? {} : { port: options.port }),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
2
|
import { chmodSync, closeSync, existsSync, fsyncSync, mkdirSync, openSync, readFileSync, readdirSync, renameSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
|
-
import { validSecretName } from
|
|
4
|
+
import { validSecretName } from '../protocol/secrets.js';
|
|
5
5
|
export class SecretStore {
|
|
6
6
|
directory;
|
|
7
7
|
constructor(stateRoot) {
|
package/dist/daemon/server.js
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
import { createServer } from "node:http";
|
|
2
|
+
import { Readable } from "node:stream";
|
|
3
|
+
import { homedir } from "node:os";
|
|
2
4
|
import { mediaTypeOf } from "../protocol/attachments.js";
|
|
3
5
|
import { ConfigError } from "./config.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
6
|
+
import { gh } from "./github.js";
|
|
7
|
+
import { githubImage } from "./github-image.js";
|
|
8
|
+
import { workflowRoutes } from './workflow-routes.js';
|
|
9
|
+
import { workflowScheduleRoutes } from './workflow-schedule-routes.js';
|
|
10
|
+
import { workflowBuilderRoutes } from './workflow-builder-routes.js';
|
|
11
|
+
import { workflowMcpAuthoringRoutes } from './workflow-mcp-authoring-routes.js';
|
|
12
|
+
import { hostControlRoute } from './host-control-routes.js';
|
|
13
|
+
import { readBody, readBytes, send } from './http.js';
|
|
14
|
+
import { WhisperNotReady } from './whisper.js';
|
|
15
|
+
import { workflowExecutionRoutes } from './workflow-execution-routes.js';
|
|
10
16
|
import { discoverProjects, includedProjects, searchDirectories } from "./projects.js";
|
|
11
17
|
import { gitAvailable, head, isRepository, localBranches, MAX_BRANCHES } from "./git.js";
|
|
12
18
|
import { tokenMatches } from "./auth.js";
|
|
13
19
|
import { CommandRefused } from "./host.js";
|
|
14
|
-
import { UpdateRefusal } from
|
|
20
|
+
import { UpdateRefusal } from './update-api.js';
|
|
15
21
|
const PUBLIC_ICON_PATHS = new Set([
|
|
16
22
|
"/favicon.svg",
|
|
17
23
|
"/favicon-16x16.png",
|
|
@@ -27,6 +33,19 @@ const ICON_LINKS = `<link rel="icon" href="/favicon.svg" type="image/svg+xml">
|
|
|
27
33
|
<link rel="icon" href="/favicon.ico" type="image/x-icon" sizes="16x16 32x32 48x48">
|
|
28
34
|
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5f6368">
|
|
29
35
|
<link rel="apple-touch-icon" href="/apple-touch-icon.png" sizes="180x180">`;
|
|
36
|
+
/**
|
|
37
|
+
* The Session Host's loopback HTTP surface (ADR 0004).
|
|
38
|
+
*
|
|
39
|
+
* Commands are POSTed and events arrive over SSE. SSE rather than WebSocket because the transcript
|
|
40
|
+
* is one-directional and sequence-numbered — reconnect is `?since=N`, which is a replay rather than
|
|
41
|
+
* a resynchronisation protocol — and because it needs no dependency in Node or the browser.
|
|
42
|
+
*
|
|
43
|
+
* A Shell is the one thing here that is not the transcript, and none of that reasoning covers it:
|
|
44
|
+
* it is bidirectional, it carries raw bytes rather than sequenced events, and it has no `?since=N`.
|
|
45
|
+
* So Shells alone speak WebSocket (ADR 0008). The gate is the same on both — same cookie, same
|
|
46
|
+
* strict Origin check — because an upgrade request is an ordinary HTTP request until it is not.
|
|
47
|
+
*/
|
|
48
|
+
const MAX_DICTATION_BYTES = 10_000_000;
|
|
30
49
|
export async function serve(options) {
|
|
31
50
|
const address = options.address ?? "127.0.0.1";
|
|
32
51
|
let stopping = false;
|
|
@@ -291,6 +310,8 @@ ${ICON_LINKS}</head><body><script>window.location.replace(${JSON.stringify(locat
|
|
|
291
310
|
}
|
|
292
311
|
if (await workflowMcpAuthoringRoutes(request, response, url.pathname, options.workflowMcpAuthoring))
|
|
293
312
|
return;
|
|
313
|
+
if (await workflowScheduleRoutes(request, response, url, options.workflowSchedules, options.workflowExecutions))
|
|
314
|
+
return;
|
|
294
315
|
if (await workflowBuilderRoutes(request, response, url.pathname, options.workflowBuilders))
|
|
295
316
|
return;
|
|
296
317
|
if (await workflowExecutionRoutes(request, response, url.pathname, options.workflowExecutions, options.workflows))
|
|
@@ -364,6 +385,14 @@ ${ICON_LINKS}</head><body><script>window.location.replace(${JSON.stringify(locat
|
|
|
364
385
|
send(response, 200, options.host.list());
|
|
365
386
|
return;
|
|
366
387
|
}
|
|
388
|
+
if (request.method === "GET" && url.pathname === "/api/spend") {
|
|
389
|
+
send(response, 200, options.host.spendSummary());
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
if (request.method === "GET" && url.pathname === "/api/plan-limits") {
|
|
393
|
+
send(response, 200, await options.host.planLimits(options.config?.projectRoot() ?? options.scope ?? process.cwd()));
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
367
396
|
if (request.method === "GET" && url.pathname === "/api/config") {
|
|
368
397
|
send(response, 200, {
|
|
369
398
|
// The Project Root first: it is the directory this deployment is anchored to, and a client
|
|
@@ -403,11 +432,12 @@ ${ICON_LINKS}</head><body><script>window.location.replace(${JSON.stringify(locat
|
|
|
403
432
|
// Spread rather than nested so `fonts` stays where it was on the wire.
|
|
404
433
|
...(options.config?.view() ?? {}),
|
|
405
434
|
...(options.config ? { filesystemIsolationStatus: options.config.filesystemIsolationStatus() } : {}),
|
|
435
|
+
...(options.dictation ? { dictationStatus: options.dictation.status() } : {}),
|
|
406
436
|
});
|
|
407
437
|
return;
|
|
408
438
|
}
|
|
409
439
|
if (request.method === "PUT" && url.pathname === "/api/config") {
|
|
410
|
-
await handleSettingsUpdate(request, response, options.config);
|
|
440
|
+
await handleSettingsUpdate(request, response, options.config, options.dictation);
|
|
411
441
|
options.workflowExecutions?.refresh();
|
|
412
442
|
return;
|
|
413
443
|
}
|
|
@@ -432,9 +462,10 @@ ${ICON_LINKS}</head><body><script>window.location.replace(${JSON.stringify(locat
|
|
|
432
462
|
*
|
|
433
463
|
* Its own endpoint rather than more of `/api/config`, and a query rather than state, for the
|
|
434
464
|
* reason `/api/directories` is (ADR 0011): the answer changes outside Flow — a `git
|
|
435
|
-
* branch` in a terminal, a `git fetch` — so
|
|
465
|
+
* branch` in a terminal, a `git fetch` — so the list of branches is not folded into the document
|
|
436
466
|
* every client polls, and a cache would need a filesystem watcher in order to be more often
|
|
437
|
-
* wrong.
|
|
467
|
+
* wrong. The Git State of an Agent Session's Scope is different: the Session Host holds it and
|
|
468
|
+
* reads it again at known points, and `SessionSummary.git` carries it (ADR 0043).
|
|
438
469
|
*
|
|
439
470
|
* Answers for a *Scope* rather than for an Agent Session, because the New Agent Session view
|
|
440
471
|
* has to ask before there is a session to ask about: picking the branch to cut a worktree from
|
|
@@ -535,6 +566,10 @@ ${ICON_LINKS}</head><body><script>window.location.replace(${JSON.stringify(locat
|
|
|
535
566
|
servePresentation(response, options.host, presentationMatch[1], url.searchParams, presentationMatch[2] !== undefined, authentication.kind === "browser" ? options.oidc : undefined, authentication.kind === "browser" ? authentication.sessionId : undefined);
|
|
536
567
|
return;
|
|
537
568
|
}
|
|
569
|
+
if (request.method === "GET" && url.pathname === "/api/attention/events") {
|
|
570
|
+
streamAttention(response, options.host, authentication.kind === "browser" ? options.oidc : undefined, authentication.kind === "browser" ? authentication.sessionId : undefined);
|
|
571
|
+
return;
|
|
572
|
+
}
|
|
538
573
|
const eventsMatch = /^\/api\/sessions\/([^/]+)\/events$/.exec(url.pathname);
|
|
539
574
|
const sessionId = eventsMatch?.[1];
|
|
540
575
|
if (request.method === "GET" && sessionId) {
|
|
@@ -555,6 +590,41 @@ ${ICON_LINKS}</head><body><script>window.location.replace(${JSON.stringify(locat
|
|
|
555
590
|
sendAttachment(response, options.store, attachmentMatch[1] ?? "", attachmentMatch[2] ?? "");
|
|
556
591
|
return;
|
|
557
592
|
}
|
|
593
|
+
if (request.method === "GET" && url.pathname === "/api/github-image") {
|
|
594
|
+
const image = await githubImage(url.searchParams.get("url") ?? "", () => gh(homedir(), ["auth", "token"])).catch(() => null);
|
|
595
|
+
if (!image?.body) {
|
|
596
|
+
send(response, 404, { error: "Image not found." });
|
|
597
|
+
return;
|
|
598
|
+
}
|
|
599
|
+
response.writeHead(200, {
|
|
600
|
+
"content-type": image.headers.get("content-type") ?? "",
|
|
601
|
+
"x-content-type-options": "nosniff",
|
|
602
|
+
"cache-control": "private, max-age=300",
|
|
603
|
+
});
|
|
604
|
+
Readable.fromWeb(image.body).pipe(response);
|
|
605
|
+
return;
|
|
606
|
+
}
|
|
607
|
+
if (request.method === "POST" && url.pathname === "/api/dictation") {
|
|
608
|
+
let audio;
|
|
609
|
+
try {
|
|
610
|
+
audio = await readBytes(request, MAX_DICTATION_BYTES);
|
|
611
|
+
}
|
|
612
|
+
catch {
|
|
613
|
+
send(response, 413, { error: "The recording is too long" });
|
|
614
|
+
return;
|
|
615
|
+
}
|
|
616
|
+
try {
|
|
617
|
+
if (!options.dictation)
|
|
618
|
+
throw new WhisperNotReady("Whisper dictation is not configured");
|
|
619
|
+
send(response, 200, { text: await options.dictation.transcribe(audio, request.headers["content-type"] ?? "application/octet-stream", url.searchParams.get("prompt") ?? "") });
|
|
620
|
+
}
|
|
621
|
+
catch (error) {
|
|
622
|
+
if (!(error instanceof WhisperNotReady))
|
|
623
|
+
throw error;
|
|
624
|
+
send(response, 409, { error: error.message });
|
|
625
|
+
}
|
|
626
|
+
return;
|
|
627
|
+
}
|
|
558
628
|
if (request.method === "POST" && url.pathname === "/api/command") {
|
|
559
629
|
const command = JSON.parse(await readBody(request));
|
|
560
630
|
try {
|
|
@@ -640,7 +710,7 @@ function projectLists(config) {
|
|
|
640
710
|
* Retention is not swept here. The next hourly sweep applies it, which is what the UI says, so
|
|
641
711
|
* saving a shorter window is never itself the thing that deletes a Presentation Transcript.
|
|
642
712
|
*/
|
|
643
|
-
async function handleSettingsUpdate(request, response, config) {
|
|
713
|
+
async function handleSettingsUpdate(request, response, config, dictation) {
|
|
644
714
|
if (!config) {
|
|
645
715
|
send(response, 404, { error: "This Session Host serves no Settings" });
|
|
646
716
|
return;
|
|
@@ -655,7 +725,13 @@ async function handleSettingsUpdate(request, response, config) {
|
|
|
655
725
|
}
|
|
656
726
|
try {
|
|
657
727
|
const settings = config.update(patch);
|
|
658
|
-
|
|
728
|
+
if (dictation && patch.dictation !== undefined)
|
|
729
|
+
void dictation.restart(config.dictation());
|
|
730
|
+
send(response, 200, {
|
|
731
|
+
...settings,
|
|
732
|
+
filesystemIsolationStatus: config.filesystemIsolationStatus(),
|
|
733
|
+
...(dictation ? { dictationStatus: dictation.status() } : {}),
|
|
734
|
+
});
|
|
659
735
|
}
|
|
660
736
|
catch (error) {
|
|
661
737
|
// A rejected value is the client's fault and its message names the field, so it is safe and
|
|
@@ -929,7 +1005,28 @@ function streamEvents(response, host, sessionId, since, oidc, browserSessionId)
|
|
|
929
1005
|
detachAuth?.();
|
|
930
1006
|
});
|
|
931
1007
|
}
|
|
932
|
-
|
|
1008
|
+
function streamAttention(response, host, oidc, browserSessionId) {
|
|
1009
|
+
response.writeHead(200, {
|
|
1010
|
+
"content-type": "text/event-stream",
|
|
1011
|
+
"cache-control": "no-store",
|
|
1012
|
+
connection: "keep-alive",
|
|
1013
|
+
});
|
|
1014
|
+
response.flushHeaders();
|
|
1015
|
+
const unsubscribe = host.onAttentionRaised((raised) => {
|
|
1016
|
+
response.write(`data: ${JSON.stringify(raised)}\n\n`);
|
|
1017
|
+
});
|
|
1018
|
+
const heartbeat = setInterval(() => response.write(": keepalive\n\n"), 15_000);
|
|
1019
|
+
heartbeat.unref();
|
|
1020
|
+
const detachAuth = oidc && browserSessionId
|
|
1021
|
+
? oidc.registerConnection(browserSessionId, () => response.end())
|
|
1022
|
+
: undefined;
|
|
1023
|
+
response.on("close", () => {
|
|
1024
|
+
clearInterval(heartbeat);
|
|
1025
|
+
unsubscribe();
|
|
1026
|
+
detachAuth?.();
|
|
1027
|
+
});
|
|
1028
|
+
}
|
|
1029
|
+
/** Bearer access is deliberately independent of OIDC so remote CLI clients keep working. */
|
|
933
1030
|
async function authenticateRequest(request, options) {
|
|
934
1031
|
if (tokenMatches(options.token, presentedBearer(request)))
|
|
935
1032
|
return { kind: "bearer" };
|
|
@@ -991,7 +1088,7 @@ a{display:inline-flex;align-items:center;justify-content:center;width:100%;heigh
|
|
|
991
1088
|
response.end(html);
|
|
992
1089
|
}
|
|
993
1090
|
/**
|
|
994
|
-
* Same-origin only. A request with no Origin header is a non-browser client (the
|
|
1091
|
+
* Same-origin only. A request with no Origin header is a non-browser client (the CLI, curl), which
|
|
995
1092
|
* a hostile page cannot forge on the user's behalf, so it is not what this check defends against.
|
|
996
1093
|
*/
|
|
997
1094
|
function originAllowed(request, publicAppUrl) {
|
package/dist/daemon/skills.js
CHANGED
|
@@ -83,6 +83,30 @@ export async function probeSkills(backend, scope, keep) {
|
|
|
83
83
|
await release(held, answered ? keep : undefined);
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
|
+
export async function probePlanLimits(backend, scope, keep) {
|
|
87
|
+
const { held, options } = probeSession(scope);
|
|
88
|
+
const started = backend.create(options);
|
|
89
|
+
const session = await within(started, PROBE_TIMEOUT_MS);
|
|
90
|
+
if (session === undefined) {
|
|
91
|
+
void started.then((late) => void late.dispose().catch(() => { }), () => { });
|
|
92
|
+
return [];
|
|
93
|
+
}
|
|
94
|
+
if (session instanceof Error)
|
|
95
|
+
return [];
|
|
96
|
+
held.session = session;
|
|
97
|
+
let answered = false;
|
|
98
|
+
try {
|
|
99
|
+
const limits = await session.planLimits?.() ?? [];
|
|
100
|
+
answered = true;
|
|
101
|
+
return limits;
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
return [];
|
|
105
|
+
}
|
|
106
|
+
finally {
|
|
107
|
+
await release(held, answered ? keep : undefined);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
86
110
|
function message(error) {
|
|
87
111
|
return error instanceof Error ? error.message : String(error);
|
|
88
112
|
}
|