akanjs 3.3.0 → 3.4.0-rc.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/common/PipelinePlanSchema.ts +31 -7
- package/common/index.ts +6 -0
- package/common/pipelinePlan.ts +31 -5
- package/index.ts +7 -5
- package/package.json +1 -1
- package/pipelineConfig.ts +25 -2
- package/service/agentLoop/agentLoop.ts +19 -12
- package/service/predefinedAdaptor/anthropicTools.ts +8 -2
- package/types/common/index.d.ts +1 -1
- package/types/common/pipelinePlan.d.ts +35 -6
- package/types/index.d.ts +7 -5
- package/types/pipelineConfig.d.ts +20 -3
- package/types/server/logging/rotatingLogWriter.d.ts +1 -1
- package/types/service/predefinedAdaptor/anthropicTools.d.ts +1 -0
- package/types/vendor/@akanjs/native/packages/cli/src/api-updates.d.ts +149 -0
- package/types/vendor/@akanjs/native/packages/cli/src/api.d.ts +16 -162
- package/types/vendor/@akanjs/native/packages/cli/src/config.d.ts +3 -2
- package/types/vendor/@akanjs/native/packages/cli/src/lib/api-task.d.ts +79 -0
- package/types/vendor/@akanjs/native/packages/cli/src/lib/prepare.d.ts +1 -1
- package/types/vendor/@akanjs/native/packages/cli/src/lib/publish.d.ts +17 -5
- package/types/vendor/@akanjs/native/packages/cli/src/lib/updates.d.ts +29 -2
- package/types/vendor/@akanjs/native/packages/cli/src/platforms/desktop-update.d.ts +36 -0
- package/types/vendor/@akanjs/native/packages/cli/src/platforms/linux-install.d.ts +15 -0
- package/types/vendor/@akanjs/native/packages/core/src/kernel.d.ts +16 -5
- package/types/vendor/@akanjs/native/packages/desktop/src/commands.d.ts +81 -0
- package/types/vendor/@akanjs/native/packages/desktop/src/deeplinks.d.ts +5 -1
- package/types/vendor/@akanjs/native/packages/desktop/src/dispatcher.d.ts +3 -0
- package/types/vendor/@akanjs/native/packages/desktop/src/lifecycle.d.ts +8 -1
- package/types/vendor/@akanjs/native/packages/desktop/src/plugin.d.ts +21 -0
- package/types/vendor/@akanjs/native/packages/desktop/src/server.d.ts +1 -0
- package/types/vendor/@akanjs/native/plugins/updates/src/desktop.d.ts +4 -4
- package/types/vendor/@akanjs/native/plugins/updates/src/reports.d.ts +49 -0
- package/types/vendor/@akanjs/native/plugins/updates/src/signer.d.ts +21 -0
- package/types/vendor/@akanjs/native/plugins/window/src/index.d.ts +55 -3
- package/vendor/@akanjs/native/native/desktop/src/lib.rs +209 -54
- package/vendor/@akanjs/native/packages/cli/src/api-updates.ts +332 -0
- package/vendor/@akanjs/native/packages/cli/src/api.ts +67 -419
- package/vendor/@akanjs/native/packages/cli/src/commands/build.ts +4 -1
- package/vendor/@akanjs/native/packages/cli/src/config.ts +3 -2
- package/vendor/@akanjs/native/packages/cli/src/lib/api-task.ts +223 -0
- package/vendor/@akanjs/native/packages/cli/src/lib/prepare.ts +2 -7
- package/vendor/@akanjs/native/packages/cli/src/lib/publish.ts +164 -19
- package/vendor/@akanjs/native/packages/cli/src/lib/updates.ts +90 -3
- package/vendor/@akanjs/native/packages/cli/src/platforms/desktop-update.ts +195 -43
- package/vendor/@akanjs/native/packages/cli/src/platforms/linux-appimage.ts +1 -1
- package/vendor/@akanjs/native/packages/cli/src/platforms/linux-install.ts +206 -0
- package/vendor/@akanjs/native/packages/cli/src/platforms/linux.ts +5 -1
- package/vendor/@akanjs/native/packages/core/src/kernel.ts +21 -6
- package/vendor/@akanjs/native/packages/core/vectors/updates.json +2 -1
- package/vendor/@akanjs/native/packages/desktop/src/commands.ts +380 -0
- package/vendor/@akanjs/native/packages/desktop/src/deeplinks.ts +20 -3
- package/vendor/@akanjs/native/packages/desktop/src/dispatcher.ts +28 -13
- package/vendor/@akanjs/native/packages/desktop/src/host.ts +6 -18
- package/vendor/@akanjs/native/packages/desktop/src/lifecycle.ts +8 -1
- package/vendor/@akanjs/native/packages/desktop/src/plugin.ts +21 -0
- package/vendor/@akanjs/native/packages/desktop/src/server.ts +1 -1
- package/vendor/@akanjs/native/plugins/updates/src/desktop.ts +90 -164
- package/vendor/@akanjs/native/plugins/updates/src/reports.ts +255 -0
- package/vendor/@akanjs/native/plugins/updates/src/signer.ts +133 -0
- package/vendor/@akanjs/native/plugins/window/native-plugin.json +6 -1
- package/vendor/@akanjs/native/plugins/window/src/desktop.ts +20 -4
- package/vendor/@akanjs/native/plugins/window/src/index.ts +55 -3
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
type PipelinePlan,
|
|
8
8
|
type PipelinePlanActionStep,
|
|
9
9
|
type PipelinePlanContext,
|
|
10
|
+
type PipelinePlanDesktopOtaStep,
|
|
10
11
|
type PipelinePlanOtaStep,
|
|
11
12
|
type PipelinePlanPhase,
|
|
12
13
|
type PipelinePlanPost,
|
|
@@ -18,6 +19,8 @@ import {
|
|
|
18
19
|
type PipelinePlanStep,
|
|
19
20
|
pipelineActionNames,
|
|
20
21
|
pipelineActions,
|
|
22
|
+
pipelineDesktopOtaArchs,
|
|
23
|
+
pipelineDesktopOtaSystems,
|
|
21
24
|
pipelineMilestones,
|
|
22
25
|
pipelineOtaPlatforms,
|
|
23
26
|
pipelinePlanLimits,
|
|
@@ -366,6 +369,8 @@ export class PipelinePlanSchema {
|
|
|
366
369
|
const actionVersion = pipelineActions[action].version;
|
|
367
370
|
if (action === "ota")
|
|
368
371
|
return { ...base, kind: "action", action, actionVersion, with: this.#otaWith(step.with, path) };
|
|
372
|
+
if (action === "desktop-ota")
|
|
373
|
+
return { ...base, kind: "action", action, actionVersion, with: this.#desktopOtaWith(step.with, path) };
|
|
369
374
|
const app = this.#read.object(step.with, `${path}.with`, ["app"]).app;
|
|
370
375
|
return {
|
|
371
376
|
...base,
|
|
@@ -382,16 +387,35 @@ export class PipelinePlanSchema {
|
|
|
382
387
|
const platforms = this.#read
|
|
383
388
|
.list(raw.platforms, `${path}.with.platforms`)
|
|
384
389
|
.map((platform, idx) => this.#read.oneOf(platform, `${path}.with.platforms[${idx}]`, pipelineOtaPlatforms));
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
["platforms", platforms],
|
|
388
|
-
] as const) {
|
|
389
|
-
if (!list.length) this.#fail(`${path}.with.${key}`, "may not be empty");
|
|
390
|
-
if (new Set(list).size !== list.length) this.#fail(`${path}.with.${key}`, "lists one twice");
|
|
391
|
-
}
|
|
390
|
+
this.#eachOnce(targets, `${path}.with.targets`);
|
|
391
|
+
this.#eachOnce(platforms, `${path}.with.platforms`);
|
|
392
392
|
return { app: this.#read.string(raw.app, `${path}.with.app`), targets, platforms };
|
|
393
393
|
}
|
|
394
394
|
|
|
395
|
+
#desktopOtaWith(value: unknown, path: string): PipelinePlanDesktopOtaStep["with"] {
|
|
396
|
+
const raw = this.#read.object(value, `${path}.with`, ["app", "targets", "platforms"]);
|
|
397
|
+
const targets = this.#stringList(raw.targets, `${path}.with.targets`);
|
|
398
|
+
const platforms = this.#read.list(raw.platforms, `${path}.with.platforms`).map((platform, idx) => {
|
|
399
|
+
const entryPath = `${path}.with.platforms[${idx}]`;
|
|
400
|
+
const entry = this.#read.object(platform, entryPath, ["os", "arch"]);
|
|
401
|
+
const os = this.#read.oneOf(entry.os, `${entryPath}.os`, pipelineDesktopOtaSystems);
|
|
402
|
+
const arch = this.#read.oneOf(entry.arch, `${entryPath}.arch`, pipelineDesktopOtaArchs);
|
|
403
|
+
if (os === "macos" && arch === "x64") this.#fail(entryPath, "a macOS app is built for arm64 only");
|
|
404
|
+
return { os, arch };
|
|
405
|
+
});
|
|
406
|
+
this.#eachOnce(targets, `${path}.with.targets`);
|
|
407
|
+
this.#eachOnce(
|
|
408
|
+
platforms.map(({ os, arch }) => `${os}-${arch}`),
|
|
409
|
+
`${path}.with.platforms`,
|
|
410
|
+
);
|
|
411
|
+
return { app: this.#read.string(raw.app, `${path}.with.app`), targets, platforms };
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
#eachOnce(items: readonly string[], path: string) {
|
|
415
|
+
if (!items.length) this.#fail(path, "may not be empty");
|
|
416
|
+
if (new Set(items).size !== items.length) this.#fail(path, "lists one twice");
|
|
417
|
+
}
|
|
418
|
+
|
|
395
419
|
#post(value: unknown, path: string): PipelinePlanPost {
|
|
396
420
|
const post = this.#read.object(value, path, ["success", "failure", "canceled", "always"]);
|
|
397
421
|
const steps = (result: keyof PipelinePlanPost) =>
|
package/common/index.ts
CHANGED
|
@@ -186,6 +186,9 @@ export { parseSearchParams } from "./parseSearchParams";
|
|
|
186
186
|
export { formatPhone, isPhoneNumber } from "./phone";
|
|
187
187
|
export {
|
|
188
188
|
type PipelineActionName,
|
|
189
|
+
type PipelineDesktopOtaArch,
|
|
190
|
+
type PipelineDesktopOtaPlatform,
|
|
191
|
+
type PipelineDesktopOtaSystem,
|
|
189
192
|
type PipelineDiagnostic,
|
|
190
193
|
type PipelineMilestone,
|
|
191
194
|
type PipelineOtaPlatform,
|
|
@@ -193,6 +196,7 @@ export {
|
|
|
193
196
|
type PipelinePlanActionStep,
|
|
194
197
|
type PipelinePlanAppActionStep,
|
|
195
198
|
type PipelinePlanContext,
|
|
199
|
+
type PipelinePlanDesktopOtaStep,
|
|
196
200
|
type PipelinePlanOtaStep,
|
|
197
201
|
type PipelinePlanPhase,
|
|
198
202
|
type PipelinePlanPost,
|
|
@@ -207,6 +211,8 @@ export {
|
|
|
207
211
|
type PipelineTrigger,
|
|
208
212
|
pipelineActionNames,
|
|
209
213
|
pipelineActions,
|
|
214
|
+
pipelineDesktopOtaArchs,
|
|
215
|
+
pipelineDesktopOtaSystems,
|
|
210
216
|
pipelineMilestones,
|
|
211
217
|
pipelineOtaPlatforms,
|
|
212
218
|
pipelinePlanLimits,
|
package/common/pipelinePlan.ts
CHANGED
|
@@ -20,24 +20,42 @@ export type PipelineTrigger = (typeof pipelineTriggers)[number];
|
|
|
20
20
|
* previous action in the run was skipped or did not succeed is skipped, never run. `deploy` is the only way any part
|
|
21
21
|
* of a plan reaches the master host, and its phase runs the apps one at a time. `ota` packs an over-the-air update of
|
|
22
22
|
* the app's native web bundle per target and platform (`akan pack-update`) for the executor to sign and publish; it
|
|
23
|
-
* makes its own CSR build, so it needs no `build` before it.
|
|
23
|
+
* makes its own CSR build, so it needs no `build` before it. `desktop-ota` is the same for a desktop app, which is
|
|
24
|
+
* replaced whole: per target and platform entry the executor runs, on a build host of that entry's OS,
|
|
25
|
+
* `akan pack-update <app> --platform desktop --arch <arch> --target <target>`, which writes an unsigned app archive and
|
|
26
|
+
* a manifest template for the executor to sign and publish. The runner holds no signing key.
|
|
24
27
|
*/
|
|
25
28
|
export const pipelineActions = {
|
|
26
29
|
build: { version: 1, milestone: "build", name: "Build" },
|
|
27
30
|
docker: { version: 1, milestone: "package", name: "Docker" },
|
|
28
31
|
deploy: { version: 1, milestone: "deploy", name: "Deploy" },
|
|
29
32
|
ota: { version: 1, milestone: "deploy", name: "OTA" },
|
|
33
|
+
"desktop-ota": { version: 1, milestone: "deploy", name: "Desktop OTA" },
|
|
30
34
|
} as const satisfies Record<string, { version: number; milestone: PipelineMilestone; name: string }>;
|
|
31
35
|
export type PipelineActionName = keyof typeof pipelineActions;
|
|
32
36
|
export const pipelineActionNames = /* @__PURE__ */ Object.keys(pipelineActions) as readonly PipelineActionName[];
|
|
33
37
|
|
|
34
|
-
/** The phones an `ota` action packs for; a desktop app
|
|
38
|
+
/** The phones an `ota` action packs for; a desktop app's update is the `desktop-ota` action's. */
|
|
35
39
|
export const pipelineOtaPlatforms = ["ios", "android"] as const;
|
|
36
40
|
export type PipelineOtaPlatform = (typeof pipelineOtaPlatforms)[number];
|
|
37
41
|
|
|
42
|
+
export const pipelineDesktopOtaSystems = ["macos", "windows", "linux"] as const;
|
|
43
|
+
export type PipelineDesktopOtaSystem = (typeof pipelineDesktopOtaSystems)[number];
|
|
44
|
+
export const pipelineDesktopOtaArchs = ["arm64", "x64"] as const;
|
|
45
|
+
export type PipelineDesktopOtaArch = (typeof pipelineDesktopOtaArchs)[number];
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* One desktop build a `desktop-ota` action packs for. A desktop app is packed only on its own OS, so `os` names the
|
|
49
|
+
* build host the executor needs and `arch` is the pack's `--arch`. A macOS app is arm64 only.
|
|
50
|
+
*/
|
|
51
|
+
export interface PipelineDesktopOtaPlatform {
|
|
52
|
+
os: PipelineDesktopOtaSystem;
|
|
53
|
+
arch: PipelineDesktopOtaArch;
|
|
54
|
+
}
|
|
55
|
+
|
|
38
56
|
/**
|
|
39
57
|
* Where a phase came from. Workspace `before`/`after` stages become a phase each; app stages fill the slots around the
|
|
40
|
-
*
|
|
58
|
+
* action phases, the k-th custom stage of every app in a slot sharing one phase (`after-build`, `after-build-2`…).
|
|
41
59
|
*/
|
|
42
60
|
export const pipelinePlanSlots = [
|
|
43
61
|
"before",
|
|
@@ -50,6 +68,8 @@ export const pipelinePlanSlots = [
|
|
|
50
68
|
"after-deploy",
|
|
51
69
|
"ota",
|
|
52
70
|
"after-ota",
|
|
71
|
+
"desktop-ota",
|
|
72
|
+
"after-desktop-ota",
|
|
53
73
|
"after",
|
|
54
74
|
] as const;
|
|
55
75
|
export type PipelinePlanSlot = (typeof pipelinePlanSlots)[number];
|
|
@@ -163,7 +183,7 @@ interface PipelinePlanActionStepBase extends PipelinePlanStepBase {
|
|
|
163
183
|
}
|
|
164
184
|
|
|
165
185
|
export interface PipelinePlanAppActionStep extends PipelinePlanActionStepBase {
|
|
166
|
-
action: Exclude<PipelineActionName, "ota">;
|
|
186
|
+
action: Exclude<PipelineActionName, "ota" | "desktop-ota">;
|
|
167
187
|
with: { app: string };
|
|
168
188
|
}
|
|
169
189
|
|
|
@@ -173,7 +193,13 @@ export interface PipelinePlanOtaStep extends PipelinePlanActionStepBase {
|
|
|
173
193
|
with: { app: string; targets: string[]; platforms: PipelineOtaPlatform[] };
|
|
174
194
|
}
|
|
175
195
|
|
|
176
|
-
|
|
196
|
+
/** One pack per target and platform entry, each on a build host of the entry's OS; the targets are as `ota`'s. */
|
|
197
|
+
export interface PipelinePlanDesktopOtaStep extends PipelinePlanActionStepBase {
|
|
198
|
+
action: "desktop-ota";
|
|
199
|
+
with: { app: string; targets: string[]; platforms: PipelineDesktopOtaPlatform[] };
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export type PipelinePlanActionStep = PipelinePlanAppActionStep | PipelinePlanOtaStep | PipelinePlanDesktopOtaStep;
|
|
177
203
|
|
|
178
204
|
export type PipelinePlanStep = PipelinePlanShellStep | PipelinePlanActionStep;
|
|
179
205
|
|
package/index.ts
CHANGED
|
@@ -157,7 +157,8 @@ export interface AkanNativeDeepLinks {
|
|
|
157
157
|
/**
|
|
158
158
|
* Where an installed app looks for newer releases of itself (the native runtime's updates plugin): the whole app on a
|
|
159
159
|
* desktop, the web bundle on a phone. `akan publish-update` writes and signs a release with a key on this machine;
|
|
160
|
-
* `akan pack-update` writes an unsigned phone bundle for whoever holds the
|
|
160
|
+
* `akan pack-update` writes an unsigned pack, a phone's web bundle or a desktop app's archive, for whoever holds the
|
|
161
|
+
* key to sign.
|
|
161
162
|
*/
|
|
162
163
|
export interface AkanNativeUpdatesConfig {
|
|
163
164
|
/**
|
|
@@ -167,8 +168,8 @@ export interface AkanNativeUpdatesConfig {
|
|
|
167
168
|
url: string;
|
|
168
169
|
/**
|
|
169
170
|
* The keys a binary trusts, raw 32-byte Ed25519 public keys in base64 (`akan update-keygen` prints one), 1 to 3:
|
|
170
|
-
* the online signing key first, offline spares after it, since a key may revoke only keys listed before it. A
|
|
171
|
-
* app built before protocol v2 trusts the first.
|
|
171
|
+
* the online signing key first, offline spares after it, since a key may revoke only keys listed before it. A phone
|
|
172
|
+
* and a desktop app trust all of them; only a desktop app built before protocol v2 (akanjs 3.1.1) trusts the first.
|
|
172
173
|
*/
|
|
173
174
|
publicKeys?: string[];
|
|
174
175
|
/** The one-key form of `publicKeys`, never beside it: a target overriding native.updates' keys keeps its form. */
|
|
@@ -187,8 +188,9 @@ export interface AkanNativeUpdatesConfig {
|
|
|
187
188
|
/** How long a newly applied release has to call notifyReady() before it is rolled back, ms. Default 10000. */
|
|
188
189
|
readyTimeout?: number;
|
|
189
190
|
/**
|
|
190
|
-
* Where
|
|
191
|
-
* launch or return to the foreground,
|
|
191
|
+
* Where an app posts what became of each release (downloaded, applied, confirmed, rolled back, failed), so rollback
|
|
192
|
+
* rates are visible: a phone at its next launch or return to the foreground, a desktop app at launch and with each
|
|
193
|
+
* check, with its CPU and the key that signed each release. Left out, nothing is sent.
|
|
192
194
|
*/
|
|
193
195
|
report?: { url: string };
|
|
194
196
|
/**
|
package/package.json
CHANGED
package/pipelineConfig.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
PipelineActionName,
|
|
3
|
+
PipelineDesktopOtaPlatform,
|
|
3
4
|
PipelineMilestone,
|
|
4
5
|
PipelineOtaPlatform,
|
|
5
6
|
PipelinePlanContext,
|
|
@@ -62,7 +63,7 @@ export interface PipelineShellStageInput extends PipelineStageBase {
|
|
|
62
63
|
|
|
63
64
|
/** No action parameters yet: rollout wait and prepull stay the executor's settings. */
|
|
64
65
|
export interface PipelineActionStageInput extends PipelineStageBase {
|
|
65
|
-
use: Exclude<PipelineActionName, "ota">;
|
|
66
|
+
use: Exclude<PipelineActionName, "ota" | "desktop-ota">;
|
|
66
67
|
name?: string;
|
|
67
68
|
retry?: number;
|
|
68
69
|
targets?: never;
|
|
@@ -91,7 +92,29 @@ export interface PipelineOtaStageInput extends PipelineStageBase {
|
|
|
91
92
|
matrix?: never;
|
|
92
93
|
}
|
|
93
94
|
|
|
94
|
-
|
|
95
|
+
/**
|
|
96
|
+
* A desktop app's update, packed whole per target and platform entry for the executor to sign and publish. Every target
|
|
97
|
+
* named must declare `native.updates`.
|
|
98
|
+
*/
|
|
99
|
+
export interface PipelineDesktopOtaStageInput extends PipelineStageBase {
|
|
100
|
+
use: "desktop-ota";
|
|
101
|
+
name?: string;
|
|
102
|
+
retry?: number;
|
|
103
|
+
/** Default: every native target that declares `native.updates`. */
|
|
104
|
+
targets?: readonly string[];
|
|
105
|
+
/** No default: each entry is packed on a build host of its own OS. A macOS app is arm64 only. */
|
|
106
|
+
platforms: readonly PipelineDesktopOtaPlatform[];
|
|
107
|
+
sh?: never;
|
|
108
|
+
steps?: never;
|
|
109
|
+
parallel?: never;
|
|
110
|
+
matrix?: never;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export type AppPipelineStageInput =
|
|
114
|
+
| PipelineActionStageInput
|
|
115
|
+
| PipelineOtaStageInput
|
|
116
|
+
| PipelineDesktopOtaStageInput
|
|
117
|
+
| PipelineShellStageInput;
|
|
95
118
|
|
|
96
119
|
export interface AppPipelineInput {
|
|
97
120
|
schemaVersion?: 1;
|
|
@@ -370,17 +370,18 @@ export class AgentLoop {
|
|
|
370
370
|
|
|
371
371
|
const verdicts: Verdict[] = [];
|
|
372
372
|
for (const call of calls) verdicts.push(await this.#verdictOf(call, byName.get(call.name)));
|
|
373
|
-
const
|
|
374
|
-
|
|
375
|
-
for (const call of deferred) yield { type: "awaiting", call };
|
|
376
|
-
return "awaiting";
|
|
377
|
-
}
|
|
373
|
+
const held: AgentWireToolCall[] = [];
|
|
374
|
+
let park: AgentLoopEvent | null = null;
|
|
378
375
|
const results: AgentWireToolResult[] = [];
|
|
379
376
|
let stop: AgentLoopStop | null = null;
|
|
380
377
|
try {
|
|
381
378
|
for (const [at, call] of calls.entries()) {
|
|
382
379
|
if (call.argsError) continue;
|
|
383
380
|
const verdict = verdicts[at] ?? { deny: AgentLoop.unjudged };
|
|
381
|
+
if (verdict === "defer") {
|
|
382
|
+
held.push(call);
|
|
383
|
+
continue;
|
|
384
|
+
}
|
|
384
385
|
const asked = this.#askUser.isMeta(call.name);
|
|
385
386
|
const meta = asked || this.#toolkits.isMeta(call.name);
|
|
386
387
|
stop = this.#haltStop() ?? (verdict === "allow" && !meta ? this.#callBudgetStop() : null);
|
|
@@ -388,22 +389,19 @@ export class AgentLoop {
|
|
|
388
389
|
const unasked = asked ? LoopAsk.refusalOf(call) : null;
|
|
389
390
|
|
|
390
391
|
if (asked && !unasked) {
|
|
391
|
-
|
|
392
|
-
stop = "awaiting";
|
|
392
|
+
park = { type: "awaiting", call, question: true };
|
|
393
393
|
break;
|
|
394
394
|
}
|
|
395
395
|
if (verdict === "allow" && this.#lent.has(call.name)) {
|
|
396
396
|
this.#toolCalls += 1;
|
|
397
|
-
|
|
398
|
-
stop = "awaiting";
|
|
397
|
+
park = { type: "awaiting", call, client: true };
|
|
399
398
|
break;
|
|
400
399
|
}
|
|
401
400
|
const kit = this.#toolkits.externalOf(call);
|
|
402
401
|
const opened = kit ? await this.#openRemote(call, kit) : null;
|
|
403
402
|
|
|
404
403
|
if (kit && !opened) {
|
|
405
|
-
|
|
406
|
-
stop = "awaiting";
|
|
404
|
+
park = { type: "awaiting", call, connect: kit };
|
|
407
405
|
break;
|
|
408
406
|
}
|
|
409
407
|
const whole =
|
|
@@ -424,7 +422,16 @@ export class AgentLoop {
|
|
|
424
422
|
|
|
425
423
|
await this.#record(results);
|
|
426
424
|
}
|
|
427
|
-
|
|
425
|
+
stop ??= this.#haltStop();
|
|
426
|
+
if (stop) return stop;
|
|
427
|
+
|
|
428
|
+
if (held.length) {
|
|
429
|
+
for (const call of held) yield { type: "awaiting", call };
|
|
430
|
+
return "awaiting";
|
|
431
|
+
}
|
|
432
|
+
if (!park) return null;
|
|
433
|
+
yield park;
|
|
434
|
+
return "awaiting";
|
|
428
435
|
}
|
|
429
436
|
|
|
430
437
|
async *#accept(answer: AgentLoopCallAnswer): Events<void> {
|
|
@@ -22,12 +22,18 @@ export class AnthropicTools {
|
|
|
22
22
|
return {
|
|
23
23
|
name: tool.name,
|
|
24
24
|
...(tool.description ? { description: tool.description } : {}),
|
|
25
|
-
|
|
26
|
-
input_schema: tool.parameters ?? { type: "object", properties: {} },
|
|
25
|
+
input_schema: AnthropicTools.#objectSchema(tool.parameters),
|
|
27
26
|
...(deferred ? { defer_loading: true as const } : {}),
|
|
28
27
|
};
|
|
29
28
|
}
|
|
30
29
|
|
|
30
|
+
static #objectSchema(parameters: Record<string, unknown> | undefined): Record<string, unknown> {
|
|
31
|
+
if (!parameters) return { type: "object", properties: {} };
|
|
32
|
+
if (parameters.type !== undefined) return parameters;
|
|
33
|
+
const { type: _untyped, ...schema } = parameters;
|
|
34
|
+
return { type: "object", properties: {}, ...schema };
|
|
35
|
+
}
|
|
36
|
+
|
|
31
37
|
static declared({ tools, deferred = [] }: Pick<LlmTurnRequest, "tools" | "deferred">): AgentWireTool[] {
|
|
32
38
|
const seen = new Set<string>();
|
|
33
39
|
return [...tools, ...deferred].filter((tool) => !seen.has(tool.name) && !!seen.add(tool.name));
|
package/types/common/index.d.ts
CHANGED
|
@@ -51,7 +51,7 @@ export { PipelinePlanSchema } from "./PipelinePlanSchema.d.ts";
|
|
|
51
51
|
export { type PipelineValueProblem, PipelineValueReader } from "./PipelineValueReader.d.ts";
|
|
52
52
|
export { parseSearchParams } from "./parseSearchParams.d.ts";
|
|
53
53
|
export { formatPhone, isPhoneNumber } from "./phone.d.ts";
|
|
54
|
-
export { type PipelineActionName, type PipelineDiagnostic, type PipelineMilestone, type PipelineOtaPlatform, type PipelinePlan, type PipelinePlanActionStep, type PipelinePlanAppActionStep, type PipelinePlanContext, type PipelinePlanOtaStep, type PipelinePlanPhase, type PipelinePlanPost, type PipelinePlanResult, type PipelinePlanRetry, type PipelinePlanShellStep, type PipelinePlanSlot, type PipelinePlanSource, type PipelinePlanStage, type PipelinePlanStep, type PipelineSkip, type PipelineTrigger, pipelineActionNames, pipelineActions, pipelineMilestones, pipelineOtaPlatforms, pipelinePlanLimits, pipelinePlanSlots, pipelinePlanVersion, pipelineReservedEnv, pipelineRuntimeEnv, pipelineTriggers, } from "./pipelinePlan.d.ts";
|
|
54
|
+
export { type PipelineActionName, type PipelineDesktopOtaArch, type PipelineDesktopOtaPlatform, type PipelineDesktopOtaSystem, type PipelineDiagnostic, type PipelineMilestone, type PipelineOtaPlatform, type PipelinePlan, type PipelinePlanActionStep, type PipelinePlanAppActionStep, type PipelinePlanContext, type PipelinePlanDesktopOtaStep, type PipelinePlanOtaStep, type PipelinePlanPhase, type PipelinePlanPost, type PipelinePlanResult, type PipelinePlanRetry, type PipelinePlanShellStep, type PipelinePlanSlot, type PipelinePlanSource, type PipelinePlanStage, type PipelinePlanStep, type PipelineSkip, type PipelineTrigger, pipelineActionNames, pipelineActions, pipelineDesktopOtaArchs, pipelineDesktopOtaSystems, pipelineMilestones, pipelineOtaPlatforms, pipelinePlanLimits, pipelinePlanSlots, pipelinePlanVersion, pipelineReservedEnv, pipelineRuntimeEnv, pipelineTriggers, } from "./pipelinePlan.d.ts";
|
|
55
55
|
export { type RouteLayer, RouteLayering } from "./RouteLayering.d.ts";
|
|
56
56
|
export { randomPick, randomPicks } from "./randomPick.d.ts";
|
|
57
57
|
export { RemoteAuthCode } from "./remoteAuthCode.d.ts";
|
|
@@ -15,7 +15,10 @@ export type PipelineTrigger = (typeof pipelineTriggers)[number];
|
|
|
15
15
|
* previous action in the run was skipped or did not succeed is skipped, never run. `deploy` is the only way any part
|
|
16
16
|
* of a plan reaches the master host, and its phase runs the apps one at a time. `ota` packs an over-the-air update of
|
|
17
17
|
* the app's native web bundle per target and platform (`akan pack-update`) for the executor to sign and publish; it
|
|
18
|
-
* makes its own CSR build, so it needs no `build` before it.
|
|
18
|
+
* makes its own CSR build, so it needs no `build` before it. `desktop-ota` is the same for a desktop app, which is
|
|
19
|
+
* replaced whole: per target and platform entry the executor runs, on a build host of that entry's OS,
|
|
20
|
+
* `akan pack-update <app> --platform desktop --arch <arch> --target <target>`, which writes an unsigned app archive and
|
|
21
|
+
* a manifest template for the executor to sign and publish. The runner holds no signing key.
|
|
19
22
|
*/
|
|
20
23
|
export declare const pipelineActions: {
|
|
21
24
|
readonly build: {
|
|
@@ -38,17 +41,34 @@ export declare const pipelineActions: {
|
|
|
38
41
|
readonly milestone: "deploy";
|
|
39
42
|
readonly name: "OTA";
|
|
40
43
|
};
|
|
44
|
+
readonly "desktop-ota": {
|
|
45
|
+
readonly version: 1;
|
|
46
|
+
readonly milestone: "deploy";
|
|
47
|
+
readonly name: "Desktop OTA";
|
|
48
|
+
};
|
|
41
49
|
};
|
|
42
50
|
export type PipelineActionName = keyof typeof pipelineActions;
|
|
43
51
|
export declare const pipelineActionNames: readonly PipelineActionName[];
|
|
44
|
-
/** The phones an `ota` action packs for; a desktop app
|
|
52
|
+
/** The phones an `ota` action packs for; a desktop app's update is the `desktop-ota` action's. */
|
|
45
53
|
export declare const pipelineOtaPlatforms: readonly ["ios", "android"];
|
|
46
54
|
export type PipelineOtaPlatform = (typeof pipelineOtaPlatforms)[number];
|
|
55
|
+
export declare const pipelineDesktopOtaSystems: readonly ["macos", "windows", "linux"];
|
|
56
|
+
export type PipelineDesktopOtaSystem = (typeof pipelineDesktopOtaSystems)[number];
|
|
57
|
+
export declare const pipelineDesktopOtaArchs: readonly ["arm64", "x64"];
|
|
58
|
+
export type PipelineDesktopOtaArch = (typeof pipelineDesktopOtaArchs)[number];
|
|
59
|
+
/**
|
|
60
|
+
* One desktop build a `desktop-ota` action packs for. A desktop app is packed only on its own OS, so `os` names the
|
|
61
|
+
* build host the executor needs and `arch` is the pack's `--arch`. A macOS app is arm64 only.
|
|
62
|
+
*/
|
|
63
|
+
export interface PipelineDesktopOtaPlatform {
|
|
64
|
+
os: PipelineDesktopOtaSystem;
|
|
65
|
+
arch: PipelineDesktopOtaArch;
|
|
66
|
+
}
|
|
47
67
|
/**
|
|
48
68
|
* Where a phase came from. Workspace `before`/`after` stages become a phase each; app stages fill the slots around the
|
|
49
|
-
*
|
|
69
|
+
* action phases, the k-th custom stage of every app in a slot sharing one phase (`after-build`, `after-build-2`…).
|
|
50
70
|
*/
|
|
51
|
-
export declare const pipelinePlanSlots: readonly ["before", "before-build", "build", "after-build", "docker", "after-docker", "deploy", "after-deploy", "ota", "after-ota", "after"];
|
|
71
|
+
export declare const pipelinePlanSlots: readonly ["before", "before-build", "build", "after-build", "docker", "after-docker", "deploy", "after-deploy", "ota", "after-ota", "desktop-ota", "after-desktop-ota", "after"];
|
|
52
72
|
export type PipelinePlanSlot = (typeof pipelinePlanSlots)[number];
|
|
53
73
|
/**
|
|
54
74
|
* Set by the executor on every `sh` step (AKAN_CI_APP from the stage's `app`), never by a plan. AKAN_CI_RESULT's
|
|
@@ -123,7 +143,7 @@ interface PipelinePlanActionStepBase extends PipelinePlanStepBase {
|
|
|
123
143
|
actionVersion: 1;
|
|
124
144
|
}
|
|
125
145
|
export interface PipelinePlanAppActionStep extends PipelinePlanActionStepBase {
|
|
126
|
-
action: Exclude<PipelineActionName, "ota">;
|
|
146
|
+
action: Exclude<PipelineActionName, "ota" | "desktop-ota">;
|
|
127
147
|
with: {
|
|
128
148
|
app: string;
|
|
129
149
|
};
|
|
@@ -137,7 +157,16 @@ export interface PipelinePlanOtaStep extends PipelinePlanActionStepBase {
|
|
|
137
157
|
platforms: PipelineOtaPlatform[];
|
|
138
158
|
};
|
|
139
159
|
}
|
|
140
|
-
|
|
160
|
+
/** One pack per target and platform entry, each on a build host of the entry's OS; the targets are as `ota`'s. */
|
|
161
|
+
export interface PipelinePlanDesktopOtaStep extends PipelinePlanActionStepBase {
|
|
162
|
+
action: "desktop-ota";
|
|
163
|
+
with: {
|
|
164
|
+
app: string;
|
|
165
|
+
targets: string[];
|
|
166
|
+
platforms: PipelineDesktopOtaPlatform[];
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
export type PipelinePlanActionStep = PipelinePlanAppActionStep | PipelinePlanOtaStep | PipelinePlanDesktopOtaStep;
|
|
141
170
|
export type PipelinePlanStep = PipelinePlanShellStep | PipelinePlanActionStep;
|
|
142
171
|
/**
|
|
143
172
|
* Stages of one phase run concurrently unless the phase is sequential; a stage's steps run in order. Whether a stage
|
package/types/index.d.ts
CHANGED
|
@@ -145,7 +145,8 @@ export interface AkanNativeDeepLinks {
|
|
|
145
145
|
/**
|
|
146
146
|
* Where an installed app looks for newer releases of itself (the native runtime's updates plugin): the whole app on a
|
|
147
147
|
* desktop, the web bundle on a phone. `akan publish-update` writes and signs a release with a key on this machine;
|
|
148
|
-
* `akan pack-update` writes an unsigned phone bundle for whoever holds the
|
|
148
|
+
* `akan pack-update` writes an unsigned pack, a phone's web bundle or a desktop app's archive, for whoever holds the
|
|
149
|
+
* key to sign.
|
|
149
150
|
*/
|
|
150
151
|
export interface AkanNativeUpdatesConfig {
|
|
151
152
|
/**
|
|
@@ -155,8 +156,8 @@ export interface AkanNativeUpdatesConfig {
|
|
|
155
156
|
url: string;
|
|
156
157
|
/**
|
|
157
158
|
* The keys a binary trusts, raw 32-byte Ed25519 public keys in base64 (`akan update-keygen` prints one), 1 to 3:
|
|
158
|
-
* the online signing key first, offline spares after it, since a key may revoke only keys listed before it. A
|
|
159
|
-
* app built before protocol v2 trusts the first.
|
|
159
|
+
* the online signing key first, offline spares after it, since a key may revoke only keys listed before it. A phone
|
|
160
|
+
* and a desktop app trust all of them; only a desktop app built before protocol v2 (akanjs 3.1.1) trusts the first.
|
|
160
161
|
*/
|
|
161
162
|
publicKeys?: string[];
|
|
162
163
|
/** The one-key form of `publicKeys`, never beside it: a target overriding native.updates' keys keeps its form. */
|
|
@@ -175,8 +176,9 @@ export interface AkanNativeUpdatesConfig {
|
|
|
175
176
|
/** How long a newly applied release has to call notifyReady() before it is rolled back, ms. Default 10000. */
|
|
176
177
|
readyTimeout?: number;
|
|
177
178
|
/**
|
|
178
|
-
* Where
|
|
179
|
-
* launch or return to the foreground,
|
|
179
|
+
* Where an app posts what became of each release (downloaded, applied, confirmed, rolled back, failed), so rollback
|
|
180
|
+
* rates are visible: a phone at its next launch or return to the foreground, a desktop app at launch and with each
|
|
181
|
+
* check, with its CPU and the key that signed each release. Left out, nothing is sent.
|
|
180
182
|
*/
|
|
181
183
|
report?: {
|
|
182
184
|
url: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PipelineActionName, PipelineMilestone, PipelineOtaPlatform, PipelinePlanContext, PipelineTrigger } from "akanjs/common";
|
|
1
|
+
import type { PipelineActionName, PipelineDesktopOtaPlatform, PipelineMilestone, PipelineOtaPlatform, PipelinePlanContext, PipelineTrigger } from "akanjs/common";
|
|
2
2
|
export type PipelineDuration = number | `${number}s` | `${number}m` | `${number}h`;
|
|
3
3
|
/** In the `PipelinePattern` dialect of `akanjs/common`; a leading `!` excludes. */
|
|
4
4
|
export type PipelineGlob = string | readonly string[];
|
|
@@ -51,7 +51,7 @@ export interface PipelineShellStageInput extends PipelineStageBase {
|
|
|
51
51
|
}
|
|
52
52
|
/** No action parameters yet: rollout wait and prepull stay the executor's settings. */
|
|
53
53
|
export interface PipelineActionStageInput extends PipelineStageBase {
|
|
54
|
-
use: Exclude<PipelineActionName, "ota">;
|
|
54
|
+
use: Exclude<PipelineActionName, "ota" | "desktop-ota">;
|
|
55
55
|
name?: string;
|
|
56
56
|
retry?: number;
|
|
57
57
|
targets?: never;
|
|
@@ -78,7 +78,24 @@ export interface PipelineOtaStageInput extends PipelineStageBase {
|
|
|
78
78
|
parallel?: never;
|
|
79
79
|
matrix?: never;
|
|
80
80
|
}
|
|
81
|
-
|
|
81
|
+
/**
|
|
82
|
+
* A desktop app's update, packed whole per target and platform entry for the executor to sign and publish. Every target
|
|
83
|
+
* named must declare `native.updates`.
|
|
84
|
+
*/
|
|
85
|
+
export interface PipelineDesktopOtaStageInput extends PipelineStageBase {
|
|
86
|
+
use: "desktop-ota";
|
|
87
|
+
name?: string;
|
|
88
|
+
retry?: number;
|
|
89
|
+
/** Default: every native target that declares `native.updates`. */
|
|
90
|
+
targets?: readonly string[];
|
|
91
|
+
/** No default: each entry is packed on a build host of its own OS. A macOS app is arm64 only. */
|
|
92
|
+
platforms: readonly PipelineDesktopOtaPlatform[];
|
|
93
|
+
sh?: never;
|
|
94
|
+
steps?: never;
|
|
95
|
+
parallel?: never;
|
|
96
|
+
matrix?: never;
|
|
97
|
+
}
|
|
98
|
+
export type AppPipelineStageInput = PipelineActionStageInput | PipelineOtaStageInput | PipelineDesktopOtaStageInput | PipelineShellStageInput;
|
|
82
99
|
export interface AppPipelineInput {
|
|
83
100
|
schemaVersion?: 1;
|
|
84
101
|
/** This app's stages in order, the actions it takes included. */
|
|
@@ -19,5 +19,5 @@ export declare class RotatingLogWriter {
|
|
|
19
19
|
static sanitizeFilePart(value: string): string;
|
|
20
20
|
write(processKey: string, chunk: string): void;
|
|
21
21
|
close(): Promise<void>;
|
|
22
|
-
static fileMode(value?: string | undefined, warn?: typeof RotatingLogWriter.__#
|
|
22
|
+
static fileMode(value?: string | undefined, warn?: typeof RotatingLogWriter.__#181@#defaultWarn): number;
|
|
23
23
|
}
|
|
@@ -17,6 +17,7 @@ export interface AnthropicTool {
|
|
|
17
17
|
defer_loading?: true;
|
|
18
18
|
}
|
|
19
19
|
export declare class AnthropicTools {
|
|
20
|
+
#private;
|
|
20
21
|
static readonly beta = "mid-conversation-tool-changes-2026-07-01";
|
|
21
22
|
static definition(tool: AgentWireTool, deferred?: boolean): AnthropicTool;
|
|
22
23
|
static declared({ tools, deferred }: Pick<LlmTurnRequest, "tools" | "deferred">): AgentWireTool[];
|