@pleri/olam-cli 0.1.147 → 0.1.148
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/dist/commands/auth.d.ts.map +1 -1
- package/dist/commands/auth.js +26 -1
- package/dist/commands/auth.js.map +1 -1
- package/dist/commands/doctor.d.ts +31 -3
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +274 -6
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/services.d.ts +41 -3
- package/dist/commands/services.d.ts.map +1 -1
- package/dist/commands/services.js +221 -13
- package/dist/commands/services.js.map +1 -1
- package/dist/commands/substrate-audit-log.d.ts +2 -0
- package/dist/commands/substrate-audit-log.d.ts.map +1 -1
- package/dist/commands/substrate-audit-log.js +13 -0
- package/dist/commands/substrate-audit-log.js.map +1 -1
- package/dist/image-digests.json +7 -7
- package/dist/index.js +3381 -2560
- package/dist/lib/auth-refresh-kubernetes.d.ts +62 -0
- package/dist/lib/auth-refresh-kubernetes.d.ts.map +1 -0
- package/dist/lib/auth-refresh-kubernetes.js +127 -0
- package/dist/lib/auth-refresh-kubernetes.js.map +1 -0
- package/dist/lib/kubectl-wrap.d.ts +6 -0
- package/dist/lib/kubectl-wrap.d.ts.map +1 -1
- package/dist/lib/kubectl-wrap.js +6 -1
- package/dist/lib/kubectl-wrap.js.map +1 -1
- package/dist/lib/manifest-refresh.d.ts +8 -1
- package/dist/lib/manifest-refresh.d.ts.map +1 -1
- package/dist/lib/manifest-refresh.js +17 -7
- package/dist/lib/manifest-refresh.js.map +1 -1
- package/dist/lib/peripheral-registry.d.ts +36 -0
- package/dist/lib/peripheral-registry.d.ts.map +1 -0
- package/dist/lib/peripheral-registry.js +55 -0
- package/dist/lib/peripheral-registry.js.map +1 -0
- package/dist/lib/port-forward.d.ts +67 -0
- package/dist/lib/port-forward.d.ts.map +1 -1
- package/dist/lib/port-forward.js +153 -0
- package/dist/lib/port-forward.js.map +1 -1
- package/dist/lib/upgrade-kubernetes.d.ts +35 -11
- package/dist/lib/upgrade-kubernetes.d.ts.map +1 -1
- package/dist/lib/upgrade-kubernetes.js +265 -21
- package/dist/lib/upgrade-kubernetes.js.map +1 -1
- package/host-cp/k8s/manifests/auth-service/10-serviceaccount.yaml +8 -0
- package/host-cp/k8s/manifests/auth-service/20-rbac.yaml +34 -0
- package/host-cp/k8s/manifests/auth-service/30-configmap.yaml +24 -0
- package/host-cp/k8s/manifests/auth-service/45-pvc.yaml +25 -0
- package/host-cp/k8s/manifests/auth-service/50-deployment.yaml +114 -0
- package/host-cp/k8s/manifests/auth-service/60-service.yaml +21 -0
- package/host-cp/k8s/manifests/kg-service/10-serviceaccount.yaml +8 -0
- package/host-cp/k8s/manifests/kg-service/20-rbac.yaml +34 -0
- package/host-cp/k8s/manifests/kg-service/30-configmap.yaml +18 -0
- package/host-cp/k8s/manifests/kg-service/45-pvc.yaml +25 -0
- package/host-cp/k8s/manifests/kg-service/50-deployment.yaml +108 -0
- package/host-cp/k8s/manifests/kg-service/60-service.yaml +21 -0
- package/host-cp/k8s/manifests/mcp-auth-service/10-serviceaccount.yaml +8 -0
- package/host-cp/k8s/manifests/mcp-auth-service/20-rbac.yaml +34 -0
- package/host-cp/k8s/manifests/mcp-auth-service/30-configmap.yaml +18 -0
- package/host-cp/k8s/manifests/mcp-auth-service/45-pvc.yaml +25 -0
- package/host-cp/k8s/manifests/mcp-auth-service/50-deployment.yaml +114 -0
- package/host-cp/k8s/manifests/mcp-auth-service/60-service.yaml +21 -0
- package/host-cp/k8s/manifests/memory-service/10-serviceaccount.yaml +8 -0
- package/host-cp/k8s/manifests/memory-service/20-rbac.yaml +34 -0
- package/host-cp/k8s/manifests/memory-service/30-configmap.yaml +20 -0
- package/host-cp/k8s/manifests/memory-service/45-pvc.yaml +25 -0
- package/host-cp/k8s/manifests/memory-service/50-deployment.yaml +116 -0
- package/host-cp/k8s/manifests/memory-service/60-service.yaml +21 -0
- package/host-cp/k8s/templates/auth-service-secret-template.yaml +28 -0
- package/host-cp/k8s/templates/kg-service-secret-template.yaml +28 -0
- package/host-cp/k8s/templates/mcp-auth-service-secret-template.yaml +28 -0
- package/host-cp/k8s/templates/memory-service-secret-template.yaml +29 -0
- package/host-cp/src/plan-chat-service.mjs +22 -3
- package/host-cp/src/server.mjs +4 -4
- package/package.json +1 -1
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* auth-refresh-kubernetes.ts — D4 kubernetes Secret rotation for `olam auth refresh`.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from auth.ts to keep the testable logic free of @olam/core dependencies.
|
|
5
|
+
* No @olam/core imports here — tested directly by auth.test.ts without needing
|
|
6
|
+
* to mock the entire @olam/core workspace package.
|
|
7
|
+
*
|
|
8
|
+
* D20 security invariant: secret value NEVER in subprocess argv (–from-literal forbidden).
|
|
9
|
+
* SEC-NEW-003: refuses when kubectl_context_pinned absent (no ambient KUBECONFIG fallthrough).
|
|
10
|
+
* ADV-N-003: kubectl rollout restart after apply (K8s does NOT hot-update mounted Secrets).
|
|
11
|
+
*/
|
|
12
|
+
import { kubectlWrap } from './kubectl-wrap.js';
|
|
13
|
+
export interface AuthRefreshKubernetesDeps {
|
|
14
|
+
/** Injectable kubectlWrap for tests (Secret apply + rollout restart). */
|
|
15
|
+
readonly kubectlWrapImpl?: typeof kubectlWrap;
|
|
16
|
+
/** Injectable readFileSync for reading ~/.olam/auth-secret. */
|
|
17
|
+
readonly readFileSyncImpl?: (p: string, enc: 'utf8') => string;
|
|
18
|
+
/** Injectable writeFileSync for writing ~/.olam/auth-secret. */
|
|
19
|
+
readonly writeFileSyncImpl?: (p: string, data: string, opts: {
|
|
20
|
+
mode: number;
|
|
21
|
+
}) => void;
|
|
22
|
+
/** Injectable config path for readConfig. */
|
|
23
|
+
readonly configPath?: string;
|
|
24
|
+
/** Injectable olam home override (for auth-secret path). */
|
|
25
|
+
readonly olamHomeOverride?: string;
|
|
26
|
+
/** Injectable stdout. */
|
|
27
|
+
readonly stdout?: NodeJS.WritableStream;
|
|
28
|
+
/** Injectable stderr. */
|
|
29
|
+
readonly stderr?: NodeJS.WritableStream;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Construct the olam-host-cp-secret YAML in-process (D20 stdin-safe design).
|
|
33
|
+
* Values are base64-encoded via Buffer. NEVER uses --from-literal in subprocess argv.
|
|
34
|
+
*/
|
|
35
|
+
export declare function buildSecretYaml(secretName: string, data: Record<string, string>): string;
|
|
36
|
+
/**
|
|
37
|
+
* Resolve the pinned kubectl context from config or OLAM_K8S_CONTEXT_ACK fallback.
|
|
38
|
+
*
|
|
39
|
+
* Returns { context } on success.
|
|
40
|
+
* Returns { error } when neither source has a context (SEC-NEW-003 enforcement).
|
|
41
|
+
* Returns { context, deprecationWarning } when OLAM_K8S_CONTEXT_ACK fallback is used.
|
|
42
|
+
*/
|
|
43
|
+
export declare function resolveKubectlContext(configPath?: string): {
|
|
44
|
+
context?: string;
|
|
45
|
+
deprecationWarning?: string;
|
|
46
|
+
error?: string;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Run the kubernetes-substrate portion of auth refresh (D4).
|
|
50
|
+
*
|
|
51
|
+
* Called by auth.ts after a successful `client.refreshAccount()` when
|
|
52
|
+
* the substrate is kubernetes. Performs:
|
|
53
|
+
* 1. Reads ~/.olam/auth-secret for the bearer secret value.
|
|
54
|
+
* 2. Writes ~/.olam/auth-secret back (idempotent, sets mode 0o600).
|
|
55
|
+
* 3. Constructs olam-host-cp-secret YAML in-process (D20: value in stdin, not argv).
|
|
56
|
+
* 4. kubectl apply -f - via stdin pipe.
|
|
57
|
+
* 5. kubectl rollout restart deployment/olam-host-cp -n olam (ADV-N-003).
|
|
58
|
+
*
|
|
59
|
+
* Returns exit code: 0 = success, 1 = error.
|
|
60
|
+
*/
|
|
61
|
+
export declare function applyK8sAuthRefresh(pinnedContext: string, deps?: AuthRefreshKubernetesDeps): Promise<number>;
|
|
62
|
+
//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AM,CAAC;CAChB,CAqBA;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,mBAAmB,CACvC,aAAa,EAAE,MAAM,EACrB,IAAI,GAAE,yBAA8B,GACnC,OAAO,CAAC,MAAM,CAAC,CAoEjB"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* auth-refresh-kubernetes.ts — D4 kubernetes Secret rotation for `olam auth refresh`.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from auth.ts to keep the testable logic free of @olam/core dependencies.
|
|
5
|
+
* No @olam/core imports here — tested directly by auth.test.ts without needing
|
|
6
|
+
* to mock the entire @olam/core workspace package.
|
|
7
|
+
*
|
|
8
|
+
* D20 security invariant: secret value NEVER in subprocess argv (–from-literal forbidden).
|
|
9
|
+
* SEC-NEW-003: refuses when kubectl_context_pinned absent (no ambient KUBECONFIG fallthrough).
|
|
10
|
+
* ADV-N-003: kubectl rollout restart after apply (K8s does NOT hot-update mounted Secrets).
|
|
11
|
+
*/
|
|
12
|
+
import * as fs from 'node:fs';
|
|
13
|
+
import * as path from 'node:path';
|
|
14
|
+
import pc from 'picocolors';
|
|
15
|
+
import { stringify as yamlStringify } from 'yaml';
|
|
16
|
+
import { readConfig, OLAM_HOME } from './config.js';
|
|
17
|
+
import { kubectlWrap } from './kubectl-wrap.js';
|
|
18
|
+
import { HOST_CP_SECRET_NAME, HOST_CP_DEPLOYMENT_NAME } from './upgrade-kubernetes.js';
|
|
19
|
+
const K8S_NAMESPACE = 'olam';
|
|
20
|
+
/**
|
|
21
|
+
* Construct the olam-host-cp-secret YAML in-process (D20 stdin-safe design).
|
|
22
|
+
* Values are base64-encoded via Buffer. NEVER uses --from-literal in subprocess argv.
|
|
23
|
+
*/
|
|
24
|
+
export function buildSecretYaml(secretName, data) {
|
|
25
|
+
const base64Data = {};
|
|
26
|
+
for (const [key, value] of Object.entries(data)) {
|
|
27
|
+
base64Data[key] = Buffer.from(value).toString('base64');
|
|
28
|
+
}
|
|
29
|
+
return yamlStringify({
|
|
30
|
+
apiVersion: 'v1',
|
|
31
|
+
kind: 'Secret',
|
|
32
|
+
metadata: { name: secretName, namespace: K8S_NAMESPACE },
|
|
33
|
+
type: 'Opaque',
|
|
34
|
+
data: base64Data,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Resolve the pinned kubectl context from config or OLAM_K8S_CONTEXT_ACK fallback.
|
|
39
|
+
*
|
|
40
|
+
* Returns { context } on success.
|
|
41
|
+
* Returns { error } when neither source has a context (SEC-NEW-003 enforcement).
|
|
42
|
+
* Returns { context, deprecationWarning } when OLAM_K8S_CONTEXT_ACK fallback is used.
|
|
43
|
+
*/
|
|
44
|
+
export function resolveKubectlContext(configPath) {
|
|
45
|
+
const cfg = readConfig({ configPath });
|
|
46
|
+
const raw = cfg.host['kubectl_context_pinned'];
|
|
47
|
+
if (typeof raw === 'string' && raw.length > 0) {
|
|
48
|
+
return { context: raw };
|
|
49
|
+
}
|
|
50
|
+
const ack = process.env['OLAM_K8S_CONTEXT_ACK'];
|
|
51
|
+
if (typeof ack === 'string' && ack.length > 0) {
|
|
52
|
+
return {
|
|
53
|
+
context: ack,
|
|
54
|
+
deprecationWarning: 'OLAM_K8S_CONTEXT_ACK is deprecated; set host.kubectl_context_pinned in ~/.olam/config.json',
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
error: 'kubectl_context_pinned is not set in ~/.olam/config.json and OLAM_K8S_CONTEXT_ACK is not set.\n' +
|
|
59
|
+
' Set host.kubectl_context_pinned in ~/.olam/config.json to your kubectl context name.',
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Run the kubernetes-substrate portion of auth refresh (D4).
|
|
64
|
+
*
|
|
65
|
+
* Called by auth.ts after a successful `client.refreshAccount()` when
|
|
66
|
+
* the substrate is kubernetes. Performs:
|
|
67
|
+
* 1. Reads ~/.olam/auth-secret for the bearer secret value.
|
|
68
|
+
* 2. Writes ~/.olam/auth-secret back (idempotent, sets mode 0o600).
|
|
69
|
+
* 3. Constructs olam-host-cp-secret YAML in-process (D20: value in stdin, not argv).
|
|
70
|
+
* 4. kubectl apply -f - via stdin pipe.
|
|
71
|
+
* 5. kubectl rollout restart deployment/olam-host-cp -n olam (ADV-N-003).
|
|
72
|
+
*
|
|
73
|
+
* Returns exit code: 0 = success, 1 = error.
|
|
74
|
+
*/
|
|
75
|
+
export async function applyK8sAuthRefresh(pinnedContext, deps = {}) {
|
|
76
|
+
const stdout = deps.stdout ?? process.stdout;
|
|
77
|
+
const stderr = deps.stderr ?? process.stderr;
|
|
78
|
+
const olamHome = deps.olamHomeOverride ?? OLAM_HOME;
|
|
79
|
+
const authSecretFile = path.join(olamHome, 'auth-secret');
|
|
80
|
+
const readFn = deps.readFileSyncImpl ?? ((p, enc) => fs.readFileSync(p, enc));
|
|
81
|
+
const writeFn = deps.writeFileSyncImpl ?? ((p, data, opts) => {
|
|
82
|
+
fs.mkdirSync(path.dirname(p), { recursive: true });
|
|
83
|
+
fs.writeFileSync(p, data, { encoding: 'utf8', mode: opts.mode });
|
|
84
|
+
});
|
|
85
|
+
const wrap = deps.kubectlWrapImpl ?? kubectlWrap;
|
|
86
|
+
// Read current ~/.olam/auth-secret.
|
|
87
|
+
let authSecretValue = null;
|
|
88
|
+
try {
|
|
89
|
+
const raw = readFn(authSecretFile, 'utf8').trim();
|
|
90
|
+
if (raw.length > 0)
|
|
91
|
+
authSecretValue = raw;
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
// File absent — warn and skip Secret update.
|
|
95
|
+
}
|
|
96
|
+
// Write ~/.olam/auth-secret (both substrates; idempotent).
|
|
97
|
+
if (authSecretValue !== null) {
|
|
98
|
+
writeFn(authSecretFile, authSecretValue + '\n', { mode: 0o600 });
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
stderr.write(`${pc.yellow('[warn]')} ~/.olam/auth-secret not found — skipping kubernetes Secret update. ` +
|
|
102
|
+
`Run \`olam upgrade\` to populate the Secret.\n`);
|
|
103
|
+
return 0;
|
|
104
|
+
}
|
|
105
|
+
// D20: construct Secret YAML in-process; secret value NEVER in subprocess argv.
|
|
106
|
+
const secretYaml = buildSecretYaml(HOST_CP_SECRET_NAME, {
|
|
107
|
+
OLAM_AUTH_SECRET: authSecretValue,
|
|
108
|
+
});
|
|
109
|
+
// Apply the Secret via stdin pipe.
|
|
110
|
+
const applyResult = await wrap(['--context', pinnedContext, 'apply', '-f', '-'], { timeout: 30_000, stdin: secretYaml });
|
|
111
|
+
if (!applyResult.ok) {
|
|
112
|
+
stderr.write(`${pc.red('error:')} kubectl apply (Secret update) failed: ${applyResult.stderr.split('\n')[0] ?? ''}\n`);
|
|
113
|
+
return 1;
|
|
114
|
+
}
|
|
115
|
+
// ADV-N-003: rollout restart to flush the mounted Secret into host-cp.
|
|
116
|
+
const rolloutResult = await wrap(['--context', pinnedContext, 'rollout', 'restart', `deployment/${HOST_CP_DEPLOYMENT_NAME}`, '-n', K8S_NAMESPACE], { timeout: 60_000 });
|
|
117
|
+
if (!rolloutResult.ok) {
|
|
118
|
+
stderr.write(`${pc.yellow('[warn]')} rollout restart failed: ${rolloutResult.stderr.split('\n')[0] ?? ''}. ` +
|
|
119
|
+
`host-cp may not pick up the new token until the next pod restart.\n`);
|
|
120
|
+
// Non-fatal: apply succeeded; warn but return 0.
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
stdout.write(`${pc.green('✓')} Restarted deployment/${HOST_CP_DEPLOYMENT_NAME} (new token mounted)\n`);
|
|
124
|
+
}
|
|
125
|
+
return 0;
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=auth-refresh-kubernetes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-refresh-kubernetes.js","sourceRoot":"","sources":["../../src/lib/auth-refresh-kubernetes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,O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EAAE,IAAI,CACzG,CAAC;QACF,OAAO,CAAC,CAAC;IACX,CAAC;IAED,uEAAuE;IACvE,MAAM,aAAa,GAAG,MAAM,IAAI,CAC9B,CAAC,WAAW,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,EAAE,cAAc,uBAAuB,EAAE,EAAE,IAAI,EAAE,aAAa,CAAC,EAChH,EAAE,OAAO,EAAE,MAAM,EAAE,CACpB,CAAC;IAEF,IAAI,CAAC,aAAa,CAAC,EAAE,EAAE,CAAC;QACtB,MAAM,CAAC,KAAK,CACV,GAAG,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,4BAA4B,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI;YAC/F,qEAAqE,CACtE,CAAC;QACF,iDAAiD;IACnD,CAAC;SAAM,CAAC;QACN,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,yBAAyB,uBAAuB,wBAAwB,CAAC,CAAC;IACzG,CAAC;IAED,OAAO,CAAC,CAAC;AACX,CAAC"}
|
|
@@ -48,6 +48,12 @@ export interface KubectlWrapOpts {
|
|
|
48
48
|
* Signature matches `child_process.spawn` return type.
|
|
49
49
|
*/
|
|
50
50
|
readonly spawnImpl?: typeof spawn;
|
|
51
|
+
/**
|
|
52
|
+
* Optional stdin payload. When set, the subprocess stdin is set to 'pipe'
|
|
53
|
+
* and this string is written then closed. Used for `kubectl apply -f -`
|
|
54
|
+
* patterns (C1 ConfigMap substitution; D20 — value never in argv).
|
|
55
|
+
*/
|
|
56
|
+
readonly stdin?: string;
|
|
51
57
|
}
|
|
52
58
|
/**
|
|
53
59
|
* Invoke kubectl with a timeout.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kubectl-wrap.d.ts","sourceRoot":"","sources":["../../src/lib/kubectl-wrap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;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,MAAM,EAAE,SAAS,GAAG,OAAO,GAAG,SAAS,CAAA;CAAE,CAAC;AAE7G,MAAM,WAAW,eAAe;IAC9B,8EAA8E;IAC9E,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,yEAAyE;IACzE,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC;;;OAGG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;IAClC;;;;OAIG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;;GAKG;AACH,wBAAsB,WAAW,CAC/B,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,IAAI,GAAE,eAAoB,GACzB,OAAO,CAAC,aAAa,CAAC,CA6FxB"}
|
package/dist/lib/kubectl-wrap.js
CHANGED
|
@@ -59,7 +59,7 @@ export async function kubectlWrap(args, opts = {}) {
|
|
|
59
59
|
let child;
|
|
60
60
|
try {
|
|
61
61
|
child = spawnImpl('kubectl', [...args], {
|
|
62
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
62
|
+
stdio: [opts.stdin !== undefined ? 'pipe' : 'ignore', 'pipe', 'pipe'],
|
|
63
63
|
env: { ...process.env, ...(opts.env ?? {}) },
|
|
64
64
|
});
|
|
65
65
|
}
|
|
@@ -73,6 +73,11 @@ export async function kubectlWrap(args, opts = {}) {
|
|
|
73
73
|
});
|
|
74
74
|
return;
|
|
75
75
|
}
|
|
76
|
+
// Write stdin payload and close the stream when provided.
|
|
77
|
+
if (opts.stdin !== undefined && child.stdin) {
|
|
78
|
+
child.stdin.write(opts.stdin, 'utf8');
|
|
79
|
+
child.stdin.end();
|
|
80
|
+
}
|
|
76
81
|
if (child.stdout) {
|
|
77
82
|
child.stdout.on('data', (chunk) => { stdout.push(chunk.toString('utf8')); });
|
|
78
83
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kubectl-wrap.js","sourceRoot":"","sources":["../../src/lib/kubectl-wrap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,MAAM,CAAC,MAAM,kBAAkB,GAAG,OAAO,CAAC;AAC1C,MAAM,gBAAgB,GAAG,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"kubectl-wrap.js","sourceRoot":"","sources":["../../src/lib/kubectl-wrap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,MAAM,CAAC,MAAM,kBAAkB,GAAG,OAAO,CAAC;AAC1C,MAAM,gBAAgB,GAAG,KAAK,CAAC;AAwB/B;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,IAAuB,EACvB,OAAwB,EAAE;IAE1B,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,IAAI,kBAAkB,CAAC;IACrD,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,IAAI,KAAK,CAAC;IAE1C,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,MAAM,MAAM,GAAa,EAAE,CAAC;IAE5B,OAAO,IAAI,OAAO,CAAgB,CAAC,OAAO,EAAE,EAAE;QAC5C,IAAI,QAAQ,GAAG,KAAK,CAAC;QACrB,IAAI,SAAS,GAAyC,IAAI,CAAC;QAC3D,IAAI,YAAY,GAAyC,IAAI,CAAC;QAE9D,SAAS,WAAW,CAAC,CAAgB;YACnC,IAAI,QAAQ;gBAAE,OAAO;YACrB,QAAQ,GAAG,IAAI,CAAC;YAChB,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;gBAAC,YAAY,CAAC,SAAS,CAAC,CAAC;gBAAC,SAAS,GAAG,IAAI,CAAC;YAAC,CAAC;YACtE,IAAI,YAAY,KAAK,I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C,CAAC;QAEH,+DAA+D;QAC/D,SAAS,GAAG,UAAU,CAAC,GAAG,EAAE;YAC1B,SAAS,GAAG,IAAI,CAAC;YACjB,qCAAqC;YACrC,IAAI,CAAC;gBAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YAAC,CAAC;YAAC,MAAM,CAAC,CAAC,oBAAoB,CAAC,CAAC;YAE7D,gEAAgE;YAChE,YAAY,GAAG,UAAU,CAAC,GAAG,EAAE;gBAC7B,YAAY,GAAG,IAAI,CAAC;gBACpB,IAAI,CAAC;oBAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;gBAAC,CAAC;gBAAC,MAAM,CAAC,CAAC,oBAAoB,CAAC,CAAC;gBAC7D,0EAA0E;gBAC1E,2EAA2E;gBAC3E,WAAW,CAAC;oBACV,EAAE,EAAE,KAAK;oBACT,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;oBACvB,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;oBACvB,QAAQ,EAAE,CAAC,CAAC;oBACZ,MAAM,EAAE,SAAS;iBAClB,CAAC,CAAC;YACL,CAAC,EAAE,gBAAgB,CAAC,CAAC;QACvB,CAAC,EAAE,SAAS,CAAC,CAAC;IAChB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -42,6 +42,8 @@ export interface ManifestRefreshAuditEntry {
|
|
|
42
42
|
changed_fields: string[];
|
|
43
43
|
accepted: boolean;
|
|
44
44
|
operator_pid: number;
|
|
45
|
+
/** When set, the refresh was scoped to this peripheral's manifest subdir (C4/D19). */
|
|
46
|
+
peripheral?: string;
|
|
45
47
|
}
|
|
46
48
|
export interface ManifestRefreshDeps {
|
|
47
49
|
/** Override state dir for tests. */
|
|
@@ -82,14 +84,19 @@ export type ManifestRefreshResult = {
|
|
|
82
84
|
* @param manifestsDir — path to ~/.olam/k8s/manifests/
|
|
83
85
|
* @param acceptRegression — true when --accept-security-regression is set
|
|
84
86
|
* @param deps — injectable for tests
|
|
87
|
+
* @param peripheral — when set, scope diff to manifests/<peripheral>/ ONLY (C4/D19)
|
|
85
88
|
*
|
|
86
89
|
* Returns ok=false when:
|
|
87
90
|
* - Security-sensitive fields differ AND !acceptRegression.
|
|
88
91
|
* - Audit log write fails (ENOSPC).
|
|
92
|
+
* - peripheral is set but the peripheral subdir does not exist.
|
|
89
93
|
*
|
|
90
94
|
* On ok=true the audit log entry is written with accepted=true (or
|
|
91
95
|
* accepted=false when no regression was detected — regression-free
|
|
92
96
|
* refreshes are still audited).
|
|
97
|
+
*
|
|
98
|
+
* When peripheral is set, the audit-log entry includes { peripheral: <name> } (D19).
|
|
99
|
+
* Other peripherals' security drift does NOT block a targeted peripheral refresh (D19).
|
|
93
100
|
*/
|
|
94
|
-
export declare function runManifestRefresh(manifestsDir: string, acceptRegression: boolean, deps?: ManifestRefreshDeps): Promise<ManifestRefreshResult>;
|
|
101
|
+
export declare function runManifestRefresh(manifestsDir: string, acceptRegression: boolean, deps?: ManifestRefreshDeps, peripheral?: string): Promise<ManifestRefreshResult>;
|
|
95
102
|
//# sourceMappingURL=manifest-refresh.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest-refresh.d.ts","sourceRoot":"","sources":["../../src/lib/manifest-refresh.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAI9B,eAAO,MAAM,0BAA0B,QAA4D,CAAC;AAEpG,0DAA0D;AAC1D,eAAO,MAAM,yBAAyB,qGAM5B,CAAC;AAEX,MAAM,MAAM,sBAAsB,GAAG,CAAC,OAAO,yBAAyB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEhF,MAAM,WAAW,kBAAkB;IACjC,gFAAgF;IAChF,qBAAqB,EAAE,OAAO,CAAC;IAC/B,uCAAuC;IACvC,aAAa,EAAE,sBAAsB,EAAE,CAAC;CACz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CAAC,WAAW,CAAC,EAAE,OAAO,EAAE,CAAC,WAAW,CAAC;IAC7C,0CAA0C;IAC1C,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,EAAE,CAAC,YAAY,CAAC;IAC/C,2CAA2C;IAC3C,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,EAAE,CAAC,aAAa,CAAC;IACjD,wCAAwC;IACxC,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,CAAC,UAAU,CAAC;IAC3C,mCAAmC;IACnC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;CAC3B;AAkCD;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACxC,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,GACjB,kBAAkB,CA4BpB;AAyBD,MAAM,MAAM,qBAAqB,GAC7B;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAC7B;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,kBAAkB,CACtC,YAAY,EAAE,MAAM,EACpB,gBAAgB,EAAE,OAAO,EACzB,IAAI,GAAE,mBAAwB,EAC9B,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,qBAAqB,CAAC,CA2FhC"}
|
|
@@ -129,32 +129,41 @@ function appendAuditEntry(entry, auditLogPath, writeFileSyncImpl) {
|
|
|
129
129
|
* @param manifestsDir — path to ~/.olam/k8s/manifests/
|
|
130
130
|
* @param acceptRegression — true when --accept-security-regression is set
|
|
131
131
|
* @param deps — injectable for tests
|
|
132
|
+
* @param peripheral — when set, scope diff to manifests/<peripheral>/ ONLY (C4/D19)
|
|
132
133
|
*
|
|
133
134
|
* Returns ok=false when:
|
|
134
135
|
* - Security-sensitive fields differ AND !acceptRegression.
|
|
135
136
|
* - Audit log write fails (ENOSPC).
|
|
137
|
+
* - peripheral is set but the peripheral subdir does not exist.
|
|
136
138
|
*
|
|
137
139
|
* On ok=true the audit log entry is written with accepted=true (or
|
|
138
140
|
* accepted=false when no regression was detected — regression-free
|
|
139
141
|
* refreshes are still audited).
|
|
142
|
+
*
|
|
143
|
+
* When peripheral is set, the audit-log entry includes { peripheral: <name> } (D19).
|
|
144
|
+
* Other peripherals' security drift does NOT block a targeted peripheral refresh (D19).
|
|
140
145
|
*/
|
|
141
|
-
export async function runManifestRefresh(manifestsDir, acceptRegression, deps = {}) {
|
|
146
|
+
export async function runManifestRefresh(manifestsDir, acceptRegression, deps = {}, peripheral) {
|
|
142
147
|
const auditLogPath = deps.auditLogPath ?? MANIFEST_REFRESH_AUDIT_LOG;
|
|
143
148
|
const readdirSync = deps.readdirSync ?? fs.readdirSync;
|
|
144
149
|
const readFileSync = deps.readFileSync ?? fs.readFileSync;
|
|
145
150
|
const writeFileSyncImpl = deps.writeFileSync ?? fs.writeFileSync;
|
|
146
151
|
const existsSync = deps.existsSync ?? fs.existsSync;
|
|
147
152
|
const now = deps.now ? deps.now() : new Date();
|
|
148
|
-
|
|
153
|
+
// When --peripheral=<name> is set, scope to manifests/<peripheral>/ ONLY (C4/D19).
|
|
154
|
+
const targetDir = peripheral ? path.join(manifestsDir, peripheral) : manifestsDir;
|
|
155
|
+
if (!existsSync(targetDir)) {
|
|
149
156
|
return {
|
|
150
157
|
ok: false,
|
|
151
|
-
message:
|
|
158
|
+
message: peripheral
|
|
159
|
+
? `peripheral manifests directory not found: ${targetDir}`
|
|
160
|
+
: `manifests directory not found: ${targetDir}`,
|
|
152
161
|
};
|
|
153
162
|
}
|
|
154
|
-
// Read
|
|
163
|
+
// Read manifest files from the scoped directory (non-recursive).
|
|
155
164
|
let files;
|
|
156
165
|
try {
|
|
157
|
-
const entries = readdirSync(
|
|
166
|
+
const entries = readdirSync(targetDir, { withFileTypes: true });
|
|
158
167
|
files = entries
|
|
159
168
|
.filter((e) => e.isFile() && (e.name.endsWith('.yaml') || e.name.endsWith('.json')))
|
|
160
169
|
.map((e) => e.name);
|
|
@@ -167,7 +176,7 @@ export async function runManifestRefresh(manifestsDir, acceptRegression, deps =
|
|
|
167
176
|
}
|
|
168
177
|
const allChangedFields = [];
|
|
169
178
|
for (const file of files) {
|
|
170
|
-
const filePath = path.join(
|
|
179
|
+
const filePath = path.join(targetDir, file);
|
|
171
180
|
let content;
|
|
172
181
|
try {
|
|
173
182
|
content = readFileSync(filePath, 'utf8');
|
|
@@ -197,11 +206,12 @@ export async function runManifestRefresh(manifestsDir, acceptRegression, deps =
|
|
|
197
206
|
// Write audit entry BEFORE confirming ok (ENOSPC aborts the refresh).
|
|
198
207
|
const entry = {
|
|
199
208
|
ts: now.toISOString(),
|
|
200
|
-
manifests_path:
|
|
209
|
+
manifests_path: targetDir,
|
|
201
210
|
security_regression: hasSecurityRegression,
|
|
202
211
|
changed_fields: allChangedFields,
|
|
203
212
|
accepted: acceptRegression,
|
|
204
213
|
operator_pid: process.pid,
|
|
214
|
+
...(peripheral !== undefined ? { peripheral } : {}),
|
|
205
215
|
};
|
|
206
216
|
try {
|
|
207
217
|
appendAuditEntry(entry, auditLogPath, writeFileSyncImpl);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest-refresh.js","sourceRoot":"","sources":["../../src/lib/manifest-refresh.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,CAAC,MAAM,0BAA0B,GAAG,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,8BAA8B,CAAC,CAAC;AAEpG,0DAA0D;AAC1D,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,iBAAiB;IACjB,kBAAkB;IAClB,cAAc;IAC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CAAC,IAAI,CAAC,oEAAoE;YACvI,CAAC,CAAC,wFAAwF;KAC7F,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* peripheral-registry.ts — Typed const registry of olam's 4 k8s peripheral services.
|
|
3
|
+
*
|
|
4
|
+
* Phase 2 Phase B (olam-host-suite-phase-2-peripheral-services-on-k3s).
|
|
5
|
+
*
|
|
6
|
+
* Each entry describes everything port-forward.ts (B2), upgrade-kubernetes.ts (C),
|
|
7
|
+
* and services.ts / doctor.ts (D) need to drive the lifecycle of one peripheral.
|
|
8
|
+
*
|
|
9
|
+
* ---
|
|
10
|
+
* YAML-DRIVEN REFACTOR TRIGGER (Decision D26)
|
|
11
|
+
*
|
|
12
|
+
* This file uses a hardcoded TypeScript const — acceptable while the registry
|
|
13
|
+
* has ≤4 entries (small, type-safe, IDE-checkable). ADD THE 5th PERIPHERAL HERE
|
|
14
|
+
* as a plain object literal first; if the registry grows to 5+ entries and the
|
|
15
|
+
* pattern becomes repetitive, THEN migrate to yaml-driven config. Do not
|
|
16
|
+
* over-engineer for the case that hasn't arrived.
|
|
17
|
+
* ---
|
|
18
|
+
*
|
|
19
|
+
* host-cp is NOT in PERIPHERALS. It is a named special-case in port-forward.ts.
|
|
20
|
+
*/
|
|
21
|
+
export type Peripheral = {
|
|
22
|
+
/** Human-readable name; matches the k8s Service metadata.name and docker-compose service name (olam-<name> prefix for compose). */
|
|
23
|
+
name: 'auth-service' | 'mcp-auth-service' | 'kg-service' | 'memory-service';
|
|
24
|
+
/** Local port kubectl port-forward binds on the host. */
|
|
25
|
+
port: number;
|
|
26
|
+
/** k8s Service metadata.name in the olam namespace (Phase A 60-service.yaml). */
|
|
27
|
+
k8sServiceName: string;
|
|
28
|
+
/** docker-compose service name for the compose substrate equivalent (Phase D). */
|
|
29
|
+
composeContainerName: string;
|
|
30
|
+
/** ENV var name in host-cp's deployment ConfigMap that exposes this peripheral's URL. */
|
|
31
|
+
configMapKeyInHostCp: string;
|
|
32
|
+
/** Health check path — e.g. /health or /agentmemory/livez. */
|
|
33
|
+
healthPath: string;
|
|
34
|
+
};
|
|
35
|
+
export declare const PERIPHERALS: ReadonlyArray<Peripheral>;
|
|
36
|
+
//# sourceMappingURL=peripheral-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"peripheral-registry.d.ts","sourceRoot":"","sources":["../../src/lib/peripheral-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,MAAM,MAAM,UAAU,GAAG;IACvB,mIAAmI;IACnI,IAAI,EAAE,cAAc,GAAG,kBAAkB,GAAG,YAAY,GAAG,gBAAgB,CAAC;IAC5E,yDAAyD;IACzD,IAAI,EAAE,MAAM,CAAC;IACb,iFAAiF;IACjF,cAAc,EAAE,MAAM,CAAC;IACvB,kFAAkF;IAClF,oBAAoB,EAAE,MAAM,CAAC;IAC7B,yFAAyF;IACzF,oBAAoB,EAAE,MAAM,CAAC;IAC7B,8DAA8D;IAC9D,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,aAAa,CAAC,UAAU,CAiCxC,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* peripheral-registry.ts — Typed const registry of olam's 4 k8s peripheral services.
|
|
3
|
+
*
|
|
4
|
+
* Phase 2 Phase B (olam-host-suite-phase-2-peripheral-services-on-k3s).
|
|
5
|
+
*
|
|
6
|
+
* Each entry describes everything port-forward.ts (B2), upgrade-kubernetes.ts (C),
|
|
7
|
+
* and services.ts / doctor.ts (D) need to drive the lifecycle of one peripheral.
|
|
8
|
+
*
|
|
9
|
+
* ---
|
|
10
|
+
* YAML-DRIVEN REFACTOR TRIGGER (Decision D26)
|
|
11
|
+
*
|
|
12
|
+
* This file uses a hardcoded TypeScript const — acceptable while the registry
|
|
13
|
+
* has ≤4 entries (small, type-safe, IDE-checkable). ADD THE 5th PERIPHERAL HERE
|
|
14
|
+
* as a plain object literal first; if the registry grows to 5+ entries and the
|
|
15
|
+
* pattern becomes repetitive, THEN migrate to yaml-driven config. Do not
|
|
16
|
+
* over-engineer for the case that hasn't arrived.
|
|
17
|
+
* ---
|
|
18
|
+
*
|
|
19
|
+
* host-cp is NOT in PERIPHERALS. It is a named special-case in port-forward.ts.
|
|
20
|
+
*/
|
|
21
|
+
export const PERIPHERALS = [
|
|
22
|
+
{
|
|
23
|
+
name: 'auth-service',
|
|
24
|
+
port: 9999,
|
|
25
|
+
k8sServiceName: 'auth-service',
|
|
26
|
+
composeContainerName: 'olam-auth-service',
|
|
27
|
+
configMapKeyInHostCp: 'OLAM_AUTH_SERVICE_URL',
|
|
28
|
+
healthPath: '/health',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: 'mcp-auth-service',
|
|
32
|
+
port: 9998,
|
|
33
|
+
k8sServiceName: 'mcp-auth-service',
|
|
34
|
+
composeContainerName: 'olam-mcp-auth-service',
|
|
35
|
+
configMapKeyInHostCp: 'OLAM_MCP_AUTH_SERVICE_URL',
|
|
36
|
+
healthPath: '/health',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: 'kg-service',
|
|
40
|
+
port: 9997,
|
|
41
|
+
k8sServiceName: 'kg-service',
|
|
42
|
+
composeContainerName: 'olam-kg-service',
|
|
43
|
+
configMapKeyInHostCp: 'OLAM_KG_SERVICE_URL',
|
|
44
|
+
healthPath: '/health',
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: 'memory-service',
|
|
48
|
+
port: 3111,
|
|
49
|
+
k8sServiceName: 'memory-service',
|
|
50
|
+
composeContainerName: 'olam-memory-service',
|
|
51
|
+
configMapKeyInHostCp: 'OLAM_MEMORY_SERVICE_URL',
|
|
52
|
+
healthPath: '/agentmemory/livez',
|
|
53
|
+
},
|
|
54
|
+
];
|
|
55
|
+
//# sourceMappingURL=peripheral-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"peripheral-registry.js","sourceRoot":"","sources":["../../src/lib/peripheral-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAiBH,MAAM,CAAC,MAAM,WAAW,GAA8B;IACpD;QACE,IAAI,EAAE,cAAc;QACpB,IAAI,EAAE,IAAI;QACV,cAAc,EAAE,cAAc;QAC9B,oBAAoB,EAAE,mBAAmB;QACzC,oBAAoB,EAAE,uBAAuB;QAC7C,UAAU,EAAE,SAAS;KACtB;IACD;QACE,IAAI,EAAE,kBAAkB;QACxB,IAAI,EAAE,IAAI;QACV,cAAc,EAAE,kBAAkB;QAClC,oBAAoB,EAAE,uBAAuB;QAC7C,oBAAoB,EAAE,2BAA2B;QACjD,UAAU,EAAE,SAAS;KACtB;IACD;QACE,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE,IAAI;QACV,cAAc,EAAE,YAAY;QAC5B,oBAAoB,EAAE,iBAAiB;QACvC,oBAAoB,EAAE,qBAAqB;QAC3C,UAAU,EAAE,SAAS;KACtB;IACD;QACE,IAAI,EAAE,gBAAgB;QACtB,IAAI,EAAE,IAAI;QACV,cAAc,EAAE,gBAAgB;QAChC,oBAAoB,EAAE,qBAAqB;QAC3C,oBAAoB,EAAE,yBAAyB;QAC/C,UAAU,EAAE,oBAAoB;KACjC;CACO,CAAC"}
|
|
@@ -4,10 +4,19 @@
|
|
|
4
4
|
* Phase 1b C1 of olam-host-suite-phase-1b-k3s-beta-flavour (plan
|
|
5
5
|
* ~/.claude/plans/olam-host-suite-phase-1b-k3s-beta-flavour.md).
|
|
6
6
|
*
|
|
7
|
+
* Phase 2 Phase B B2 (olam-host-suite-phase-2-peripheral-services-on-k3s):
|
|
8
|
+
* Extended with registry-driven multi-peripheral support:
|
|
9
|
+
* spawnAllPeripheralPortForwards() — iterate PERIPHERALS; spawn each in parallel
|
|
10
|
+
* stopAllPeripheralPortForwards() — SIGTERM each peripheral's port-forward
|
|
11
|
+
* getPeripheralLivenessSnapshot() — TCP probe all 4 peripherals; return {name, alive}[]
|
|
12
|
+
* Each peripheral uses its own independent flock + PID file named by peripheral.name.
|
|
13
|
+
* host-cp port-forward retained as a named special-case; Phase 1b callers unchanged.
|
|
14
|
+
*
|
|
7
15
|
* Decisions consumed:
|
|
8
16
|
* D17 — port-forward spawn via flock advisory lock (race-safe)
|
|
9
17
|
* D23 — PID file at ~/.olam/state/port-forward.pid (mode 0600)
|
|
10
18
|
* D24 — probePortForwardLiveness uses TCP probe, NOT kill(pid, 0)
|
|
19
|
+
* D26 — per-peripheral PID/lock at ~/.olam/state/port-forward-<name>.{pid,lock}
|
|
11
20
|
*
|
|
12
21
|
* ## Flock strategy (why O_CREAT|O_EXCL, not POSIX flock(2))
|
|
13
22
|
*
|
|
@@ -40,6 +49,7 @@
|
|
|
40
49
|
import { spawn } from 'node:child_process';
|
|
41
50
|
import * as path from 'node:path';
|
|
42
51
|
import * as os from 'node:os';
|
|
52
|
+
import { type Peripheral } from './peripheral-registry.js';
|
|
43
53
|
export declare const PORT_FORWARD_PORT = 19000;
|
|
44
54
|
export declare const PORT_FORWARD_LOCK_PATH: string;
|
|
45
55
|
export declare const PORT_FORWARD_PID_PATH: string;
|
|
@@ -97,5 +107,62 @@ export declare function spawnPortForward(context: string, namespace: string, tar
|
|
|
97
107
|
* No-op when no PID file exists. Returns true when a process was signalled.
|
|
98
108
|
*/
|
|
99
109
|
export declare function stopPortForward(deps?: PortForwardDeps): boolean;
|
|
110
|
+
/**
|
|
111
|
+
* Options for peripheral port-forward operations (injectable for tests).
|
|
112
|
+
* Extends the same deps pattern as the host-cp single port-forward.
|
|
113
|
+
*/
|
|
114
|
+
export interface PeripheralPortForwardDeps {
|
|
115
|
+
/** Override state directory (default: OLAM_STATE_DIR). Used in tests to isolate state. */
|
|
116
|
+
readonly stateDir?: string;
|
|
117
|
+
/** Override spawn factory (default: child_process.spawn). */
|
|
118
|
+
readonly spawnImpl?: typeof spawn;
|
|
119
|
+
/** Override TCP probe (default: real TCP socket). */
|
|
120
|
+
readonly tcpProbeImpl?: (host: string, port: number, timeoutMs: number) => Promise<boolean>;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Spawn a kubectl port-forward for a single peripheral, guarded by an
|
|
124
|
+
* independent advisory lock per peripheral. Mirrors the Phase 1b host-cp
|
|
125
|
+
* pattern (D17/D23/D24) generalised to any Peripheral entry.
|
|
126
|
+
*
|
|
127
|
+
* Returns true when a new process was spawned; false when the tunnel was
|
|
128
|
+
* already live or the lock was held by a concurrent caller.
|
|
129
|
+
*
|
|
130
|
+
* @internal — called by spawnAllPeripheralPortForwards; exported for test injection.
|
|
131
|
+
*/
|
|
132
|
+
export declare function spawnPeripheralPortForward(peripheral: Peripheral, context: string, namespace: string, deps?: PeripheralPortForwardDeps): Promise<boolean>;
|
|
133
|
+
/**
|
|
134
|
+
* Spawn kubectl port-forward processes for all 4 peripherals in parallel.
|
|
135
|
+
*
|
|
136
|
+
* Each peripheral uses its own independent flock + PID file
|
|
137
|
+
* (`~/.olam/state/port-forward-<name>.{lock,pid}`), so locking one
|
|
138
|
+
* peripheral does NOT block another.
|
|
139
|
+
*
|
|
140
|
+
* @param context - kubectl context name (--context flag); defaults to 'olam'
|
|
141
|
+
* @param namespace - target namespace; defaults to 'olam'
|
|
142
|
+
* @param deps - injectable dependencies for testing
|
|
143
|
+
*/
|
|
144
|
+
export declare function spawnAllPeripheralPortForwards(context?: string, namespace?: string, deps?: PeripheralPortForwardDeps): Promise<void>;
|
|
145
|
+
/**
|
|
146
|
+
* Send SIGTERM to all running peripheral port-forward processes and
|
|
147
|
+
* remove their PID and lock files.
|
|
148
|
+
*
|
|
149
|
+
* No-op for any peripheral whose PID file is absent (process already stopped).
|
|
150
|
+
*
|
|
151
|
+
* @param deps - injectable dependencies for testing (stateDir override)
|
|
152
|
+
*/
|
|
153
|
+
export declare function stopAllPeripheralPortForwards(deps?: Pick<PeripheralPortForwardDeps, 'stateDir'>): void;
|
|
154
|
+
export interface PeripheralLivenessEntry {
|
|
155
|
+
name: string;
|
|
156
|
+
alive: boolean;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* TCP-probe each peripheral and return a snapshot of their liveness.
|
|
160
|
+
*
|
|
161
|
+
* Uses the same realTcpProbe utility as probePortForwardLiveness (D24).
|
|
162
|
+
* Probes run in parallel for speed.
|
|
163
|
+
*
|
|
164
|
+
* @param deps - injectable dependencies for testing
|
|
165
|
+
*/
|
|
166
|
+
export declare function getPeripheralLivenessSnapshot(deps?: Pick<PeripheralPortForwardDeps, 'tcpProbeImpl'>): Promise<PeripheralLivenessEntry[]>;
|
|
100
167
|
export { os, path };
|
|
101
168
|
//# sourceMappingURL=port-forward.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"port-forward.d.ts","sourceRoot":"","sources":["../../src/lib/port-forward.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"port-forward.d.ts","sourceRoot":"","sources":["../../src/lib/port-forward.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAG3C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAE9B,OAAO,EAAe,KAAK,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAExE,eAAO,MAAM,iBAAiB,QAAQ,CAAC;AACvC,eAAO,MAAM,sBAAsB,QAAiD,CAAC;AACrF,eAAO,MAAM,qBAAqB,QAAgD,CAAC;AAKnF,MAAM,WAAW,eAAe;IAC9B,2EAA2E;IAC3E,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,qDAAqD;IACrD,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;IAClC,6CA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