@indigoai-us/hq-cli 5.345.225 → 5.345.228
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/CHANGELOG.md +174 -0
- package/dist/command-catalog.generated.d.ts +215 -0
- package/dist/command-catalog.generated.js +261 -0
- package/dist/commands/auth.d.ts +2 -2
- package/dist/commands/auth.js +3 -3
- package/dist/commands/core-delegate-w1b.js +92 -69
- package/dist/commands/core-delegate.d.ts +19 -1
- package/dist/commands/core-delegate.js +411 -6
- package/dist/commands/core-dm-bind-native.js +2 -1
- package/dist/commands/core-handoff.d.ts +5 -0
- package/dist/commands/core-handoff.js +1008 -14
- package/dist/commands/core-pin-native.d.ts +1 -0
- package/dist/commands/core-pin-native.js +3 -15
- package/dist/commands/core-register-project-native.d.ts +6 -0
- package/dist/commands/core-register-project-native.js +182 -52
- package/dist/commands/core-work-mesh-bind-trusted-native.js +4 -9
- package/dist/commands/daemon.js +3 -3
- package/dist/commands/deploy-domains.js +38 -2
- package/dist/commands/index-cmd.d.ts +3 -1
- package/dist/commands/index-cmd.js +12 -0
- package/dist/commands/lanes-accounts.d.ts +14 -0
- package/dist/commands/lanes-accounts.js +119 -0
- package/dist/commands/lanes-checks.js +1 -1
- package/dist/commands/lanes-move.js +10 -0
- package/dist/commands/lanes-session-start.d.ts +1 -2
- package/dist/commands/lanes-session-start.js +9 -145
- package/dist/commands/lanes-shared.d.ts +3 -0
- package/dist/commands/lanes-shared.js +9 -0
- package/dist/commands/lanes.d.ts +3 -0
- package/dist/commands/lanes.js +231 -39
- package/dist/commands/link.d.ts +8 -3
- package/dist/commands/link.js +14 -17
- package/dist/commands/mcp-registration.d.ts +65 -7
- package/dist/commands/mcp-registration.js +289 -51
- package/dist/commands/mesh.d.ts +12 -0
- package/dist/commands/mesh.js +92 -10
- package/dist/commands/reindex.js +6 -0
- package/dist/commands/repo.d.ts +13 -0
- package/dist/commands/repo.js +39 -1
- package/dist/commands/sync-held.d.ts +22 -0
- package/dist/commands/sync-held.js +167 -18
- package/dist/commands/sync-mode.d.ts +3 -1
- package/dist/commands/sync-mode.js +11 -1
- package/dist/hq-cloud-sync-runner/bin/sync-runner.js +4845 -2524
- package/dist/hq-cloud-sync-runner/package.json +1 -1
- package/dist/lazy-commands.js +3 -4
- package/dist/lib/capacity/accounts.d.ts +4 -0
- package/dist/lib/capacity/accounts.js +4 -0
- package/dist/lib/capacity/route.js +14 -0
- package/dist/lib/capacity/sign-in.d.ts +18 -0
- package/dist/lib/capacity/sign-in.js +34 -1
- package/dist/lib/checkpoint-ontology/entity-file.js +4 -4
- package/dist/lib/checkpoint-ontology/merge-copies.js +7 -11
- package/dist/lib/checkpoint-ontology/plan.js +2 -1
- package/dist/lib/core-utils/archive-old-threads.js +5 -2
- package/dist/lib/core-utils/session-company.d.ts +13 -1
- package/dist/lib/core-utils/session-company.js +75 -4
- package/dist/lib/core-utils/worktree-resume.d.ts +6 -0
- package/dist/lib/core-utils/worktree-resume.js +8 -4
- package/dist/lib/daemon/background-qos.d.ts +7 -0
- package/dist/lib/daemon/background-qos.js +13 -0
- package/dist/lib/daemon/catalog.d.ts +10 -0
- package/dist/lib/daemon/catalog.js +9 -2
- package/dist/lib/daemon/hook-requests-acl-suggest.d.ts +18 -0
- package/dist/lib/daemon/hook-requests-acl-suggest.js +245 -0
- package/dist/lib/daemon/hook-requests-fleet-session-start.d.ts +32 -0
- package/dist/lib/daemon/hook-requests-fleet-session-start.js +214 -0
- package/dist/lib/daemon/hook-requests-mesh-tool-writes.d.ts +44 -0
- package/dist/lib/daemon/hook-requests-mesh-tool-writes.js +292 -0
- package/dist/lib/daemon/hook-requests-mesh.d.ts +54 -0
- package/dist/lib/daemon/hook-requests-mesh.js +559 -0
- package/dist/lib/daemon/hook-requests.d.ts +417 -0
- package/dist/lib/daemon/hook-requests.js +1747 -0
- package/dist/lib/daemon/lanes-reconcile-status.d.ts +35 -0
- package/dist/lib/daemon/lanes-reconcile-status.js +86 -0
- package/dist/lib/daemon/machine-checks.d.ts +12 -2
- package/dist/lib/daemon/machine-checks.js +27 -10
- package/dist/lib/daemon/merge-sections.d.ts +24 -2
- package/dist/lib/daemon/merge-sections.js +58 -16
- package/dist/lib/daemon/ops/policy.d.ts +1 -1
- package/dist/lib/daemon/ops/policy.js +47 -6
- package/dist/lib/daemon/resolver.js +9 -2
- package/dist/lib/daemon/run.d.ts +11 -7
- package/dist/lib/daemon/run.js +195 -18
- package/dist/lib/daemon/search-index-worker-v1.d.ts +2 -0
- package/dist/lib/daemon/search-index-worker-v1.js +25 -0
- package/dist/lib/daemon/server.js +6 -1
- package/dist/lib/daemon/session-registry.d.ts +0 -1
- package/dist/lib/daemon/session-registry.js +0 -3
- package/dist/lib/daemon/supervisor.d.ts +5 -1
- package/dist/lib/daemon/supervisor.js +1 -1
- package/dist/lib/daemon/tcc-eperm.d.ts +59 -4
- package/dist/lib/daemon/tcc-eperm.js +110 -8
- package/dist/lib/doctor/fix/process-identity.d.ts +20 -2
- package/dist/lib/doctor/fix/process-identity.js +48 -5
- package/dist/lib/flag-registry-worker-source.generated.d.ts +1 -1
- package/dist/lib/flag-registry-worker-source.generated.js +1 -1
- package/dist/lib/hook-engine/canary-gate.js +1 -0
- package/dist/lib/hook-engine/native-stop-compatibility.json +2 -1
- package/dist/lib/hot-channels/adapters/attio.js +2 -1
- package/dist/lib/hot-channels/adapters/meetings.js +2 -1
- package/dist/lib/lanes/account-company.d.ts +7 -1
- package/dist/lib/lanes/account-company.js +22 -4
- package/dist/lib/lanes/account-ownership.d.ts +65 -0
- package/dist/lib/lanes/account-ownership.js +134 -0
- package/dist/lib/lanes/accounts.js +9 -2
- package/dist/lib/lanes/claude-balance.js +9 -3
- package/dist/lib/lanes/company-outposts.d.ts +37 -0
- package/dist/lib/lanes/company-outposts.js +164 -0
- package/dist/lib/lanes/config.js +17 -0
- package/dist/lib/lanes/host-capacity.d.ts +19 -0
- package/dist/lib/lanes/host-capacity.js +37 -0
- package/dist/lib/lanes/liveness.d.ts +6 -0
- package/dist/lib/lanes/liveness.js +49 -8
- package/dist/lib/lanes/orphan-report.d.ts +15 -0
- package/dist/lib/lanes/orphan-report.js +223 -0
- package/dist/lib/lanes/orphan-sweep.d.ts +26 -0
- package/dist/lib/lanes/orphan-sweep.js +152 -0
- package/dist/lib/lanes/reaper.d.ts +2 -0
- package/dist/lib/lanes/reaper.js +11 -8
- package/dist/lib/lanes/reconcile.d.ts +8 -7
- package/dist/lib/lanes/reconcile.js +83 -3
- package/dist/lib/lanes/spawn.d.ts +0 -10
- package/dist/lib/lanes/spawn.js +51 -1
- package/dist/lib/lanes/types.d.ts +12 -0
- package/dist/lib/mesh/live/backfill-held.d.ts +13 -0
- package/dist/lib/mesh/live/backfill-held.js +23 -0
- package/dist/lib/mesh/live/daemon/mode.d.ts +8 -4
- package/dist/lib/mesh/live/daemon/mode.js +8 -4
- package/dist/lib/mesh/live/daemon/run.d.ts +14 -3
- package/dist/lib/mesh/live/daemon/run.js +116 -7
- package/dist/lib/mesh/live/direct-drain.d.ts +123 -0
- package/dist/lib/mesh/live/direct-drain.js +315 -0
- package/dist/lib/mesh/live/emit-replay.d.ts +10 -0
- package/dist/lib/mesh/live/emit-replay.js +10 -0
- package/dist/lib/mesh/live/flush.d.ts +15 -0
- package/dist/lib/mesh/live/flush.js +27 -0
- package/dist/lib/mesh/live/liveness-carry.d.ts +45 -0
- package/dist/lib/mesh/live/liveness-carry.js +141 -0
- package/dist/lib/mesh/live/spool.d.ts +19 -0
- package/dist/lib/mesh/live/spool.js +80 -0
- package/dist/lib/safe-store.d.ts +2 -0
- package/dist/lib/safe-store.js +8 -6
- package/dist/lib/search-index/index.d.ts +9 -3
- package/dist/lib/search-index/index.js +35 -10
- package/dist/lib/search-index/worker-process.d.ts +9 -0
- package/dist/lib/search-index/worker-process.js +171 -0
- package/dist/lib/session-company-lock.d.ts +3 -1
- package/dist/lib/session-company-lock.js +3 -2
- package/dist/utils/delegate-command-supervisor.d.ts +3 -0
- package/dist/utils/delegate-command-supervisor.js +44 -0
- package/dist/utils/delegate-lock.d.ts +12 -0
- package/dist/utils/delegate-lock.js +88 -0
- package/dist/utils/frontmatter.d.ts +27 -0
- package/dist/utils/frontmatter.js +33 -0
- package/dist/utils/hook-trust.d.ts +1 -0
- package/dist/utils/hook-trust.js +18 -2
- package/dist/utils/host-registration.d.ts +13 -1
- package/dist/utils/host-registration.js +98 -5
- package/dist/utils/package-use-lease.d.ts +1 -1
- package/dist/utils/package-use-lease.js +15 -7
- package/docs/anywhere-runtime.md +17 -0
- package/package.json +9 -8
- package/scripts/check-function-manifest.mjs +17 -3
|
@@ -104,6 +104,7 @@ export function canaryRefusal(record, expected) {
|
|
|
104
104
|
return `the last ${host} canary failed`;
|
|
105
105
|
if (result.engineVersion === null)
|
|
106
106
|
return `the last ${host} canary reached no event on the new core`;
|
|
107
|
+
// Preserve metadata: semver precedence equality would accept another source build.
|
|
107
108
|
if (result.engineVersion !== engineVersion) {
|
|
108
109
|
return `the last ${host} canary ran hq-hook ${String(result.engineVersion)}, not ${engineVersion}`;
|
|
109
110
|
}
|
|
@@ -82,7 +82,8 @@
|
|
|
82
82
|
],
|
|
83
83
|
".claude/hooks/lanes-senior-monitor-stop-gate.sh": [
|
|
84
84
|
"c34e55aa10cf2c768943711a6a3cd89a69c7d5947050cb0f4cebb1289b55f671",
|
|
85
|
-
"03d8896cac9756c84f8fb8e5d51af9ee26bac3e6e024795bb0d10c2823c01208"
|
|
85
|
+
"03d8896cac9756c84f8fb8e5d51af9ee26bac3e6e024795bb0d10c2823c01208",
|
|
86
|
+
"1741275eef31d7f656ed618f4c08814ff630b6664f98f18ebdd822b3d2270827"
|
|
86
87
|
],
|
|
87
88
|
".claude/hooks/conduct-lanes-link-deliver.sh": [
|
|
88
89
|
"b1124363238ba405a0efd4bca08b4601430a596614037fbd30bf92b2e6bf8465"
|
|
@@ -82,6 +82,7 @@ import * as fs from "node:fs/promises";
|
|
|
82
82
|
import * as path from "node:path";
|
|
83
83
|
import * as yaml from "js-yaml";
|
|
84
84
|
import { MAX_CATCH_UP_WINDOW_MS } from "../contract.js";
|
|
85
|
+
import { matchFrontmatter } from "../../../utils/frontmatter.js";
|
|
85
86
|
import { eventKey, HOT_SIGNAL_ORIGIN, hotSourceId } from "../landing.js";
|
|
86
87
|
export const ATTIO_ADAPTER_ID = "attio";
|
|
87
88
|
export const ATTIO_CHANNEL = "attio-events";
|
|
@@ -203,7 +204,7 @@ function parseTime(value) {
|
|
|
203
204
|
}
|
|
204
205
|
/** Split `---\n{yaml}\n---\n{body}` and return the frontmatter. Unparseable or non-object is null. */
|
|
205
206
|
function readFrontmatter(text) {
|
|
206
|
-
const match =
|
|
207
|
+
const match = matchFrontmatter(text);
|
|
207
208
|
if (!match)
|
|
208
209
|
return null;
|
|
209
210
|
let parsed;
|
|
@@ -46,6 +46,7 @@ import * as fs from "node:fs/promises";
|
|
|
46
46
|
import * as path from "node:path";
|
|
47
47
|
import * as yaml from "js-yaml";
|
|
48
48
|
import { isAuthError } from "../../../utils/auth-error.js";
|
|
49
|
+
import { matchFrontmatter } from "../../../utils/frontmatter.js";
|
|
49
50
|
import { MAX_CATCH_UP_WINDOW_MS } from "../contract.js";
|
|
50
51
|
import { assertSafeSegment, HOT_SIGNAL_ORIGIN, writeFileAtomic } from "../landing.js";
|
|
51
52
|
import { SyncLockLostError } from "../sync-lock.js";
|
|
@@ -92,7 +93,7 @@ function toVersion(value) {
|
|
|
92
93
|
}
|
|
93
94
|
/** Split `---\n{yaml}\n---\n{body}`. Unparseable or non-object frontmatter is null. */
|
|
94
95
|
function splitFrontmatter(text) {
|
|
95
|
-
const match =
|
|
96
|
+
const match = matchFrontmatter(text);
|
|
96
97
|
if (!match)
|
|
97
98
|
return null;
|
|
98
99
|
let parsed;
|
|
@@ -10,9 +10,15 @@ export declare function companyEnforcementActive(providerAccounts: ProviderAccou
|
|
|
10
10
|
/**
|
|
11
11
|
* Account ownership is explicit; names and homes never imply a tenant.
|
|
12
12
|
* Pass the provider's account map to apply the opt-in rule above.
|
|
13
|
+
* A login whose `holder` names another person never matches (PS-006): the
|
|
14
|
+
* owner's own logins serve any of the owner's businesses, other people's do not.
|
|
13
15
|
*/
|
|
14
16
|
export declare function accountMatchesCompany(account: AccountConfig | undefined, company: LaneCompanyRef | null, providerAccounts?: ProviderAccounts): boolean;
|
|
15
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* Legacy untagged accounts may retain an existing lane, never acquire one.
|
|
19
|
+
* A login held by another person retains nothing (PS-006): the lane moves off
|
|
20
|
+
* it, or is refused, on its next spawn, resume or recovery.
|
|
21
|
+
*/
|
|
16
22
|
export declare function accountMayRetainLane(account: AccountConfig | undefined, company: LaneCompanyRef | null, providerAccounts?: ProviderAccounts): boolean;
|
|
17
23
|
/**
|
|
18
24
|
* When enforcement is active and every enabled candidate was excluded only by
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { accountHeldByOther } from "./account-ownership.js";
|
|
1
2
|
import { LanesError } from "./errors.js";
|
|
2
3
|
/**
|
|
3
4
|
* Company enforcement is opt-in per provider: it begins once any account for
|
|
@@ -12,30 +13,47 @@ export function companyEnforcementActive(providerAccounts) {
|
|
|
12
13
|
/**
|
|
13
14
|
* Account ownership is explicit; names and homes never imply a tenant.
|
|
14
15
|
* Pass the provider's account map to apply the opt-in rule above.
|
|
16
|
+
* A login whose `holder` names another person never matches (PS-006): the
|
|
17
|
+
* owner's own logins serve any of the owner's businesses, other people's do not.
|
|
15
18
|
*/
|
|
16
19
|
export function accountMatchesCompany(account, company, providerAccounts) {
|
|
17
20
|
if (account === undefined)
|
|
18
21
|
return false;
|
|
22
|
+
if (accountHeldByOther(account))
|
|
23
|
+
return false;
|
|
19
24
|
if (providerAccounts !== undefined && !companyEnforcementActive(providerAccounts))
|
|
20
25
|
return true;
|
|
21
26
|
if (company === null)
|
|
22
27
|
return account.company === undefined;
|
|
23
28
|
return account.company === company.uid || account.company === company.slug;
|
|
24
29
|
}
|
|
25
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* Legacy untagged accounts may retain an existing lane, never acquire one.
|
|
32
|
+
* A login held by another person retains nothing (PS-006): the lane moves off
|
|
33
|
+
* it, or is refused, on its next spawn, resume or recovery.
|
|
34
|
+
*/
|
|
26
35
|
export function accountMayRetainLane(account, company, providerAccounts) {
|
|
27
|
-
|
|
36
|
+
if (account === undefined || accountHeldByOther(account))
|
|
37
|
+
return false;
|
|
38
|
+
return account.company === undefined || accountMatchesCompany(account, company, providerAccounts);
|
|
28
39
|
}
|
|
29
40
|
/**
|
|
30
41
|
* When enforcement is active and every enabled candidate was excluded only by
|
|
31
42
|
* company ownership, name the problem instead of reporting no enabled account.
|
|
32
43
|
*/
|
|
33
44
|
export function companyMismatchError(input) {
|
|
34
|
-
if (!companyEnforcementActive(input.providerAccounts))
|
|
35
|
-
return undefined;
|
|
36
45
|
const enabled = input.candidates.filter((id) => input.providerAccounts[id]?.enabled === true);
|
|
37
46
|
if (enabled.length === 0)
|
|
38
47
|
return undefined;
|
|
48
|
+
if (enabled.every((id) => accountHeldByOther(input.providerAccounts[id]))) {
|
|
49
|
+
const held = enabled.map((id) => ({ account: id, holder: input.providerAccounts[id]?.holder ?? null }));
|
|
50
|
+
return new LanesError("account_held_by_other", `Every enabled ${input.provider} account is held by another person and is not used for lanes: ` +
|
|
51
|
+
`${held.map((row) => `${row.account} (${row.holder})`).join(", ")}. ` +
|
|
52
|
+
"Sign in with one of your own logins. Change a holder to owner only if that login is really yours: " +
|
|
53
|
+
`hq lanes accounts set-owner ${input.provider} <id> --holder owner`, { provider: input.provider, held_accounts: held, config_key: `providers.${input.provider}.accounts.<id>.holder`, config_file: "personal/lanes/config.json" });
|
|
54
|
+
}
|
|
55
|
+
if (!companyEnforcementActive(input.providerAccounts))
|
|
56
|
+
return undefined;
|
|
39
57
|
if (enabled.some((id) => accountMatchesCompany(input.providerAccounts[id], input.company, input.providerAccounts)))
|
|
40
58
|
return undefined;
|
|
41
59
|
const companyLabel = input.company === null ? "(no company)" : input.company.slug;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Owning business and holder on every lane account (PS-006).
|
|
3
|
+
*
|
|
4
|
+
* `owning_company` records which business owns a login: a company slug,
|
|
5
|
+
* `personal`, or `unknown`. It is for reporting and ranking. The owner's own
|
|
6
|
+
* logins may be used for any of the owner's businesses (decision D5), so it
|
|
7
|
+
* is never a lane filter; `company` stays the only company filter.
|
|
8
|
+
*
|
|
9
|
+
* `holder` records who holds the login: `owner` for the person this HQ
|
|
10
|
+
* belongs to, or another named person. A login held by another person is
|
|
11
|
+
* never picked for lane work and is listed without its account id when the
|
|
12
|
+
* host's capacity is printed.
|
|
13
|
+
*
|
|
14
|
+
* Accounts written before this change have neither field. They read as
|
|
15
|
+
* `unknown`, keep working as before, and carry a warning naming the command
|
|
16
|
+
* that records both values.
|
|
17
|
+
*/
|
|
18
|
+
import type { AccountConfig, LaneProvider } from "./types.js";
|
|
19
|
+
export declare const OWNER_HOLDER = "owner";
|
|
20
|
+
export declare const PERSONAL_OWNING_COMPANY = "personal";
|
|
21
|
+
export declare const UNKNOWN_OWNING_COMPANY = "unknown";
|
|
22
|
+
export declare const UNKNOWN_HOLDER = "unknown";
|
|
23
|
+
export type OwnershipField = "owning_company" | "holder";
|
|
24
|
+
export interface AccountOwnership {
|
|
25
|
+
/** The configured slug, `personal`, or `unknown`. Falls back to `company` when only that is set. */
|
|
26
|
+
owning_company: string;
|
|
27
|
+
/** Where `owning_company` came from. */
|
|
28
|
+
owning_company_source: "config" | "company" | "unset";
|
|
29
|
+
/** `owner`, another person's name, or `unknown` when unset. */
|
|
30
|
+
holder: string;
|
|
31
|
+
holder_source: "config" | "unset";
|
|
32
|
+
/** Fields with no recorded value. Empty when both are recorded. */
|
|
33
|
+
ownership_missing: OwnershipField[];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Reserved words are matched case-insensitively and stored in lowercase:
|
|
37
|
+
* "Personal" and "UNKNOWN" become `personal` and `unknown`. Any other value is
|
|
38
|
+
* returned unchanged (and then validated as a slug, which must be lowercase).
|
|
39
|
+
*/
|
|
40
|
+
export declare function normalizeOwningCompany<T>(value: T): T | string;
|
|
41
|
+
/** "Owner", "OWNER" and "Unknown" become `owner` and `unknown`; names are kept as given. */
|
|
42
|
+
export declare function normalizeHolder<T>(value: T): T | string;
|
|
43
|
+
/** null when valid, else the reason. Pass the normalized value. */
|
|
44
|
+
export declare function owningCompanyProblem(value: unknown): string | null;
|
|
45
|
+
/** null when valid, else the reason. Pass the normalized value. */
|
|
46
|
+
export declare function holderProblem(value: unknown): string | null;
|
|
47
|
+
export declare function accountOwnership(account: AccountConfig | undefined): AccountOwnership;
|
|
48
|
+
/**
|
|
49
|
+
* True only when the holder is recorded as another person. An unset holder is
|
|
50
|
+
* not "another person": accounts from before PS-006 keep their lane use.
|
|
51
|
+
*/
|
|
52
|
+
export declare function accountHeldByOther(account: AccountConfig | undefined): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* true when the recorded holder is the owner, false when it names another
|
|
55
|
+
* person, null when no holder is recorded or it is recorded as unknown.
|
|
56
|
+
*/
|
|
57
|
+
export declare function heldByOwner(account: AccountConfig | undefined): boolean | null;
|
|
58
|
+
export declare function setOwnerCommand(provider: LaneProvider | string, id: string): string;
|
|
59
|
+
/** Warning for an enabled account missing either field; undefined when nothing is missing. */
|
|
60
|
+
export declare function ownershipWarning(provider: LaneProvider | string, id: string, account: AccountConfig | undefined): {
|
|
61
|
+
message: string;
|
|
62
|
+
missing: OwnershipField[];
|
|
63
|
+
fix_command: string;
|
|
64
|
+
} | undefined;
|
|
65
|
+
//# sourceMappingURL=account-ownership.d.ts.map
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Owning business and holder on every lane account (PS-006).
|
|
3
|
+
*
|
|
4
|
+
* `owning_company` records which business owns a login: a company slug,
|
|
5
|
+
* `personal`, or `unknown`. It is for reporting and ranking. The owner's own
|
|
6
|
+
* logins may be used for any of the owner's businesses (decision D5), so it
|
|
7
|
+
* is never a lane filter; `company` stays the only company filter.
|
|
8
|
+
*
|
|
9
|
+
* `holder` records who holds the login: `owner` for the person this HQ
|
|
10
|
+
* belongs to, or another named person. A login held by another person is
|
|
11
|
+
* never picked for lane work and is listed without its account id when the
|
|
12
|
+
* host's capacity is printed.
|
|
13
|
+
*
|
|
14
|
+
* Accounts written before this change have neither field. They read as
|
|
15
|
+
* `unknown`, keep working as before, and carry a warning naming the command
|
|
16
|
+
* that records both values.
|
|
17
|
+
*/
|
|
18
|
+
export const OWNER_HOLDER = "owner";
|
|
19
|
+
export const PERSONAL_OWNING_COMPANY = "personal";
|
|
20
|
+
export const UNKNOWN_OWNING_COMPANY = "unknown";
|
|
21
|
+
export const UNKNOWN_HOLDER = "unknown";
|
|
22
|
+
const SLUG = /^[a-z0-9][a-z0-9-]{0,62}$/;
|
|
23
|
+
const HOLDER_MAX = 64;
|
|
24
|
+
const RESERVED_OWNING = new Set([PERSONAL_OWNING_COMPANY, UNKNOWN_OWNING_COMPANY]);
|
|
25
|
+
const RESERVED_HOLDER = new Set([OWNER_HOLDER, UNKNOWN_HOLDER]);
|
|
26
|
+
/**
|
|
27
|
+
* Reserved words are matched case-insensitively and stored in lowercase:
|
|
28
|
+
* "Personal" and "UNKNOWN" become `personal` and `unknown`. Any other value is
|
|
29
|
+
* returned unchanged (and then validated as a slug, which must be lowercase).
|
|
30
|
+
*/
|
|
31
|
+
export function normalizeOwningCompany(value) {
|
|
32
|
+
return typeof value === "string" && RESERVED_OWNING.has(value.toLowerCase()) ? value.toLowerCase() : value;
|
|
33
|
+
}
|
|
34
|
+
/** "Owner", "OWNER" and "Unknown" become `owner` and `unknown`; names are kept as given. */
|
|
35
|
+
export function normalizeHolder(value) {
|
|
36
|
+
return typeof value === "string" && RESERVED_HOLDER.has(value.toLowerCase()) ? value.toLowerCase() : value;
|
|
37
|
+
}
|
|
38
|
+
/** null when valid, else the reason. Pass the normalized value. */
|
|
39
|
+
export function owningCompanyProblem(value) {
|
|
40
|
+
if (typeof value !== "string")
|
|
41
|
+
return "must be a string";
|
|
42
|
+
if (!SLUG.test(value))
|
|
43
|
+
return "must be a company slug (lowercase letters, digits, hyphens), personal or unknown";
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Characters a holder name may not contain: C0 and C1 controls, DEL, bidi
|
|
48
|
+
* embeddings, overrides, isolates and marks, and zero-width characters. They
|
|
49
|
+
* can make one name print as another.
|
|
50
|
+
*/
|
|
51
|
+
function forbiddenHolderChar(code) {
|
|
52
|
+
return code < 0x20 ||
|
|
53
|
+
(code >= 0x7f && code <= 0x9f) ||
|
|
54
|
+
code === 0x061c ||
|
|
55
|
+
(code >= 0x200b && code <= 0x200f) ||
|
|
56
|
+
(code >= 0x202a && code <= 0x202e) ||
|
|
57
|
+
(code >= 0x2060 && code <= 0x2069) ||
|
|
58
|
+
code === 0xfeff;
|
|
59
|
+
}
|
|
60
|
+
/** null when valid, else the reason. Pass the normalized value. */
|
|
61
|
+
export function holderProblem(value) {
|
|
62
|
+
if (typeof value !== "string")
|
|
63
|
+
return "must be a string";
|
|
64
|
+
if (value.trim() === "" || value.trim() !== value)
|
|
65
|
+
return "must be non-empty with no surrounding whitespace";
|
|
66
|
+
if (value.length > HOLDER_MAX)
|
|
67
|
+
return `must be at most ${HOLDER_MAX} characters`;
|
|
68
|
+
if ([...value].some((ch) => forbiddenHolderChar(ch.codePointAt(0) ?? 0))) {
|
|
69
|
+
return "must not contain control, bidi or zero-width characters";
|
|
70
|
+
}
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
export function accountOwnership(account) {
|
|
74
|
+
const missing = [];
|
|
75
|
+
let owning;
|
|
76
|
+
let owningSource;
|
|
77
|
+
if (account?.owning_company !== undefined) {
|
|
78
|
+
owning = account.owning_company;
|
|
79
|
+
owningSource = "config";
|
|
80
|
+
}
|
|
81
|
+
else if (account?.company !== undefined && SLUG.test(account.company)) {
|
|
82
|
+
owning = account.company;
|
|
83
|
+
owningSource = "company";
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
owning = UNKNOWN_OWNING_COMPANY;
|
|
87
|
+
owningSource = "unset";
|
|
88
|
+
missing.push("owning_company");
|
|
89
|
+
}
|
|
90
|
+
const holderSet = account?.holder !== undefined;
|
|
91
|
+
if (!holderSet)
|
|
92
|
+
missing.push("holder");
|
|
93
|
+
return {
|
|
94
|
+
owning_company: owning,
|
|
95
|
+
owning_company_source: owningSource,
|
|
96
|
+
holder: holderSet ? account.holder : UNKNOWN_HOLDER,
|
|
97
|
+
holder_source: holderSet ? "config" : "unset",
|
|
98
|
+
ownership_missing: missing,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* True only when the holder is recorded as another person. An unset holder is
|
|
103
|
+
* not "another person": accounts from before PS-006 keep their lane use.
|
|
104
|
+
*/
|
|
105
|
+
export function accountHeldByOther(account) {
|
|
106
|
+
return account?.holder !== undefined && !RESERVED_HOLDER.has(account.holder.toLowerCase());
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* true when the recorded holder is the owner, false when it names another
|
|
110
|
+
* person, null when no holder is recorded or it is recorded as unknown.
|
|
111
|
+
*/
|
|
112
|
+
export function heldByOwner(account) {
|
|
113
|
+
if (account?.holder === undefined || account.holder.toLowerCase() === UNKNOWN_HOLDER)
|
|
114
|
+
return null;
|
|
115
|
+
return !accountHeldByOther(account);
|
|
116
|
+
}
|
|
117
|
+
export function setOwnerCommand(provider, id) {
|
|
118
|
+
return `hq lanes accounts set-owner ${provider} ${id} --owning-company <slug|personal|unknown> --holder <owner|name>`;
|
|
119
|
+
}
|
|
120
|
+
/** Warning for an enabled account missing either field; undefined when nothing is missing. */
|
|
121
|
+
export function ownershipWarning(provider, id, account) {
|
|
122
|
+
if (account?.enabled !== true)
|
|
123
|
+
return undefined;
|
|
124
|
+
const { ownership_missing: missing } = accountOwnership(account);
|
|
125
|
+
if (missing.length === 0)
|
|
126
|
+
return undefined;
|
|
127
|
+
const fix = setOwnerCommand(provider, id);
|
|
128
|
+
return {
|
|
129
|
+
message: `${provider} account ${id} has no ${missing.join(" and no ")}. Set it with: ${fix}`,
|
|
130
|
+
missing,
|
|
131
|
+
fix_command: fix,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=account-ownership.js.map
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import * as fs from "node:fs";
|
|
14
14
|
import { effectiveAccountHome } from "./account-home.js";
|
|
15
|
+
import { accountHeldByOther } from "./account-ownership.js";
|
|
15
16
|
import * as path from "node:path";
|
|
16
17
|
import { AccountResolutionError } from "./errors.js";
|
|
17
18
|
import { isTerminalLaneState } from "./types.js";
|
|
@@ -285,9 +286,15 @@ export function selectBalancedAccount(provider, config, ctx = {}) {
|
|
|
285
286
|
const providerCfg = config.providers[provider];
|
|
286
287
|
const existsSync = ctx.existsSync ?? ((p) => fs.existsSync(p));
|
|
287
288
|
const allowed = ctx.allowedAccounts;
|
|
288
|
-
const
|
|
289
|
+
const allowedEnabled = enabledIds(providerCfg).filter((id) => allowed === undefined || allowed.includes(id));
|
|
290
|
+
// PS-006: a login whose holder is another person is never a balanced pick,
|
|
291
|
+
// whichever caller asks (Outpost pickup and model pre-checks pass no list).
|
|
292
|
+
const enabled = allowedEnabled.filter((id) => !accountHeldByOther(providerCfg.accounts[id]));
|
|
289
293
|
if (enabled.length === 0) {
|
|
290
|
-
|
|
294
|
+
const held = allowedEnabled.length > 0;
|
|
295
|
+
throw new AccountResolutionError("no_enabled_account", held
|
|
296
|
+
? `Every enabled account for provider ${provider} is held by another person and is not used for lanes`
|
|
297
|
+
: `No enabled account for provider ${provider}`, { provider, ineligible: held ? "held_by_other" : "none_enabled" });
|
|
291
298
|
}
|
|
292
299
|
const proven = [];
|
|
293
300
|
const identities = new Map();
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { LanesError } from "./errors.js";
|
|
2
2
|
import { accountMatchesCompany, accountMayRetainLane } from "./account-company.js";
|
|
3
|
+
import { accountHeldByOther } from "./account-ownership.js";
|
|
3
4
|
import { quotaBlockFor } from "./quota.js";
|
|
4
5
|
export const BALANCE_LIVE_STATES = ["running", "queued", "awaiting_input"];
|
|
5
6
|
export const BALANCE_MOVABLE_STATES = ["interrupted", "done", "awaiting_input"];
|
|
@@ -138,7 +139,8 @@ function buildLoads(input) {
|
|
|
138
139
|
const companyMismatch = input.company !== undefined && !(account === input.retainedAccount
|
|
139
140
|
? accountMayRetainLane(configAccounts[account], input.company, configAccounts)
|
|
140
141
|
: accountMatchesCompany(configAccounts[account], input.company, configAccounts));
|
|
141
|
-
|
|
142
|
+
// PS-006: another person's login is never eligible, with or without a lane company.
|
|
143
|
+
const ineligible = accountHeldByOther(configAccounts[account]) ? "held_by_other" : companyMismatch ? "company_mismatch" : targetIneligibilityReason(account, configAccounts[account]?.enabled === true, input.allowedAccounts, targetLoad) ?? (quotaBlock?.blocked === true ? "quota_held" : undefined);
|
|
142
144
|
if (ineligible !== undefined)
|
|
143
145
|
skipped.push({ account, host: targetHost, reason: ineligible });
|
|
144
146
|
const knownCounts = hosts.flatMap((host) => host.live_lanes === null ? [] : [host.live_lanes]);
|
|
@@ -286,7 +288,11 @@ export function planClaudeBalanceMoves(input) {
|
|
|
286
288
|
if (!hostSnapshot)
|
|
287
289
|
continue;
|
|
288
290
|
const sourceStatus = hostSnapshot.capacity.providers.claude.accounts[source];
|
|
289
|
-
|
|
291
|
+
// PS-006: buildHostCapacitySnapshot leaves another person's login out of
|
|
292
|
+
// `accounts`, so a missing row must not hide it; such a source is always
|
|
293
|
+
// unavailable and its lanes are moved off.
|
|
294
|
+
const sourceHeldByOther = accountHeldByOther(input.config.providers.claude.accounts[source]);
|
|
295
|
+
if (sourceStatus === undefined && !sourceHeldByOther)
|
|
290
296
|
continue;
|
|
291
297
|
const candidates = Object.keys(input.config.providers.claude.accounts)
|
|
292
298
|
.filter((account) => accountMatchesCompany(input.config.providers.claude.accounts[account], input.laneCompany ? input.laneCompany(lane) : lane.company, input.config.providers.claude.accounts))
|
|
@@ -298,7 +304,7 @@ export function planClaudeBalanceMoves(input) {
|
|
|
298
304
|
}))
|
|
299
305
|
.filter((candidate) => candidate.targetStatus?.enabled === true && candidate.targetStatus.logged_in === true)
|
|
300
306
|
.sort((a, b) => a.load - b.load || a.account.localeCompare(b.account));
|
|
301
|
-
const sourceUnavailable = sourceStatus
|
|
307
|
+
const sourceUnavailable = sourceHeldByOther || sourceStatus?.enabled !== true || sourceStatus.logged_in !== true;
|
|
302
308
|
const target = candidates[0];
|
|
303
309
|
const laneIsLive = isBalanceLive(lane);
|
|
304
310
|
if (!target || (!sourceUnavailable && (!laneIsLive || target.load >= sourceLoad)))
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type OutpostsClient } from "@indigoai-us/hq-cloud/outposts";
|
|
2
|
+
import { LanesError } from "./errors.js";
|
|
3
|
+
import type { OutpostExecPort } from "./outpost-dispatch.js";
|
|
4
|
+
import type { LaneCompanyRef } from "./types.js";
|
|
5
|
+
type CompanyIdentity = {
|
|
6
|
+
uid: string;
|
|
7
|
+
slug?: string;
|
|
8
|
+
};
|
|
9
|
+
export interface CompanyOutpostCandidate {
|
|
10
|
+
outpostId: string;
|
|
11
|
+
lifecycle?: string;
|
|
12
|
+
canUse?: boolean;
|
|
13
|
+
lanesReady?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export type CompanyOutpostListPort = Pick<OutpostsClient, "request">;
|
|
16
|
+
export type CompanyOutpostExecClient = Pick<OutpostsClient, "stageExecInput" | "submitExec" | "waitForExecResult">;
|
|
17
|
+
export declare function isCompanyOutpostId(id: string): boolean;
|
|
18
|
+
export declare function companyUidOfFirstOutpostId(id: string): string | undefined;
|
|
19
|
+
export declare function companyOutpostAccessRequired(outpostId: string, company: CompanyIdentity): LanesError;
|
|
20
|
+
export declare function companyOutpostRefusal(err: unknown, outpostId: string, company: CompanyIdentity): LanesError | undefined;
|
|
21
|
+
export declare function isCompanyOutpostRefusal(err: unknown): err is LanesError;
|
|
22
|
+
export declare function assertCompanyOutpostBelongsTo(outpostId: string, company: LaneCompanyRef): void;
|
|
23
|
+
export declare function companyOutpostNeedsCompany(outpostId: string): LanesError;
|
|
24
|
+
export declare function isNoCompanyOutposts(err: unknown): boolean;
|
|
25
|
+
export declare class CompanyOutpostTargets {
|
|
26
|
+
private readonly lookupRecordedCompany;
|
|
27
|
+
private readonly companies;
|
|
28
|
+
constructor(lookupRecordedCompany?: (outpostId: string) => LaneCompanyRef | undefined);
|
|
29
|
+
remember(company: LaneCompanyRef, outpostIds: readonly string[]): void;
|
|
30
|
+
companyOf(outpostId: string): CompanyIdentity | undefined;
|
|
31
|
+
}
|
|
32
|
+
export declare function listCompanyOutpostCandidates(port: CompanyOutpostListPort, company: LaneCompanyRef): Promise<CompanyOutpostCandidate[]>;
|
|
33
|
+
export declare function readyCompanyOutpostIds(candidates: readonly CompanyOutpostCandidate[]): string[];
|
|
34
|
+
export declare function companyOutpostNotLaneReady(outpostId: string, company: CompanyIdentity): LanesError;
|
|
35
|
+
export declare function companyAwareExecPort(client: CompanyOutpostExecClient, targets: CompanyOutpostTargets): OutpostExecPort;
|
|
36
|
+
export {};
|
|
37
|
+
//# sourceMappingURL=company-outposts.d.ts.map
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { OutpostHttpError } from "@indigoai-us/hq-cloud/outposts";
|
|
2
|
+
import { LanesError } from "./errors.js";
|
|
3
|
+
const COMPANY_OUTPOST_ID = /^(?:opc_[0-9A-HJKMNP-TV-Z]{26}|outpost_cmp_[A-Za-z0-9]+)$/;
|
|
4
|
+
const FIRST_COMPANY_OUTPOST_PREFIX = "outpost_";
|
|
5
|
+
const NO_COMPANY_OUTPOSTS_CODES = new Set(["feature_disabled", "forbidden", "admin_required", "not_found"]);
|
|
6
|
+
const LIFECYCLE = /^[a-z_]{1,32}$/;
|
|
7
|
+
export function isCompanyOutpostId(id) {
|
|
8
|
+
return COMPANY_OUTPOST_ID.test(id);
|
|
9
|
+
}
|
|
10
|
+
export function companyUidOfFirstOutpostId(id) {
|
|
11
|
+
if (!isCompanyOutpostId(id) || !id.startsWith(FIRST_COMPANY_OUTPOST_PREFIX))
|
|
12
|
+
return undefined;
|
|
13
|
+
return id.slice(FIRST_COMPANY_OUTPOST_PREFIX.length);
|
|
14
|
+
}
|
|
15
|
+
function companyDetails(outpostId, company) {
|
|
16
|
+
return {
|
|
17
|
+
outpost_id: outpostId,
|
|
18
|
+
company_uid: company.uid,
|
|
19
|
+
...(company.slug ? { company: company.slug } : {}),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export function companyOutpostAccessRequired(outpostId, company) {
|
|
23
|
+
const label = company.slug ? `${company.slug}'s Outpost ${outpostId}` : `company Outpost ${outpostId}`;
|
|
24
|
+
const approvers = company.slug ? `An owner or admin of ${company.slug}` : "An owner or admin of the company";
|
|
25
|
+
const slug = company.slug ?? "<slug>";
|
|
26
|
+
const requestAccess = `hq outposts request-access --company ${slug} --outpost ${outpostId}`;
|
|
27
|
+
const requestOutpost = `hq outposts request --company ${slug}`;
|
|
28
|
+
return new LanesError("company_outpost_access_required", `You are not approved to use ${label}. Next: ${requestAccess} (or ${requestOutpost} for an Outpost of your own). ${approvers} approves the request once; access lasts until they revoke it.`, {
|
|
29
|
+
...companyDetails(outpostId, company),
|
|
30
|
+
request_access_command: requestAccess,
|
|
31
|
+
request_outpost_command: requestOutpost,
|
|
32
|
+
request_access: { method: "POST", path: "/outpost/status", body: { companyUid: company.uid, action: "request-access", outpostId } },
|
|
33
|
+
request_outpost: { method: "POST", path: "/outpost/status", body: { companyUid: company.uid, action: "request-outpost" } },
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
export function companyOutpostRefusal(err, outpostId, company) {
|
|
37
|
+
if (!(err instanceof OutpostHttpError))
|
|
38
|
+
return undefined;
|
|
39
|
+
const details = { ...companyDetails(outpostId, company), status: err.status };
|
|
40
|
+
const name = company.slug ?? "the company";
|
|
41
|
+
const slugArg = company.slug ?? "<slug>";
|
|
42
|
+
switch (err.code) {
|
|
43
|
+
case "grant_required":
|
|
44
|
+
return companyOutpostAccessRequired(outpostId, company);
|
|
45
|
+
case "forbidden":
|
|
46
|
+
case "admin_required":
|
|
47
|
+
return new LanesError("company_outpost_not_a_member", `Only current members of ${name} can use its Outpost ${outpostId}.`, details);
|
|
48
|
+
case "not_found":
|
|
49
|
+
return new LanesError("company_outpost_not_found", `${name} has no Outpost ${outpostId}. Run: hq outposts list --company ${slugArg}`, details);
|
|
50
|
+
case "not_ready":
|
|
51
|
+
return new LanesError("company_outpost_not_ready", `Outpost ${outpostId} of ${name} is not running yet. Check it with: hq outposts status --company ${slugArg} --outpost ${outpostId}`, details);
|
|
52
|
+
case "feature_disabled":
|
|
53
|
+
return new LanesError("company_outposts_unavailable", `Company Outposts are not available for ${name} right now. Try again later.`, details);
|
|
54
|
+
default:
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const COMPANY_OUTPOST_REFUSALS = new Set([
|
|
59
|
+
"company_outpost_access_required",
|
|
60
|
+
"company_outpost_not_a_member",
|
|
61
|
+
"company_outpost_not_found",
|
|
62
|
+
"company_outpost_not_ready",
|
|
63
|
+
"company_outposts_unavailable",
|
|
64
|
+
]);
|
|
65
|
+
export function isCompanyOutpostRefusal(err) {
|
|
66
|
+
return err instanceof LanesError && COMPANY_OUTPOST_REFUSALS.has(err.error);
|
|
67
|
+
}
|
|
68
|
+
export function assertCompanyOutpostBelongsTo(outpostId, company) {
|
|
69
|
+
const owner = companyUidOfFirstOutpostId(outpostId);
|
|
70
|
+
if (owner !== undefined && owner !== company.uid) {
|
|
71
|
+
throw new LanesError("company_outpost_wrong_company", `Outpost ${outpostId} does not belong to ${company.slug}. A lane can only run on an Outpost of its own company.`, { outpost_id: outpostId, company: company.slug });
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
export function companyOutpostNeedsCompany(outpostId) {
|
|
75
|
+
return new LanesError("company_outpost_requires_company", `Outpost ${outpostId} is a company Outpost. Pass --company <slug> for the company that owns it.`, { outpost_id: outpostId });
|
|
76
|
+
}
|
|
77
|
+
export function isNoCompanyOutposts(err) {
|
|
78
|
+
return (err instanceof OutpostHttpError &&
|
|
79
|
+
err.code !== undefined &&
|
|
80
|
+
NO_COMPANY_OUTPOSTS_CODES.has(err.code));
|
|
81
|
+
}
|
|
82
|
+
export class CompanyOutpostTargets {
|
|
83
|
+
lookupRecordedCompany;
|
|
84
|
+
companies = new Map();
|
|
85
|
+
constructor(lookupRecordedCompany = () => undefined) {
|
|
86
|
+
this.lookupRecordedCompany = lookupRecordedCompany;
|
|
87
|
+
}
|
|
88
|
+
remember(company, outpostIds) {
|
|
89
|
+
for (const id of outpostIds) {
|
|
90
|
+
if (isCompanyOutpostId(id))
|
|
91
|
+
this.companies.set(id, { uid: company.uid, slug: company.slug });
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
companyOf(outpostId) {
|
|
95
|
+
if (!isCompanyOutpostId(outpostId))
|
|
96
|
+
return undefined;
|
|
97
|
+
const remembered = this.companies.get(outpostId);
|
|
98
|
+
if (remembered)
|
|
99
|
+
return remembered;
|
|
100
|
+
const recorded = this.lookupRecordedCompany(outpostId);
|
|
101
|
+
const firstOutpostCompany = companyUidOfFirstOutpostId(outpostId);
|
|
102
|
+
if (recorded && (firstOutpostCompany === undefined || firstOutpostCompany === recorded.uid)) {
|
|
103
|
+
return { uid: recorded.uid, slug: recorded.slug };
|
|
104
|
+
}
|
|
105
|
+
if (firstOutpostCompany !== undefined)
|
|
106
|
+
return { uid: firstOutpostCompany };
|
|
107
|
+
throw companyOutpostNeedsCompany(outpostId);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
export async function listCompanyOutpostCandidates(port, company) {
|
|
111
|
+
const body = await port.request({
|
|
112
|
+
path: "/outpost/status",
|
|
113
|
+
query: { companyUid: company.uid, list: "true" },
|
|
114
|
+
});
|
|
115
|
+
const rows = Array.isArray(body?.outposts) ? body.outposts : [];
|
|
116
|
+
const candidates = [];
|
|
117
|
+
for (const raw of rows) {
|
|
118
|
+
if (!raw || typeof raw !== "object")
|
|
119
|
+
continue;
|
|
120
|
+
const row = raw;
|
|
121
|
+
if (typeof row.outpostId !== "string" || !isCompanyOutpostId(row.outpostId))
|
|
122
|
+
continue;
|
|
123
|
+
const owner = companyUidOfFirstOutpostId(row.outpostId);
|
|
124
|
+
if (owner !== undefined && owner !== company.uid)
|
|
125
|
+
continue;
|
|
126
|
+
candidates.push({
|
|
127
|
+
outpostId: row.outpostId,
|
|
128
|
+
...(typeof row.lifecycle === "string" && LIFECYCLE.test(row.lifecycle) ? { lifecycle: row.lifecycle } : {}),
|
|
129
|
+
...(typeof row.canUse === "boolean" ? { canUse: row.canUse } : {}),
|
|
130
|
+
...(typeof row.lanesReady === "boolean" ? { lanesReady: row.lanesReady } : {}),
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
return candidates;
|
|
134
|
+
}
|
|
135
|
+
export function readyCompanyOutpostIds(candidates) {
|
|
136
|
+
return candidates
|
|
137
|
+
.filter((row) => (row.lifecycle === undefined || row.lifecycle === "ready") && row.canUse !== false && row.lanesReady === true)
|
|
138
|
+
.map((row) => row.outpostId);
|
|
139
|
+
}
|
|
140
|
+
export function companyOutpostNotLaneReady(outpostId, company) {
|
|
141
|
+
const label = company.slug ? `${company.slug}'s Outpost ${outpostId}` : `Company Outpost ${outpostId}`;
|
|
142
|
+
return new LanesError("company_outpost_not_lane_ready", `${label} is not set up for lanes yet. Nothing was dispatched. Next: run the lane on a personal Outpost or this host for now.`, companyDetails(outpostId, company));
|
|
143
|
+
}
|
|
144
|
+
export function companyAwareExecPort(client, targets) {
|
|
145
|
+
const guarded = async (outpostId, call) => {
|
|
146
|
+
if (outpostId === undefined)
|
|
147
|
+
return call(undefined);
|
|
148
|
+
const company = targets.companyOf(outpostId);
|
|
149
|
+
if (!company)
|
|
150
|
+
return call(outpostId);
|
|
151
|
+
try {
|
|
152
|
+
return await call({ companyUid: company.uid, outpostId });
|
|
153
|
+
}
|
|
154
|
+
catch (err) {
|
|
155
|
+
throw companyOutpostRefusal(err, outpostId, company) ?? err;
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
return {
|
|
159
|
+
stageExecInput: (outpostId) => guarded(outpostId, (target) => client.stageExecInput(target)),
|
|
160
|
+
submitExec: (command, outpostId, timeoutSeconds) => guarded(outpostId, (target) => client.submitExec(command, target, timeoutSeconds)),
|
|
161
|
+
waitForExecResult: (commandId, outpostId, options) => guarded(outpostId, (target) => client.waitForExecResult(commandId, target, options)),
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
//# sourceMappingURL=company-outposts.js.map
|
package/dist/lib/lanes/config.js
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
import * as fs from "node:fs";
|
|
10
10
|
import * as os from "node:os";
|
|
11
11
|
import * as path from "node:path";
|
|
12
|
+
import { holderProblem, normalizeHolder, normalizeOwningCompany, owningCompanyProblem } from "./account-ownership.js";
|
|
12
13
|
import { parseConfigEffort } from "./effort.js";
|
|
13
14
|
import { LanesConfigError } from "./errors.js";
|
|
14
15
|
import { CONFIG_SCHEMA_VERSION, LANE_PROVIDERS, isLaneProvider, parseMajorSchema, } from "./types.js";
|
|
@@ -200,6 +201,22 @@ function parseAccount(provider, id, raw, deps) {
|
|
|
200
201
|
}
|
|
201
202
|
account.company = raw.company;
|
|
202
203
|
}
|
|
204
|
+
if (raw.owning_company !== undefined) {
|
|
205
|
+
raw.owning_company = normalizeOwningCompany(raw.owning_company);
|
|
206
|
+
const problem = owningCompanyProblem(raw.owning_company);
|
|
207
|
+
if (problem !== null) {
|
|
208
|
+
throw new LanesConfigError("invalid_config", `providers.${provider}.accounts.${id}.owning_company ${problem}`, { provider, account: id, field: `providers.${provider}.accounts.${id}.owning_company` });
|
|
209
|
+
}
|
|
210
|
+
account.owning_company = raw.owning_company;
|
|
211
|
+
}
|
|
212
|
+
if (raw.holder !== undefined) {
|
|
213
|
+
raw.holder = normalizeHolder(raw.holder);
|
|
214
|
+
const problem = holderProblem(raw.holder);
|
|
215
|
+
if (problem !== null) {
|
|
216
|
+
throw new LanesConfigError("invalid_config", `providers.${provider}.accounts.${id}.holder ${problem}`, { provider, account: id, field: `providers.${provider}.accounts.${id}.holder` });
|
|
217
|
+
}
|
|
218
|
+
account.holder = raw.holder;
|
|
219
|
+
}
|
|
203
220
|
if (raw.hosts !== undefined) {
|
|
204
221
|
const field = `providers.${provider}.accounts.${id}.hosts`;
|
|
205
222
|
if (!isPlainObject(raw.hosts)) {
|