@halonicjs/testing 0.1.0 → 0.1.2
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/NOTICE +4 -0
- package/README.md +1 -1
- package/dist/adapters/http-kit/src/address-checking.d.ts +19 -0
- package/dist/adapters/http-kit/src/address-checking.js +1 -0
- package/dist/adapters/http-kit/src/connector-host-class.d.ts +14 -0
- package/dist/adapters/http-kit/src/connector-host-class.js +34 -0
- package/dist/adapters/http-kit/src/index.d.ts +3 -0
- package/dist/adapters/http-kit/src/index.js +2 -0
- package/dist/adapters/http-kit/src/ollama-tags.d.ts +20 -0
- package/dist/adapters/http-kit/src/ollama-tags.js +38 -0
- package/dist/adapters/integration-kit/src/auth-placement.d.ts +40 -0
- package/dist/adapters/integration-kit/src/auth-placement.js +102 -0
- package/dist/adapters/integration-kit/src/current-secret-forms.d.ts +28 -0
- package/dist/adapters/integration-kit/src/current-secret-forms.js +60 -0
- package/dist/adapters/integration-kit/src/declaration.d.ts +2 -1
- package/dist/adapters/integration-kit/src/declaration.js +4 -3
- package/dist/adapters/integration-kit/src/host.d.ts +7 -1
- package/dist/adapters/integration-kit/src/host.js +1 -0
- package/dist/adapters/integration-kit/src/index.d.ts +5 -2
- package/dist/adapters/integration-kit/src/index.js +2 -0
- package/dist/adapters/integration-kit/src/leak-attempt.d.ts +4 -2
- package/dist/adapters/integration-kit/src/leak-attempt.js +5 -2
- package/dist/adapters/integration-kit/src/limited-http.d.ts +7 -1
- package/dist/adapters/integration-kit/src/limited-http.js +53 -10
- package/dist/adapters/integration-kit/src/loader.d.ts +28 -11
- package/dist/adapters/integration-kit/src/loader.js +36 -21
- package/dist/adapters/integration-kit/src/own-request.d.ts +2 -2
- package/dist/adapters/integration-kit/src/own-request.js +1 -1
- package/dist/adapters/integration-kit/src/plugin-load.d.ts +3 -3
- package/dist/adapters/integration-kit/src/plugin-load.js +5 -5
- package/dist/adapters/integration-kit/src/policy.d.ts +28 -0
- package/dist/adapters/integration-kit/src/response-body.d.ts +6 -2
- package/dist/adapters/integration-kit/src/secret-filter.d.ts +3 -3
- package/dist/adapters/integration-kit/src/secret-filter.js +19 -4
- package/dist/adapters/integration-kit/src/secret-in-request.d.ts +3 -0
- package/dist/adapters/integration-kit/src/secret-in-request.js +8 -2
- package/dist/adapters/integration-kit/src/secret-placement.d.ts +35 -25
- package/dist/adapters/integration-kit/src/secret-placement.js +65 -95
- package/dist/adapters/integration-kit/src/sign-in-placement.d.ts +29 -0
- package/dist/adapters/integration-kit/src/sign-in-placement.js +92 -0
- package/dist/adapters/integration-kit/src/workspace-choices.d.ts +37 -0
- package/dist/adapters/integration-kit/src/workspace-choices.js +37 -0
- package/dist/core/events/src/blocked-sites.d.ts +57 -0
- package/dist/core/events/src/blocked-sites.js +89 -0
- package/dist/core/events/src/connector-listing-failed.d.ts +18 -0
- package/dist/core/events/src/connector-listing-failed.js +1 -0
- package/dist/core/events/src/home-path.d.ts +4 -1
- package/dist/core/events/src/home-path.js +14 -3
- package/dist/core/events/src/index.d.ts +8 -2
- package/dist/core/events/src/index.js +5 -0
- package/dist/core/events/src/provider-notes.d.ts +16 -0
- package/dist/core/events/src/provider-notes.js +24 -0
- package/dist/core/events/src/run-basics.d.ts +131 -10
- package/dist/core/events/src/run-event.d.ts +120 -11
- package/dist/core/events/src/run-reads.d.ts +25 -0
- package/dist/core/events/src/run-reads.js +44 -0
- package/dist/core/events/src/run-sends.d.ts +47 -0
- package/dist/core/events/src/run-sends.js +68 -0
- package/dist/core/events/src/run-summary.d.ts +11 -1
- package/dist/core/events/src/sandbox-opened-read.d.ts +2 -1
- package/dist/core/events/src/sandbox-opened-read.js +27 -2
- package/dist/core/events/src/sandbox-opened.d.ts +37 -4
- package/dist/core/events/src/sandbox-opened.js +13 -3
- package/dist/core/events/src/summarize.js +8 -1
- package/dist/core/events/src/timeline-entry.js +1 -0
- package/dist/core/events/src/tool-failure-cause.d.ts +25 -0
- package/dist/core/events/src/tool-failure-cause.js +66 -0
- package/dist/core/format/src/index.d.ts +9 -6
- package/dist/core/format/src/index.js +7 -3
- package/dist/core/format/src/integration/index.d.ts +3 -2
- package/dist/core/format/src/integration/index.js +2 -1
- package/dist/core/format/src/kinds/agent/harness-limits.d.ts +14 -0
- package/dist/core/format/src/kinds/agent/harness-limits.js +27 -0
- package/dist/core/format/src/kinds/agent/sandbox-fields.d.ts +15 -5
- package/dist/core/format/src/kinds/agent/sandbox-fields.js +29 -10
- package/dist/core/format/src/kinds/agent/schema.d.ts +5 -0
- package/dist/core/format/src/kinds/agent/schema.js +5 -2
- package/dist/core/format/src/kinds/connector/is-local.js +1 -1
- package/dist/core/format/src/kinds/connector/kind.js +122 -2
- package/dist/core/format/src/kinds/connector/schema.d.ts +38 -0
- package/dist/core/format/src/kinds/connector/schema.js +71 -2
- package/dist/core/format/src/kinds/deployments/kind.js +25 -1
- package/dist/core/format/src/kinds/deployments/schema.d.ts +40 -0
- package/dist/core/format/src/kinds/deployments/schema.js +52 -0
- package/dist/core/format/src/kinds/integration/approved-sign-ins.d.ts +62 -0
- package/dist/core/format/src/kinds/integration/approved-sign-ins.js +125 -0
- package/dist/core/format/src/kinds/integration/host-key.d.ts +7 -0
- package/dist/core/format/src/kinds/integration/host-key.js +8 -0
- package/dist/core/format/src/kinds/integration/kind.d.ts +4 -2
- package/dist/core/format/src/kinds/integration/kind.js +49 -12
- package/dist/core/format/src/kinds/integration/policy.d.ts +47 -2
- package/dist/core/format/src/kinds/integration/policy.js +61 -2
- package/dist/core/format/src/kinds/integration/schema.d.ts +180 -3
- package/dist/core/format/src/kinds/integration/schema.js +133 -7
- package/dist/core/format/src/kinds/integration/sign-in-checks.d.ts +14 -0
- package/dist/core/format/src/kinds/integration/sign-in-checks.js +150 -0
- package/dist/core/format/src/kinds/integration/sign-in-urls.d.ts +19 -0
- package/dist/core/format/src/kinds/integration/sign-in-urls.js +47 -0
- package/dist/core/format/src/kinds/plugin/checks.d.ts +3 -2
- package/dist/core/format/src/kinds/plugin/checks.js +24 -6
- package/dist/core/format/src/kinds/plugin/schema.d.ts +130 -0
- package/dist/core/format/src/kinds/plugin/schema.js +26 -6
- package/dist/core/format/src/kinds/plugin/ui-checks.d.ts +1 -1
- package/dist/core/format/src/kinds/plugin/ui-checks.js +1 -10
- package/dist/core/format/src/kinds/provider/kind.js +40 -1
- package/dist/core/format/src/kinds/provider/types.d.ts +19 -0
- package/dist/core/format/src/kinds/provider/types.js +22 -0
- package/dist/core/format/src/kinds/routine/kind.js +38 -1
- package/dist/core/format/src/kinds/routine/schema.d.ts +20 -5
- package/dist/core/format/src/kinds/routine/schema.js +42 -14
- package/dist/core/format/src/kinds/routine/webhook-headers.d.ts +9 -0
- package/dist/core/format/src/kinds/routine/webhook-headers.js +26 -0
- package/dist/core/format/src/kinds/workflow/schema.js +1 -1
- package/dist/core/format/src/kinds/workspace/kind.js +1 -1
- package/dist/core/format/src/kinds/workspace/schema.d.ts +2 -2
- package/dist/core/format/src/kinds/workspace/schema.js +6 -5
- package/dist/core/format/src/parse-file.js +3 -1
- package/dist/core/format/src/shared/fields.d.ts +12 -8
- package/dist/core/format/src/shared/fields.js +48 -19
- package/dist/core/format/src/shared/guard.d.ts +8 -0
- package/dist/core/format/src/shared/guard.js +50 -1
- package/dist/core/format/src/shared/missing-keys.d.ts +17 -0
- package/dist/core/format/src/shared/missing-keys.js +110 -0
- package/dist/core/ports/src/agent-runs-not-available.d.ts +21 -0
- package/dist/core/ports/src/agent-runs-not-available.js +25 -0
- package/dist/core/ports/src/blob-store.d.ts +12 -0
- package/dist/core/ports/src/blob-store.js +22 -0
- package/dist/core/ports/src/chat.d.ts +8 -0
- package/dist/core/ports/src/connector-client.d.ts +48 -4
- package/dist/core/ports/src/connector-client.js +17 -0
- package/dist/core/ports/src/connector-start-failure.d.ts +31 -0
- package/dist/core/ports/src/connector-start-failure.js +32 -0
- package/dist/core/ports/src/connector-tool-error.d.ts +33 -0
- package/dist/core/ports/src/connector-tool-error.js +40 -0
- package/dist/core/ports/src/definition-store-left-out.d.ts +46 -0
- package/dist/core/ports/src/definition-store-left-out.js +47 -0
- package/dist/core/ports/src/definition-store.d.ts +36 -5
- package/dist/core/ports/src/definition-store.js +1 -1
- package/dist/core/ports/src/deploy-target.d.ts +358 -0
- package/dist/core/ports/src/deploy-target.js +2 -0
- package/dist/core/ports/src/harness-bridge-server.d.ts +67 -7
- package/dist/core/ports/src/harness-sign-in-command.d.ts +27 -0
- package/dist/core/ports/src/harness-sign-in-command.js +31 -0
- package/dist/core/ports/src/harness.d.ts +79 -15
- package/dist/core/ports/src/harness.js +1 -1
- package/dist/core/ports/src/host-settings-store.d.ts +116 -0
- package/dist/core/ports/src/host-settings-store.js +106 -0
- package/dist/core/ports/src/host-too-old.d.ts +23 -0
- package/dist/core/ports/src/host-too-old.js +27 -0
- package/dist/core/ports/src/index.d.ts +32 -13
- package/dist/core/ports/src/index.js +28 -8
- package/dist/core/ports/src/instruction-trust-store.d.ts +81 -0
- package/dist/core/ports/src/instruction-trust-store.js +43 -0
- package/dist/core/ports/src/integration.d.ts +71 -7
- package/dist/core/ports/src/integration.js +22 -4
- package/dist/core/ports/src/llm-provider.d.ts +39 -6
- package/dist/core/ports/src/llm-provider.js +46 -3
- package/dist/core/ports/src/pairing-codes.d.ts +111 -0
- package/dist/core/ports/src/pairing-codes.js +336 -0
- package/dist/core/ports/src/pairing-qr-bytes.d.ts +32 -0
- package/dist/core/ports/src/pairing-qr-bytes.js +116 -0
- package/dist/core/ports/src/password-hasher.d.ts +36 -20
- package/dist/core/ports/src/port-versions.d.ts +13 -6
- package/dist/core/ports/src/port-versions.js +14 -0
- package/dist/core/ports/src/program-probe.d.ts +25 -2
- package/dist/core/ports/src/program-probe.js +1 -1
- package/dist/core/ports/src/provider-default-base-url.d.ts +10 -0
- package/dist/core/ports/src/provider-default-base-url.js +18 -0
- package/dist/core/ports/src/record-store.d.ts +17 -0
- package/dist/core/ports/src/record-store.js +70 -0
- package/dist/core/ports/src/remote-control.d.ts +159 -0
- package/dist/core/ports/src/remote-control.js +26 -0
- package/dist/core/ports/src/remote-gateway-protocol.d.ts +220 -0
- package/dist/core/ports/src/remote-gateway-protocol.js +62 -0
- package/dist/core/ports/src/remote-gateway-session.d.ts +194 -0
- package/dist/core/ports/src/remote-gateway-session.js +241 -0
- package/dist/core/ports/src/run-executor.d.ts +44 -7
- package/dist/core/ports/src/run-executor.js +1 -1
- package/dist/core/ports/src/run-target-not-found.d.ts +34 -0
- package/dist/core/ports/src/run-target-not-found.js +41 -0
- package/dist/core/ports/src/sandbox-setting-store.d.ts +68 -0
- package/dist/core/ports/src/sandbox-setting-store.js +33 -0
- package/dist/core/ports/src/sandbox.d.ts +149 -13
- package/dist/core/ports/src/sandbox.js +52 -2
- package/dist/core/ports/src/secrets.d.ts +105 -1
- package/dist/core/ports/src/secrets.js +75 -2
- package/dist/core/ports/src/tool-approval-store.d.ts +50 -8
- package/dist/core/ports/src/tool-approval-store.js +59 -0
- package/dist/core/ports/src/tunnel-provider.d.ts +117 -0
- package/dist/core/ports/src/tunnel-provider.js +65 -0
- package/dist/core/ports/src/tunnel-resolver.d.ts +83 -0
- package/dist/core/ports/src/tunnel-resolver.js +36 -0
- package/dist/core/ports/src/vcs-status.d.ts +8 -0
- package/dist/core/ports/src/vcs-status.js +90 -0
- package/dist/core/ports/src/vcs.d.ts +30 -0
- package/dist/core/schema-kit/src/builders.d.ts +5 -0
- package/dist/core/schema-kit/src/builders.js +5 -0
- package/dist/core/std/src/amount.d.ts +13 -0
- package/dist/core/std/src/amount.js +22 -0
- package/dist/core/std/src/hidden-characters.d.ts +28 -0
- package/dist/core/std/src/hidden-characters.js +72 -0
- package/dist/core/std/src/index.d.ts +7 -0
- package/dist/core/std/src/index.js +7 -0
- package/dist/core/std/src/path-overlap.d.ts +22 -0
- package/dist/core/std/src/path-overlap.js +57 -0
- package/dist/core/std/src/public-suffixes.generated.d.ts +9 -0
- package/dist/core/std/src/public-suffixes.generated.js +10428 -0
- package/dist/core/std/src/registrable-domain.d.ts +10 -0
- package/dist/core/std/src/registrable-domain.js +62 -0
- package/dist/core/std/src/secret-variable-name.d.ts +12 -0
- package/dist/core/std/src/secret-variable-name.js +34 -0
- package/dist/core/std/src/site-name.d.ts +35 -0
- package/dist/core/std/src/site-name.js +111 -0
- package/dist/core/std/src/url-host.d.ts +35 -0
- package/dist/core/std/src/url-host.js +170 -0
- package/dist/core/std/src/word-diff.d.ts +28 -0
- package/dist/core/std/src/word-diff.js +77 -0
- package/dist/core/yaml/src/edit-data.d.ts +7 -0
- package/dist/core/yaml/src/edit-data.js +62 -3
- package/dist/core/yaml/src/edit.d.ts +7 -0
- package/dist/core/yaml/src/edit.js +34 -3
- package/dist/core/yaml/src/splice-node.d.ts +6 -0
- package/dist/core/yaml/src/splice-node.js +10 -0
- package/dist/core/yaml/src/splice.js +20 -10
- package/dist/testing/integration/src/checks.d.ts +5 -3
- package/dist/testing/integration/src/checks.js +31 -3
- package/dist/testing/integration/src/load.js +3 -1
- package/package.json +9 -2
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
import type { RunFailureKind } from "../../events/src/index.js";
|
|
2
|
+
import type { DefinitionSource } from "./definition-store.js";
|
|
3
|
+
import type { HttpClient } from "./http-client.js";
|
|
4
|
+
import type { TokenStore } from "./token-store.js";
|
|
5
|
+
/** Version of the {@link DeployTarget} port. A breaking change bumps it and comes with an ADR. */
|
|
6
|
+
export declare const deployTargetVersion = 1;
|
|
7
|
+
/** One deployment from `deployments.yaml`, with where it lives on its host. */
|
|
8
|
+
export interface DeploymentRef {
|
|
9
|
+
/** The deployment's name in `deployments.yaml`, such as "web". */
|
|
10
|
+
readonly name: string;
|
|
11
|
+
/** The account on the host, by its id. The account is always shown before anything changes. */
|
|
12
|
+
readonly accountId: string;
|
|
13
|
+
/** The service the deployment runs as on the host, such as the Worker "acme". */
|
|
14
|
+
readonly service: string;
|
|
15
|
+
/** A production deploy refuses uncommitted changes; a development one counts and ignores them. */
|
|
16
|
+
readonly environment: "production" | "development";
|
|
17
|
+
}
|
|
18
|
+
/** An account a token reaches. */
|
|
19
|
+
export interface DeployAccount {
|
|
20
|
+
readonly id: string;
|
|
21
|
+
/** The name the host shows, such as "sam@example.com's Account". */
|
|
22
|
+
readonly name: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* One thing a deploy creates or destroy removes, in the words the user meets
|
|
26
|
+
* on the host's dashboard and bill: an address, a Worker, a database, a bucket.
|
|
27
|
+
*/
|
|
28
|
+
export interface DeployResource {
|
|
29
|
+
readonly kind: "address" | "service" | "database" | "bucket";
|
|
30
|
+
readonly name: string;
|
|
31
|
+
}
|
|
32
|
+
/** A version of a deployment. `number` counts from 1 per deployment; `id` is the host's own. */
|
|
33
|
+
export interface DeployedVersion {
|
|
34
|
+
readonly number: number;
|
|
35
|
+
readonly id: string;
|
|
36
|
+
/** The commit it was deployed from, when the host still says. */
|
|
37
|
+
readonly commit: string | undefined;
|
|
38
|
+
/** The Halonic version it runs, when the host still says. */
|
|
39
|
+
readonly halonicVersion: string | undefined;
|
|
40
|
+
/** When it went live, as an ISO time. */
|
|
41
|
+
readonly liveSince: string | undefined;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Who holds a deployment's lock. `who` is the git email of whoever started
|
|
45
|
+
* the deploy, or the computer's name when there's none, and never anything
|
|
46
|
+
* else about the machine or the host. Times are ISO. The lock frees itself at
|
|
47
|
+
* `expiresAt`, 10 minutes after its last renewal.
|
|
48
|
+
*/
|
|
49
|
+
export interface DeployLockHolder {
|
|
50
|
+
readonly who: string;
|
|
51
|
+
readonly startedAt: string;
|
|
52
|
+
readonly expiresAt: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* One address the deployment talks to from the host, and the secret it sends
|
|
56
|
+
* there, by name only. `secret` is `undefined` when it sends none.
|
|
57
|
+
*/
|
|
58
|
+
export interface DeployReach {
|
|
59
|
+
/** A host name such as "api.anthropic.com", or "*" for any web address. */
|
|
60
|
+
readonly address: string;
|
|
61
|
+
readonly secret: string | undefined;
|
|
62
|
+
}
|
|
63
|
+
/** What a deploy uploads, taken by the caller from one commit. */
|
|
64
|
+
export interface DeploySnapshot {
|
|
65
|
+
readonly commit: string;
|
|
66
|
+
/** The workspace's files at `commit`, read-only. */
|
|
67
|
+
readonly files: DefinitionSource;
|
|
68
|
+
/** The Halonic version of the command line that deploys; the deployment then runs it. */
|
|
69
|
+
readonly halonicVersion: string;
|
|
70
|
+
}
|
|
71
|
+
/** What `plan` and `deploy` are given. */
|
|
72
|
+
export interface DeployRequest {
|
|
73
|
+
readonly deployment: DeploymentRef;
|
|
74
|
+
readonly snapshot: DeploySnapshot;
|
|
75
|
+
/**
|
|
76
|
+
* Secret values by name: the sign-in password's hash and the workspace's
|
|
77
|
+
* keys. A target sends them to the host and nowhere else: never into a
|
|
78
|
+
* result, an event, an error or a log.
|
|
79
|
+
*/
|
|
80
|
+
readonly secrets: ReadonlyMap<string, string>;
|
|
81
|
+
/**
|
|
82
|
+
* What the workspace reaches, as the caller read it from the files. The
|
|
83
|
+
* target keeps it with the version, so the next `plan` can say what's new.
|
|
84
|
+
*/
|
|
85
|
+
readonly reaches: readonly DeployReach[];
|
|
86
|
+
/** Use resources with Halonic's names that Halonic didn't create. */
|
|
87
|
+
readonly adopt?: boolean;
|
|
88
|
+
/** Allow a database change that deletes data. Without it such a change is refused with `denied`. */
|
|
89
|
+
readonly allowDataLoss?: boolean;
|
|
90
|
+
/** Aborting stops at the next safe point; see {@link DeployTarget.deploy}. */
|
|
91
|
+
readonly signal?: AbortSignal;
|
|
92
|
+
}
|
|
93
|
+
/** What a deploy would do, measured against what's live. Nothing was changed. */
|
|
94
|
+
export interface DeployPlan {
|
|
95
|
+
readonly account: DeployAccount;
|
|
96
|
+
/** The address once live; `undefined` when the host only gives it on the first deploy. */
|
|
97
|
+
readonly url: string | undefined;
|
|
98
|
+
/** What the deploy would create, in order. Empty when it all exists. */
|
|
99
|
+
readonly creates: readonly DeployResource[];
|
|
100
|
+
/** Ids of the database changes it would apply, in order. */
|
|
101
|
+
readonly databaseChanges: readonly string[];
|
|
102
|
+
/** `true` when one of those changes deletes data. */
|
|
103
|
+
readonly deletesData: boolean;
|
|
104
|
+
/** The live version, or `undefined` when nothing is live. */
|
|
105
|
+
readonly live: DeployedVersion | undefined;
|
|
106
|
+
/** What the live version reaches, or `undefined` when nothing is live or it doesn't say. */
|
|
107
|
+
readonly liveReaches: readonly DeployReach[] | undefined;
|
|
108
|
+
/** The lock's holder when another deploy is running, checked before any question is asked. */
|
|
109
|
+
readonly lockedBy: DeployLockHolder | undefined;
|
|
110
|
+
/** `true` when the live version has the same commit and Halonic version, so a deploy changes nothing. */
|
|
111
|
+
readonly unchanged: boolean;
|
|
112
|
+
/** Every file the deploy would upload, for `--plan`. */
|
|
113
|
+
readonly files: readonly string[];
|
|
114
|
+
}
|
|
115
|
+
/** One step of a deploy, as its events name it. */
|
|
116
|
+
export type DeployStep = {
|
|
117
|
+
readonly step: "create";
|
|
118
|
+
readonly resource: DeployResource;
|
|
119
|
+
}
|
|
120
|
+
/** `first` is `true` when the database is set up rather than updated. */
|
|
121
|
+
| {
|
|
122
|
+
readonly step: "database";
|
|
123
|
+
readonly changes: number;
|
|
124
|
+
readonly first: boolean;
|
|
125
|
+
} | {
|
|
126
|
+
readonly step: "upload";
|
|
127
|
+
readonly version: number;
|
|
128
|
+
readonly files: number;
|
|
129
|
+
readonly secrets: number;
|
|
130
|
+
} | {
|
|
131
|
+
readonly step: "self-test";
|
|
132
|
+
readonly version: number;
|
|
133
|
+
} | {
|
|
134
|
+
readonly step: "switch";
|
|
135
|
+
readonly version: number;
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* What a deploy reports as it goes, in order. Each step is `started`, then
|
|
139
|
+
* `done`; `waiting` comes while a step has waited over 10 seconds for the
|
|
140
|
+
* host; `warning` is a line the user must see, such as a database change that
|
|
141
|
+
* goes live without a trial.
|
|
142
|
+
*/
|
|
143
|
+
export type DeployEvent = (DeployStep & {
|
|
144
|
+
readonly phase: "started" | "done";
|
|
145
|
+
}) | {
|
|
146
|
+
readonly phase: "waiting";
|
|
147
|
+
readonly step: DeployStep["step"];
|
|
148
|
+
/** Whole seconds since the step started. */
|
|
149
|
+
readonly seconds: number;
|
|
150
|
+
} | {
|
|
151
|
+
readonly phase: "warning";
|
|
152
|
+
readonly message: string;
|
|
153
|
+
};
|
|
154
|
+
/** A deploy that went live. */
|
|
155
|
+
export interface DeployDone {
|
|
156
|
+
readonly outcome: "deployed";
|
|
157
|
+
readonly url: string;
|
|
158
|
+
readonly version: DeployedVersion;
|
|
159
|
+
/** The version before it, which a rollback goes back to; `undefined` on the first deploy. */
|
|
160
|
+
readonly previous: DeployedVersion | undefined;
|
|
161
|
+
/**
|
|
162
|
+
* What went wrong after traffic switched, such as the lock lost after the
|
|
163
|
+
* switch. The deploy is live. A caller shows every entry.
|
|
164
|
+
*/
|
|
165
|
+
readonly warnings: readonly string[];
|
|
166
|
+
}
|
|
167
|
+
/** A deploy whose commit and Halonic version were live already. No new version was made. */
|
|
168
|
+
export interface DeployUnchanged {
|
|
169
|
+
readonly outcome: "unchanged";
|
|
170
|
+
readonly url: string;
|
|
171
|
+
readonly version: DeployedVersion;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* The new version failed its self-test. `stillLive` is the version that
|
|
175
|
+
* still serves, or `undefined` when the new one went live before the test (a
|
|
176
|
+
* first deploy, or a change the host only applies by going live) and doesn't
|
|
177
|
+
* work. `restoreFailed` is `true` when putting the previous version back failed.
|
|
178
|
+
*/
|
|
179
|
+
export interface DeploySelfTestFailed {
|
|
180
|
+
readonly outcome: "self-test-failed";
|
|
181
|
+
readonly version: DeployedVersion;
|
|
182
|
+
readonly failedChecks: readonly string[];
|
|
183
|
+
readonly stillLive: DeployedVersion | undefined;
|
|
184
|
+
readonly restoreFailed: boolean;
|
|
185
|
+
}
|
|
186
|
+
/** How a deploy ended when nothing was thrown. */
|
|
187
|
+
export type DeployResult = DeployDone | DeployUnchanged | DeploySelfTestFailed;
|
|
188
|
+
/** Runs by state, for `status`. Only these states are counted; nothing about a run leaves the count. */
|
|
189
|
+
export interface DeployRunCounts {
|
|
190
|
+
readonly running: number;
|
|
191
|
+
readonly waiting: number;
|
|
192
|
+
readonly lastDay: number;
|
|
193
|
+
}
|
|
194
|
+
/** What `status` reads. It never changes anything. */
|
|
195
|
+
export interface DeploymentStatus {
|
|
196
|
+
readonly account: DeployAccount;
|
|
197
|
+
readonly url: string | undefined;
|
|
198
|
+
readonly live: DeployedVersion | undefined;
|
|
199
|
+
/** The version a rollback would go back to. */
|
|
200
|
+
readonly previous: DeployedVersion | undefined;
|
|
201
|
+
/** Whether the address answers, and when the routine tick last ran (ISO). */
|
|
202
|
+
readonly health: {
|
|
203
|
+
readonly answering: true;
|
|
204
|
+
readonly lastRoutineTick: string | undefined;
|
|
205
|
+
} | {
|
|
206
|
+
readonly answering: false;
|
|
207
|
+
};
|
|
208
|
+
/** `undefined` when the count failed: status never fails on it. */
|
|
209
|
+
readonly runs: DeployRunCounts | undefined;
|
|
210
|
+
readonly lockedBy: DeployLockHolder | undefined;
|
|
211
|
+
/** The step the last deploy stopped in, when it stopped without finishing. */
|
|
212
|
+
readonly unfinished: DeployStep["step"] | undefined;
|
|
213
|
+
}
|
|
214
|
+
/** What `rollback` did, or would do with `plan`. */
|
|
215
|
+
export interface DeployRollback {
|
|
216
|
+
readonly mode: "plan" | "rolled-back";
|
|
217
|
+
readonly from: DeployedVersion;
|
|
218
|
+
readonly to: DeployedVersion;
|
|
219
|
+
}
|
|
220
|
+
/** How much `export` wrote or `import` read. Secrets and tokens are never in a transfer. */
|
|
221
|
+
export interface DeployTransferCounts {
|
|
222
|
+
readonly runs: number;
|
|
223
|
+
readonly records: number;
|
|
224
|
+
readonly files: number;
|
|
225
|
+
readonly bytes: number;
|
|
226
|
+
}
|
|
227
|
+
/** One thing destroy removes, with what it holds, for the list the user confirms. */
|
|
228
|
+
export interface DestroyItem {
|
|
229
|
+
readonly resource: DeployResource;
|
|
230
|
+
readonly secrets?: number;
|
|
231
|
+
readonly runs?: number;
|
|
232
|
+
readonly bytes?: number;
|
|
233
|
+
}
|
|
234
|
+
/** What `destroy` is given. */
|
|
235
|
+
export interface DestroyRequest {
|
|
236
|
+
/**
|
|
237
|
+
* Shown the list before anything is removed; `false` stops with nothing
|
|
238
|
+
* removed. The caller asks the user to type the service's name.
|
|
239
|
+
*/
|
|
240
|
+
readonly confirm: (items: readonly DestroyItem[]) => Promise<boolean>;
|
|
241
|
+
/** List what would be removed and remove nothing. */
|
|
242
|
+
readonly plan?: boolean;
|
|
243
|
+
readonly signal?: AbortSignal;
|
|
244
|
+
}
|
|
245
|
+
/** What `destroy` did. `left` holds what it didn't remove because Halonic didn't create it. */
|
|
246
|
+
export interface DestroyResult {
|
|
247
|
+
readonly mode: "plan" | "destroyed" | "cancelled";
|
|
248
|
+
readonly items: readonly DestroyItem[];
|
|
249
|
+
readonly left: readonly DeployResource[];
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Why a target call failed. `code` is stable and goes into `--json`; callers
|
|
253
|
+
* branch on `kind`, so a new code keeps the port's version.
|
|
254
|
+
*/
|
|
255
|
+
export type DeployFailureCode = "token-missing" | "token-inactive" | "missing-permission" | "no-account" | "ambiguous-account" | "free-plan" | "host-unreachable" | "host-request-failed" | "unmarked-resources" | "uncommitted-changes" | "deploy-locked" | "older-than-live" | "data-loss" | "not-deployed" | "nothing-to-roll-back" | "rollback-not-possible" | "transfer-failed" | "destroy-changed" | "stopped";
|
|
256
|
+
/**
|
|
257
|
+
* What every {@link DeployTarget} method rejects with when it fails: an
|
|
258
|
+
* `Error` with one of the kit's error kinds (`RunFailureKind`, which the
|
|
259
|
+
* engine's type test keeps equal to `@halonicjs/std`'s `ErrorKind`), so
|
|
260
|
+
* `errorKindOf` reads it and the command line's exit code needs no new number. The message and `fix` are
|
|
261
|
+
* safe to show: no token, secret or host response body.
|
|
262
|
+
*
|
|
263
|
+
* `stopped` (kind `conflict`) is the abort of a request's signal. Its `live`
|
|
264
|
+
* says what still serves, so the caller can say "Version 1 is still live."
|
|
265
|
+
*/
|
|
266
|
+
export interface DeployFailure extends Error {
|
|
267
|
+
readonly kind: RunFailureKind;
|
|
268
|
+
readonly code: DeployFailureCode;
|
|
269
|
+
readonly fix: string | undefined;
|
|
270
|
+
/** What serves after the failure: a version, `"none"`, or `undefined` when not known. */
|
|
271
|
+
readonly live?: DeployedVersion | "none";
|
|
272
|
+
/** The step a `stopped` deploy stopped after. */
|
|
273
|
+
readonly stoppedAfter?: DeployStep;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* What a target is created with. The caller's host builds it; the target
|
|
277
|
+
* gets nothing else from the machine.
|
|
278
|
+
*/
|
|
279
|
+
export interface DeployTargetContext {
|
|
280
|
+
readonly http: HttpClient;
|
|
281
|
+
/** Where `login` keeps the host's token: the user's keychain. */
|
|
282
|
+
readonly tokens: TokenStore;
|
|
283
|
+
/** A token from the environment, for CI. It wins over the saved one and is never saved. */
|
|
284
|
+
readonly environmentToken: string | undefined;
|
|
285
|
+
/** Who runs this, for the lock: the git email, else the computer's name. */
|
|
286
|
+
readonly who: string;
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Deploys a workspace to a host such as Cloudflare, and reads, rolls back,
|
|
290
|
+
* moves data in and out of and removes what it deployed (ADR 5.6; requirement
|
|
291
|
+
* `ports.deploy-target`). The `halonic deploy` command calls it through the
|
|
292
|
+
* deploy app service, and never imports a target package: it loads one by
|
|
293
|
+
* name and checks its {@link DeployTargetEntry}.
|
|
294
|
+
*
|
|
295
|
+
* Every method that changes the host holds the deployment's lock while it
|
|
296
|
+
* does; a second one rejects with `deploy-locked` and the holder. Results are
|
|
297
|
+
* data. Failures are {@link DeployFailure}s.
|
|
298
|
+
*
|
|
299
|
+
* @example
|
|
300
|
+
* const target = entry.create({ http, tokens, environmentToken, who });
|
|
301
|
+
* const plan = await target.plan(request);
|
|
302
|
+
* if (plan.lockedBy === undefined && (await ask(plan))) {
|
|
303
|
+
* const result = await target.deploy(request, (event) => output.show(event));
|
|
304
|
+
* }
|
|
305
|
+
*/
|
|
306
|
+
export interface DeployTarget {
|
|
307
|
+
/**
|
|
308
|
+
* Checks a pasted token, saves it and lists the accounts it reaches.
|
|
309
|
+
* Rejects with `token-inactive` or `missing-permission`.
|
|
310
|
+
*/
|
|
311
|
+
login(token: string): Promise<{
|
|
312
|
+
readonly accounts: readonly DeployAccount[];
|
|
313
|
+
}>;
|
|
314
|
+
/** Measures a deploy against what's live. Changes nothing and takes no lock. */
|
|
315
|
+
plan(request: DeployRequest): Promise<DeployPlan>;
|
|
316
|
+
/**
|
|
317
|
+
* Creates what's missing, updates the database, uploads a new version,
|
|
318
|
+
* self-tests it and makes it live, reporting each step to `onEvent`.
|
|
319
|
+
* Aborting the signal stops at once before anything changed or during the
|
|
320
|
+
* self-test, finishes the step it's in otherwise, and rejects with
|
|
321
|
+
* `stopped`; making it live is one step and always finishes.
|
|
322
|
+
*/
|
|
323
|
+
deploy(request: DeployRequest, onEvent: (event: DeployEvent) => void): Promise<DeployResult>;
|
|
324
|
+
status(deployment: DeploymentRef): Promise<DeploymentStatus>;
|
|
325
|
+
/** Goes back one version. Rejects with `rollback-not-possible` when the database has moved on. */
|
|
326
|
+
rollback(deployment: DeploymentRef, options?: {
|
|
327
|
+
readonly plan?: boolean;
|
|
328
|
+
readonly signal?: AbortSignal;
|
|
329
|
+
}): Promise<DeployRollback>;
|
|
330
|
+
/** Writes the deployment's runs, records and files to a local folder. */
|
|
331
|
+
export(deployment: DeploymentRef, folder: string, options?: {
|
|
332
|
+
readonly signal?: AbortSignal;
|
|
333
|
+
}): Promise<DeployTransferCounts>;
|
|
334
|
+
/** Reads a folder `export` wrote into the deployment. */
|
|
335
|
+
import(deployment: DeploymentRef, folder: string, options?: {
|
|
336
|
+
readonly signal?: AbortSignal;
|
|
337
|
+
}): Promise<DeployTransferCounts>;
|
|
338
|
+
/** Frees a lock left by a deploy that stopped without finishing. Gives the holder it freed, if any. */
|
|
339
|
+
unlock(deployment: DeploymentRef): Promise<{
|
|
340
|
+
readonly freed: DeployLockHolder | undefined;
|
|
341
|
+
}>;
|
|
342
|
+
/** Signs out every browser signed in to the deployment. */
|
|
343
|
+
revokeSessions(deployment: DeploymentRef): Promise<void>;
|
|
344
|
+
/** Removes what Halonic created for the deployment, after `confirm` says yes. */
|
|
345
|
+
destroy(deployment: DeploymentRef, request: DestroyRequest): Promise<DestroyResult>;
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* What a target package exports as `deployTarget`. The loader checks `host`
|
|
349
|
+
* and `version` before it calls `create`, and that what `create` gives has
|
|
350
|
+
* every {@link DeployTarget} method.
|
|
351
|
+
*/
|
|
352
|
+
export interface DeployTargetEntry {
|
|
353
|
+
/** The `host` in `deployments.yaml` this target serves, such as "cloudflare". */
|
|
354
|
+
readonly host: string;
|
|
355
|
+
/** The port version the target was built against. */
|
|
356
|
+
readonly version: number;
|
|
357
|
+
create(context: DeployTargetContext): DeployTarget;
|
|
358
|
+
}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import type { ToolOutcome, Usage } from "../../events/src/index.js";
|
|
1
|
+
import type { RunEventBody, ToolOutcome, Usage } from "../../events/src/index.js";
|
|
2
2
|
import type { ToolDefinition } from "./chat.js";
|
|
3
3
|
import type { HarnessBridge, HarnessEvent } from "./harness.js";
|
|
4
4
|
import { type ModelPrice } from "./model-price.js";
|
|
5
5
|
/** Version of the {@link HarnessBridgeServer} port. A breaking change bumps it and comes with an ADR. */
|
|
6
6
|
export declare const harnessBridgeServerVersion = 1;
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* The API a model provider speaks, which the bridge passes requests on in:
|
|
9
|
+
* Anthropic's Messages API, or OpenAI's Responses API. Each is at a fixed
|
|
10
|
+
* host the adapter knows, unless a keyed access names its own `baseUrl`.
|
|
11
|
+
*/
|
|
8
12
|
export type BridgeProvider = "anthropic" | "openai";
|
|
9
13
|
/** How the agent reaches one provider through the bridge. */
|
|
10
14
|
export type BridgeProviderAccess =
|
|
@@ -13,10 +17,35 @@ export type BridgeProviderAccess =
|
|
|
13
17
|
* this name, from the `Secrets` port, in place of the program's key, and
|
|
14
18
|
* records the cost from the model's price. A model without a price is
|
|
15
19
|
* recorded without a cost, so the run shows it as unpriced.
|
|
20
|
+
*
|
|
21
|
+
* `baseUrl` is the provider file's address for a host that speaks the
|
|
22
|
+
* same API, such as `https://api.z.ai/api/anthropic`. The bridge sends
|
|
23
|
+
* this agent's calls, and the key, to that one origin only; without it,
|
|
24
|
+
* to the API's own host. The host has already checked that the key may
|
|
25
|
+
* go there (the workspace's trust and the key's allowed addresses).
|
|
26
|
+
*
|
|
27
|
+
* `providerId` is the id of the provider file the key comes from, such
|
|
28
|
+
* as `zai`. The bridge names it as the call's `provider` in `llm.request`
|
|
29
|
+
* and `llm.response`, so the run log shows where the call went; without
|
|
30
|
+
* it, the API's own name (`anthropic`, `openai`).
|
|
31
|
+
*
|
|
32
|
+
* `models` are the models the host resolved for this agent at this
|
|
33
|
+
* provider: its alias's model, and the models of its fallbacks that use
|
|
34
|
+
* the same provider file. The bridge refuses, before it reads the key, a
|
|
35
|
+
* call that names any other model, exactly as written, a call that names
|
|
36
|
+
* other models of its own (Messages' `fallbacks`, or a tool with its own
|
|
37
|
+
* `model`), so the key is spent only on models the host priced. With a
|
|
38
|
+
* `baseUrl`, it also refuses every call when the list is missing or
|
|
39
|
+
* empty, since a compatible provider can serve models that reach the
|
|
40
|
+
* network from its own side. Without a `baseUrl`, a missing list still
|
|
41
|
+
* lets any model through, until every host sends one (HAL-12488).
|
|
16
42
|
*/
|
|
17
43
|
{
|
|
18
44
|
kind: "key";
|
|
19
45
|
secret: string;
|
|
46
|
+
baseUrl?: string;
|
|
47
|
+
providerId?: string;
|
|
48
|
+
models?: readonly string[];
|
|
20
49
|
}
|
|
21
50
|
/**
|
|
22
51
|
* With the person's own subscription: the bridge passes the program's own
|
|
@@ -29,25 +58,41 @@ export type BridgeProviderAccess =
|
|
|
29
58
|
| {
|
|
30
59
|
kind: "sign-in";
|
|
31
60
|
};
|
|
32
|
-
/**
|
|
61
|
+
/**
|
|
62
|
+
* What is recorded of the bridge: the model calls and Halonic tool calls that
|
|
63
|
+
* go through it, and the failures it told the program the run log has the
|
|
64
|
+
* details of (`bridge.failed`, from {@link HarnessBridgeOptions.reportError}).
|
|
65
|
+
*/
|
|
33
66
|
export type BridgeEvent = Extract<HarnessEvent, {
|
|
34
67
|
type: "llm.request" | "llm.response" | "tool.called" | "tool.result";
|
|
68
|
+
}> | Extract<RunEventBody, {
|
|
69
|
+
type: "bridge.failed";
|
|
35
70
|
}>;
|
|
36
71
|
/** Writes the bridge's events to the run's log. The engine adds `runId`, `seq`, `at` and the `state`. */
|
|
37
72
|
export interface BridgeRecorder {
|
|
73
|
+
/**
|
|
74
|
+
* A `bridge.failed` never counts towards the budget, so recording one never
|
|
75
|
+
* throws `limit_reached`.
|
|
76
|
+
*
|
|
77
|
+
* @throws KindedError `limit_reached` for an `llm.request` once the run's
|
|
78
|
+
* budget is reached: the bridge then sends the model call nowhere and
|
|
79
|
+
* answers the program with 429 and the error's message
|
|
80
|
+
*/
|
|
38
81
|
record(event: BridgeEvent): Promise<void>;
|
|
39
82
|
}
|
|
40
83
|
/**
|
|
41
84
|
* What to do with a tool call before it runs, by the same rules as the
|
|
42
85
|
* built-in loop: the agent's `allow` and `approve` lists, the connection's
|
|
43
86
|
* "allow sending" setting and the workspace's trust. `ask`: run it only once
|
|
44
|
-
* a person says yes
|
|
87
|
+
* a person says yes; `connector` names the connector the tool comes from,
|
|
88
|
+
* when it comes from one, for the approval's record. `refused`: don't run it; `reason` goes back to the
|
|
45
89
|
* program as the call's result.
|
|
46
90
|
*/
|
|
47
91
|
export type BridgeToolCheck = {
|
|
48
92
|
kind: "run";
|
|
49
93
|
} | {
|
|
50
94
|
kind: "ask";
|
|
95
|
+
connector?: string;
|
|
51
96
|
} | {
|
|
52
97
|
kind: "refused";
|
|
53
98
|
reason: string;
|
|
@@ -80,6 +125,8 @@ export interface BridgeApprovalRequest {
|
|
|
80
125
|
/** Unique in the run; the bridge makes it up. */
|
|
81
126
|
callId: string;
|
|
82
127
|
tool: string;
|
|
128
|
+
/** The connector the tool comes from, when it comes from one; `tool` stays the bare name. */
|
|
129
|
+
connector?: string;
|
|
83
130
|
args: unknown;
|
|
84
131
|
}
|
|
85
132
|
/** A person's answer to a {@link BridgeApprovalRequest}. */
|
|
@@ -119,6 +166,15 @@ export interface HarnessBridgeOptions {
|
|
|
119
166
|
recorder: BridgeRecorder;
|
|
120
167
|
tools: BridgeTools;
|
|
121
168
|
approvals: BridgeApprovals;
|
|
169
|
+
/**
|
|
170
|
+
* Hears of a request that failed for a reason the bridge doesn't name to the
|
|
171
|
+
* program, so the run log can hold what the program was told is there.
|
|
172
|
+
* `kind` is the error kind of `@halonicjs/std`; `message` never holds the run token. It must not throw.
|
|
173
|
+
*/
|
|
174
|
+
reportError?(failure: {
|
|
175
|
+
kind: string;
|
|
176
|
+
message: string;
|
|
177
|
+
}): void;
|
|
122
178
|
/** Aborting it closes the bridge, as {@link OpenHarnessBridge.close} does. */
|
|
123
179
|
signal?: AbortSignal;
|
|
124
180
|
}
|
|
@@ -161,7 +217,8 @@ export interface OpenHarnessBridge extends HarnessBridge {
|
|
|
161
217
|
close(): Promise<void>;
|
|
162
218
|
}
|
|
163
219
|
/**
|
|
164
|
-
* Opens the Halonic bridge for one run: a server on loopback
|
|
220
|
+
* Opens the Halonic bridge for one run: a server on loopback, or on a Unix
|
|
221
|
+
* socket only this user can open, that passes the
|
|
165
222
|
* program's model requests to the provider and serves Halonic's tools and
|
|
166
223
|
* approvals over MCP (requirement `ports.harness-bridge-server`). The engine
|
|
167
224
|
* opens it before the sandbox and closes it when the run ends. It is a port
|
|
@@ -181,9 +238,12 @@ export interface OpenHarnessBridge extends HarnessBridge {
|
|
|
181
238
|
*/
|
|
182
239
|
export interface HarnessBridgeServer {
|
|
183
240
|
/**
|
|
184
|
-
* Starts serving one run on a free loopback port
|
|
241
|
+
* Starts serving one run on a free loopback port, or on a new Unix socket
|
|
242
|
+
* of its own when the adapter is set up for sockets. A socket bridge gives
|
|
243
|
+
* its path as {@link HarnessBridge.socketPath}. One that can't create its
|
|
244
|
+
* socket fails: it never falls back to a loopback port.
|
|
185
245
|
*
|
|
186
|
-
* @throws when it can't listen
|
|
246
|
+
* @throws when it can't listen
|
|
187
247
|
*/
|
|
188
248
|
open(options: HarnessBridgeOptions): Promise<OpenHarnessBridge>;
|
|
189
249
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { HarnessSignIn } from "./harness.js";
|
|
2
|
+
/**
|
|
3
|
+
* The terminal a person types a sign-in into: PowerShell, the default
|
|
4
|
+
* terminal on Windows, or `sh` and the shells that read it like `sh` elsewhere.
|
|
5
|
+
*/
|
|
6
|
+
export type SignInShell = "powershell" | "sh";
|
|
7
|
+
/**
|
|
8
|
+
* A harness's sign-in for one agent, as a person types it into their own
|
|
9
|
+
* terminal (requirement `ports.harness-sign-in-command`). Studio shows it
|
|
10
|
+
* when it can't open a window, and `halonic doctor` shows it for each
|
|
11
|
+
* agent that isn't signed in, so both print the same command.
|
|
12
|
+
*
|
|
13
|
+
* It names the program as the person's `PATH` finds it and sets the
|
|
14
|
+
* agent's folder for this command only. The folder is single-quoted, so the
|
|
15
|
+
* shell takes it as it is: no variable, `~` or wildcard in it is expanded.
|
|
16
|
+
*
|
|
17
|
+
* @param signIn - the harness's own sign-in
|
|
18
|
+
* @param settingsFolder - the agent's settings folder, absolute
|
|
19
|
+
* @param shell - the terminal it is typed into
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* signInCommandText(claudeCodeSignIn, "/data/agents/writer", "sh");
|
|
23
|
+
* // CLAUDE_CONFIG_DIR='/data/agents/writer' claude auth login
|
|
24
|
+
* signInCommandText(claudeCodeSignIn, agentFolder, "powershell");
|
|
25
|
+
* // $env:CLAUDE_CONFIG_DIR = '<agentFolder>'; claude auth login
|
|
26
|
+
*/
|
|
27
|
+
export declare function signInCommandText(signIn: HarnessSignIn, settingsFolder: string, shell: SignInShell): string;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A harness's sign-in for one agent, as a person types it into their own
|
|
3
|
+
* terminal (requirement `ports.harness-sign-in-command`). Studio shows it
|
|
4
|
+
* when it can't open a window, and `halonic doctor` shows it for each
|
|
5
|
+
* agent that isn't signed in, so both print the same command.
|
|
6
|
+
*
|
|
7
|
+
* It names the program as the person's `PATH` finds it and sets the
|
|
8
|
+
* agent's folder for this command only. The folder is single-quoted, so the
|
|
9
|
+
* shell takes it as it is: no variable, `~` or wildcard in it is expanded.
|
|
10
|
+
*
|
|
11
|
+
* @param signIn - the harness's own sign-in
|
|
12
|
+
* @param settingsFolder - the agent's settings folder, absolute
|
|
13
|
+
* @param shell - the terminal it is typed into
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* signInCommandText(claudeCodeSignIn, "/data/agents/writer", "sh");
|
|
17
|
+
* // CLAUDE_CONFIG_DIR='/data/agents/writer' claude auth login
|
|
18
|
+
* signInCommandText(claudeCodeSignIn, agentFolder, "powershell");
|
|
19
|
+
* // $env:CLAUDE_CONFIG_DIR = '<agentFolder>'; claude auth login
|
|
20
|
+
*/
|
|
21
|
+
export function signInCommandText(signIn, settingsFolder, shell) {
|
|
22
|
+
const words = [signIn.program, ...signIn.args].join(" ");
|
|
23
|
+
if (shell === "powershell") {
|
|
24
|
+
// PowerShell keeps a single-quoted string as it is, apart from `''` for one `'`.
|
|
25
|
+
const folder = `'${settingsFolder.replaceAll("'", "''")}'`;
|
|
26
|
+
return `$env:${signIn.folderVariable} = ${folder}; ${words}`;
|
|
27
|
+
}
|
|
28
|
+
// `sh` keeps a single-quoted string as it is; a `'` closes it, so it is written `'\''`.
|
|
29
|
+
const folder = `'${settingsFolder.replaceAll("'", "'\\''")}'`;
|
|
30
|
+
return `${signIn.folderVariable}=${folder} ${words}`;
|
|
31
|
+
}
|