@tpsdev-ai/flair 0.59.0 → 0.63.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -10
- package/SECURITY.md +49 -5
- package/config.yaml +23 -12
- package/dist/bridges/builtins/mem0.js +63 -28
- package/dist/bridges/runtime/execute.js +1 -0
- package/dist/bridges/runtime/import-runner.js +12 -0
- package/dist/bridges/runtime/load-plugin.js +42 -13
- package/dist/bridges/runtime/yaml-loader.js +4 -2
- package/dist/bridges/types.js +1 -0
- package/dist/build-info.json +3 -3
- package/dist/cli.js +1054 -367
- package/dist/commands/agent.js +233 -90
- package/dist/commands/attention.js +4 -3
- package/dist/commands/backup-approval.js +218 -0
- package/dist/commands/backup.js +211 -39
- package/dist/commands/bootstrap.js +3 -1
- package/dist/commands/bridge.js +172 -119
- package/dist/commands/deploy.js +71 -8
- package/dist/commands/doctor.js +711 -146
- package/dist/commands/export.js +57 -23
- package/dist/commands/federation.js +787 -82
- package/dist/commands/grant.js +5 -6
- package/dist/commands/help.js +25 -0
- package/dist/commands/hook.js +155 -2
- package/dist/commands/idp.js +27 -19
- package/dist/commands/import.js +136 -20
- package/dist/commands/init.js +469 -200
- package/dist/commands/integrity.js +387 -0
- package/dist/commands/keys.js +247 -58
- package/dist/commands/mcp.js +108 -52
- package/dist/commands/memory.js +203 -35
- package/dist/commands/migrate-harness-memory.js +3 -2
- package/dist/commands/orgevent.js +51 -47
- package/dist/commands/presence.js +4 -3
- package/dist/commands/principal.js +428 -62
- package/dist/commands/quality.js +13 -1
- package/dist/commands/reembed.js +141 -17
- package/dist/commands/relationship.js +2 -1
- package/dist/commands/rem.js +537 -80
- package/dist/commands/restore.js +413 -65
- package/dist/commands/search.js +6 -4
- package/dist/commands/service.js +235 -40
- package/dist/commands/soul.js +4 -9
- package/dist/commands/status.js +94 -38
- package/dist/commands/test.js +7 -3
- package/dist/commands/upgrade.js +77 -23
- package/dist/commands/workspace.js +13 -11
- package/dist/component-env.js +31 -41
- package/dist/deploy.js +136 -4
- package/dist/doctor-client.js +534 -92
- package/dist/engine-version-contract.js +1 -0
- package/dist/engine-version.js +23 -3
- package/dist/fabric-upgrade.js +12 -2
- package/dist/federation/presence-send.js +139 -0
- package/dist/federation-verify.js +273 -180
- package/dist/hook-install.js +670 -6
- package/dist/install/clients.js +171 -35
- package/dist/keystore.js +72 -0
- package/dist/lib/action-recall-runtime.js +328 -0
- package/dist/lib/agent-home-fields.js +132 -0
- package/dist/lib/agent-home.js +427 -0
- package/dist/lib/agent-id-rule.js +88 -0
- package/dist/lib/agent-roster.js +33 -0
- package/dist/lib/atomic-write.js +1 -1
- package/dist/lib/auth-resolve.js +1069 -60
- package/dist/lib/backup-approval-store.js +612 -0
- package/dist/lib/backup-artifact.js +343 -0
- package/dist/lib/capture-runtime.js +124 -0
- package/dist/lib/config-critical-section.js +212 -25
- package/dist/lib/connect-phase.js +33 -0
- package/dist/lib/credential-status-rule.js +78 -0
- package/dist/lib/daemon-liveness.js +43 -11
- package/dist/lib/doctor-run.js +75 -37
- package/dist/lib/durability-copy.js +10 -0
- package/dist/lib/embedding-space-doctor.js +75 -0
- package/dist/lib/federation-pair-access.js +4 -0
- package/dist/lib/federation-retry-queue.js +283 -0
- package/dist/lib/federation-retry-row.js +101 -0
- package/dist/lib/flair-agent-role.js +4 -0
- package/dist/lib/hub-url.js +12 -0
- package/dist/lib/init-admin-pass.js +88 -12
- package/dist/lib/init-listener-environ.js +1 -2
- package/dist/lib/init-occupied-listener.js +15 -111
- package/dist/lib/init-spawn-attribution.js +73 -0
- package/dist/lib/init-tcp-probe.js +33 -0
- package/dist/lib/instance-identity-row.js +20 -0
- package/dist/lib/instruction-event-contract.js +17 -0
- package/dist/lib/instruction-event-doctor.js +102 -0
- package/dist/lib/launchd-management.js +38 -3
- package/dist/lib/listener-table.js +268 -0
- package/dist/lib/local-delete-instance.js +27 -0
- package/dist/lib/local-instance-pair.js +256 -0
- package/dist/lib/mcp-enable.js +1182 -341
- package/dist/lib/mcp-oauth-env-core.js +133 -0
- package/dist/lib/mcp-oauth-env.js +125 -0
- package/dist/lib/mcp-spec.js +17 -1
- package/dist/lib/memory-attributes.js +4 -0
- package/dist/lib/memory-id-policy.js +46 -0
- package/dist/lib/memory-integrity.js +309 -0
- package/dist/lib/memory-provider-timeout.js +33 -0
- package/dist/lib/memory-purge-response.js +20 -0
- package/dist/lib/mqtt-config.js +132 -0
- package/dist/lib/mqtt-listener-doctor.js +104 -0
- package/dist/lib/open-live-row.js +20 -0
- package/dist/lib/ops-table-count.js +25 -0
- package/dist/lib/ops-url.js +52 -0
- package/dist/lib/owned-pins.js +67 -10
- package/dist/lib/peer-status.js +27 -0
- package/dist/lib/principal-status.js +29 -0
- package/dist/lib/process-start-time.js +76 -12
- package/dist/lib/promotion-content-hash.js +20 -0
- package/dist/lib/proto-safe-record.js +42 -0
- package/dist/lib/record-id-path.js +25 -0
- package/dist/lib/reembed-server-support.js +66 -0
- package/dist/lib/restore-archive.js +760 -0
- package/dist/lib/restore-verify.js +104 -0
- package/dist/lib/scheduler-platform.js +10 -6
- package/dist/lib/secret-keys.js +25 -0
- package/dist/lib/secrets-push.js +50 -22
- package/dist/lib/skill-assignment-preflight.js +159 -0
- package/dist/lib/skill-seed-pending.js +24 -0
- package/dist/lib/skill-seed.js +448 -0
- package/dist/lib/skill-tombstone-doctor.js +133 -0
- package/dist/lib/soul-scope-fields.js +26 -0
- package/dist/lib/stop-start-recovery.js +54 -0
- package/dist/lib/uninstall-purge.js +266 -11
- package/dist/lib/upgrade-prior-liveness.js +2 -1
- package/dist/lib/using-flair-skill.js +87 -0
- package/dist/mcp-client-assertion.js +114 -14
- package/dist/memory-id-checkpoint.js +347 -0
- package/dist/memory-node-compare.js +207 -0
- package/dist/mqtt-off-deploy.js +550 -0
- package/dist/packages/flair-mcp/src/secret-redaction.js +113 -0
- package/dist/rem/promote-policy.js +3 -3
- package/dist/rem/restore.js +303 -26
- package/dist/rem/runner.js +317 -96
- package/dist/rem/scheduler.js +21 -4
- package/dist/resources/A2AAdapter.js +131 -178
- package/dist/resources/AdminMemory.js +2 -0
- package/dist/resources/AdminMemoryCandidates.js +116 -0
- package/dist/resources/Agent.js +463 -33
- package/dist/resources/AgentCard.js +4 -0
- package/dist/resources/AgentKeyRegister.js +248 -0
- package/dist/resources/AgentKeyRegistration.js +28 -0
- package/dist/resources/AgentReadPosition.js +7 -0
- package/dist/resources/AgentSeed.js +238 -107
- package/dist/resources/AutoPromoteCandidates.js +413 -78
- package/dist/resources/Credential.js +183 -10
- package/dist/resources/Federation.js +915 -145
- package/dist/resources/FederationRetry.js +140 -0
- package/dist/resources/InstructionVersion.js +220 -0
- package/dist/resources/Integration.js +300 -25
- package/dist/resources/MCPClientMetadata.js +6 -3
- package/dist/resources/Memory.js +3300 -758
- package/dist/resources/MemoryArchive.js +171 -53
- package/dist/resources/MemoryBootstrap.js +122 -61
- package/dist/resources/MemoryCandidate.js +37 -3
- package/dist/resources/MemoryConsolidate.js +2 -2
- package/dist/resources/MemoryDedupStats.js +30 -1
- package/dist/resources/MemoryFeed.js +545 -50
- package/dist/resources/MemoryGrant.js +21 -1
- package/dist/resources/MemoryMaintenance.js +368 -46
- package/dist/resources/MemoryPurge.js +348 -0
- package/dist/resources/MemoryReflect.js +71 -12
- package/dist/resources/MemoryReindex.js +111 -17
- package/dist/resources/Message.js +16 -5
- package/dist/resources/OAuth.js +342 -48
- package/dist/resources/OAuthClient.js +1 -1
- package/dist/resources/OrgEvent.js +405 -19
- package/dist/resources/OrgEventCatchup.js +7 -0
- package/dist/resources/OrgEventMaintenance.js +48 -10
- package/dist/resources/PairingToken.js +1 -1
- package/dist/resources/Presence.js +166 -51
- package/dist/resources/PromoteMemoryCandidate.js +24 -7
- package/dist/resources/RecordUsage.js +2 -4
- package/dist/resources/Relationship.js +23 -0
- package/dist/resources/SemanticSearch.js +63 -32
- package/dist/resources/Soul.js +191 -76
- package/dist/resources/SoulFeed.js +2 -1
- package/dist/resources/TeamDirectory.js +35 -0
- package/dist/resources/WorkspaceLatest.js +4 -0
- package/dist/resources/WorkspaceState.js +21 -1
- package/dist/resources/XAA.js +207 -63
- package/dist/resources/a2a-stream.js +313 -0
- package/dist/resources/a2a-url.js +4 -5
- package/dist/resources/agent-admin.js +10 -1
- package/dist/resources/agent-auth.js +138 -83
- package/dist/resources/agent-read-position-lib.js +4 -1
- package/dist/resources/agent-status-guard.js +9 -7
- package/dist/resources/auth-middleware.js +534 -171
- package/dist/resources/authority-field-guard.js +9 -11
- package/dist/resources/auto-promote-lib.js +8 -5
- package/dist/resources/basic-auth-header.js +21 -0
- package/dist/resources/bm25-index-service.js +4 -5
- package/dist/resources/dedup-cluster.js +6 -1
- package/dist/resources/ed25519-auth.js +1 -1
- package/dist/resources/embedding-space-guard.js +366 -72
- package/dist/resources/embeddings-provider.js +25 -0
- package/dist/resources/engine-version-stamp-boot.js +53 -0
- package/dist/resources/federation-classify.js +161 -0
- package/dist/resources/federation-crypto.js +5 -5
- package/dist/resources/federation-retry-lib.js +60 -0
- package/dist/resources/grant-visibility.js +135 -0
- package/dist/resources/harper-routing.js +83 -0
- package/dist/resources/health.js +163 -22
- package/dist/resources/host-pointer/registry.js +29 -0
- package/dist/resources/host-pointer-adapter.js +1 -0
- package/dist/resources/host-source-citation.js +49 -0
- package/dist/resources/host-source-visibility.js +7 -6
- package/dist/resources/in-process.js +24 -22
- package/dist/resources/instance-create-lock.js +17 -0
- package/dist/resources/instance-identity.js +23 -0
- package/dist/resources/instruction-version-record.js +587 -0
- package/dist/resources/internal-authority.js +13 -0
- package/dist/resources/key-lock.js +3 -3
- package/dist/resources/mcp-handler.js +141 -19
- package/dist/resources/mcp-oauth-env-guard.js +36 -0
- package/dist/resources/mcp-oauth-flag.js +12 -14
- package/dist/resources/mcp-oauth.js +450 -56
- package/dist/resources/mcp-tool-arguments.js +4 -6
- package/dist/resources/mcp-tools.js +187 -40
- package/dist/resources/memory-bootstrap-lib.js +5 -15
- package/dist/resources/memory-declared-attributes.js +4 -1
- package/dist/resources/memory-deletion-history.js +55 -0
- package/dist/resources/memory-durability.js +54 -0
- package/dist/resources/memory-embed-hash.js +144 -0
- package/dist/resources/memory-embedding-value.js +8 -0
- package/dist/resources/memory-host-source.js +32 -7
- package/dist/resources/memory-id-guard.js +75 -0
- package/dist/resources/memory-redaction.js +236 -0
- package/dist/resources/memory-reflect-lib.js +1 -1
- package/dist/resources/memory-supplied-vector.js +72 -0
- package/dist/resources/memory-write-lock.js +489 -0
- package/dist/resources/memory-write-response.js +139 -0
- package/dist/resources/memory-write-transaction.js +243 -0
- package/dist/resources/migration-boot.js +17 -12
- package/dist/resources/migrations/boot-progress.js +25 -0
- package/dist/resources/migrations/data-dir.js +90 -19
- package/dist/resources/migrations/dir-safety.js +61 -3
- package/dist/resources/migrations/embedding-stamp.js +462 -82
- package/dist/resources/migrations/export.js +1 -0
- package/dist/resources/migrations/graph-heal.js +27 -27
- package/dist/resources/migrations/ledger.js +5 -2
- package/dist/resources/migrations/lock.js +870 -77
- package/dist/resources/migrations/progress.js +71 -10
- package/dist/resources/migrations/runner.js +212 -18
- package/dist/resources/migrations/snapshot.js +1 -0
- package/dist/resources/migrations/source-fields.js +5 -5
- package/dist/resources/migrations/state.js +36 -1
- package/dist/resources/migrations/status.js +2 -13
- package/dist/resources/migrations/synthetic-test-migration.js +81 -12
- package/dist/resources/migrations/types.js +26 -1
- package/dist/resources/migrations/visibility-backfill.js +113 -72
- package/dist/resources/oauth-discovery.js +0 -5
- package/dist/resources/object-body-guard.js +40 -0
- package/dist/resources/org-event-created-at.js +133 -0
- package/dist/resources/org-event-reserved.js +92 -0
- package/dist/resources/org-event-write-fault.js +19 -0
- package/dist/resources/originator-instance.js +39 -7
- package/dist/resources/owner-delete-recheck.js +78 -0
- package/dist/resources/owner-field-guard.js +39 -5
- package/dist/resources/owner-scoped-write-policy.js +256 -0
- package/dist/resources/owner-scoped-writes.js +89 -0
- package/dist/resources/path-id-rewrite.js +76 -0
- package/dist/resources/presence-internal.js +5 -5
- package/dist/resources/presence-receipt.js +236 -0
- package/dist/resources/promotion-binding.js +43 -0
- package/dist/resources/promotion-stamp.js +143 -17
- package/dist/resources/protocol-context.js +189 -0
- package/dist/resources/record-owner-guard.js +74 -26
- package/dist/resources/record-type-kit.js +2 -4
- package/dist/resources/record-types.js +1 -1
- package/dist/resources/relay-ops.js +78 -6
- package/dist/resources/replay-store.js +96 -19
- package/dist/resources/request-target.js +163 -0
- package/dist/resources/request-transaction.js +46 -1
- package/dist/resources/search-readiness.js +4 -1
- package/dist/resources/seed-ids.js +9 -0
- package/dist/resources/seed-reservation.js +116 -0
- package/dist/resources/semantic-retrieval-core.js +27 -15
- package/dist/resources/server-row-validation.js +71 -0
- package/dist/resources/skill-manifest.js +24 -14
- package/dist/resources/skill-subject.js +53 -0
- package/dist/resources/skill-version-write.js +789 -0
- package/dist/resources/skill-write-fault.js +20 -0
- package/dist/resources/skill-write-policy.js +68 -0
- package/dist/resources/skill-write.js +67 -7
- package/dist/resources/soul-write-policy.js +26 -7
- package/dist/resources/table-helpers.js +10 -7
- package/dist/resources/table-subscription-policy.js +518 -85
- package/dist/resources/table-subscriptions.js +20 -7
- package/dist/resources/team-directory.js +248 -0
- package/dist/resources/tool-descriptors/index.js +69 -8
- package/dist/resources/txn-pause-point.js +235 -0
- package/dist/resources/usage-recording.js +186 -70
- package/dist/resources/write-back.js +383 -0
- package/dist/resources/write-journal-context.js +5 -0
- package/dist/resources/write-journal.js +289 -0
- package/dist/src/engine-version-contract.js +1 -0
- package/dist/src/keystore.js +72 -0
- package/dist/src/lib/agent-home-fields.js +132 -0
- package/dist/src/lib/agent-id-rule.js +88 -0
- package/dist/src/lib/agent-key-register.js +80 -0
- package/dist/src/lib/atomic-write.js +256 -0
- package/dist/src/lib/credential-status-rule.js +78 -0
- package/dist/src/lib/expired-by-agent.js +37 -0
- package/dist/src/lib/federation-retry-row.js +101 -0
- package/dist/src/lib/flair-agent-role.js +4 -0
- package/dist/src/lib/idp-mapping-rule.js +81 -0
- package/dist/src/lib/instance-identity-row.js +20 -0
- package/dist/src/lib/instruction-event-contract.js +17 -0
- package/dist/src/lib/mcp-oauth-env-core.js +133 -0
- package/dist/src/lib/memory-attributes.js +4 -0
- package/dist/src/lib/memory-id-policy.js +46 -0
- package/dist/src/lib/open-live-row.js +20 -0
- package/dist/src/lib/principal-status.js +29 -0
- package/dist/src/lib/proto-safe-record.js +42 -0
- package/dist/src/lib/reembed-server-support.js +66 -0
- package/dist/src/lib/scheduler-platform.js +10 -6
- package/dist/src/lib/soul-scope-fields.js +26 -0
- package/dist/src/lib/systemd-agent-id.js +38 -0
- package/dist/src/rem/promote-policy.js +3 -3
- package/dist/src/rem/scheduler.js +21 -4
- package/docs/access-control.md +164 -54
- package/docs/api-reference.md +165 -32
- package/docs/auth.md +46 -30
- package/docs/bridges.md +11 -0
- package/docs/claude-code.md +37 -7
- package/docs/deploying-on-fabric.md +178 -0
- package/docs/deployment.md +19 -0
- package/docs/embedding-in-a-harper-app.md +17 -15
- package/docs/entity-vocabulary.md +3 -6
- package/docs/federation.md +61 -3
- package/docs/hosted-on-fabric.md +43 -36
- package/docs/integrations.md +14 -14
- package/docs/mcp-clients.md +12 -7
- package/docs/n8n.md +17 -11
- package/docs/notes/mcp-agent-auth-consumer.md +16 -13
- package/docs/notes/mcp-oauth-model2.md +40 -11
- package/docs/openclaw.md +1 -1
- package/docs/quickstart-fabric.md +4 -4
- package/docs/quickstart.md +12 -4
- package/docs/releasing.md +25 -19
- package/docs/rem.md +32 -3
- package/docs/secrets-and-keys.md +21 -4
- package/docs/standalone-local.md +30 -2
- package/docs/supply-chain-policy.md +34 -16
- package/docs/the-team.md +2 -2
- package/docs/upgrade.md +46 -6
- package/package.json +24 -12
- package/schemas/agent-key-registration.graphql +22 -0
- package/schemas/agent.graphql +6 -3
- package/schemas/federation.graphql +41 -1
- package/schemas/memory.graphql +91 -7
- package/schemas/oauth.graphql +19 -0
- package/schemas/schema.graphql +2 -0
- package/templates/bin/flair-rem-nightly.sh.tmpl +7 -1
- package/templates/launchd/start-flair-with-admin-pass.sh +188 -10
- package/dist/resources/soul-adk-guard.js +0 -68
package/dist/commands/test.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import * as render from "../render.js";
|
|
2
|
+
import { encodeRecordId } from "../lib/record-id-path.js";
|
|
3
|
+
import { ApiRequestOutcomeUnknown } from "../lib/auth-resolve.js";
|
|
2
4
|
let cli;
|
|
3
5
|
/** Bind the cli-locals this module depends on. */
|
|
4
6
|
export function bindCli(fns) {
|
|
@@ -44,13 +46,15 @@ export function register(program) {
|
|
|
44
46
|
}
|
|
45
47
|
}
|
|
46
48
|
catch (e) {
|
|
49
|
+
if (e instanceof ApiRequestOutcomeUnknown)
|
|
50
|
+
throw e;
|
|
47
51
|
const message = e instanceof Error ? e.message : String(e);
|
|
48
52
|
console.log(` ${render.icons.error} ${render.wrap(render.c.red, "FAIL")} ${name}: ${render.wrap(render.c.dim, message?.slice(0, 120))}`);
|
|
49
53
|
failed++;
|
|
50
54
|
}
|
|
51
55
|
};
|
|
52
56
|
// 1. Write a test memory via PUT /Memory/<id>.
|
|
53
|
-
//
|
|
57
|
+
// The CLI writes through PUT /Memory/<id>; a bare POST /Memory reaches Memory.post() too.
|
|
54
58
|
await check("Write test memory (PUT /Memory/<id>)", async () => {
|
|
55
59
|
const id = `flair-test-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
56
60
|
const body = {
|
|
@@ -61,7 +65,7 @@ export function register(program) {
|
|
|
61
65
|
};
|
|
62
66
|
if (agentId)
|
|
63
67
|
body.agentId = agentId;
|
|
64
|
-
await api("PUT", `/Memory/${id}`, body, { baseUrl });
|
|
68
|
+
await api("PUT", `/Memory/${encodeRecordId(id)}`, body, { baseUrl });
|
|
65
69
|
memoryId = id;
|
|
66
70
|
return true;
|
|
67
71
|
});
|
|
@@ -81,7 +85,7 @@ export function register(program) {
|
|
|
81
85
|
console.log(` (skipped — no id returned from write step)`);
|
|
82
86
|
return true;
|
|
83
87
|
}
|
|
84
|
-
await api("DELETE", `/Memory/${memoryId}`, agentId ? { agentId } : undefined, { baseUrl });
|
|
88
|
+
await api("DELETE", `/Memory/${encodeRecordId(memoryId)}`, agentId ? { agentId } : undefined, { baseUrl });
|
|
85
89
|
return true;
|
|
86
90
|
});
|
|
87
91
|
const passColor = passed > 0 ? render.c.green : render.c.dim;
|
package/dist/commands/upgrade.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { detectWiredFlairMcp } from "../doctor-client.js";
|
|
2
2
|
import { UPGRADE_SNAPSHOT_ROOT, fetchDeclaredHarperVersion, readInstalledHarperVersion } from "../engine-version.js";
|
|
3
3
|
import { fabricUpgrade } from "../fabric-upgrade.js";
|
|
4
|
+
import { deployUrlRefusal, safeUrl } from "../mqtt-off-deploy.js";
|
|
4
5
|
import { renderFleetSweepTable, sweepFleet } from "../fleet-verify.js";
|
|
5
6
|
import { resolveNpmGlobalPrefix } from "../install/global-bin-path.js";
|
|
6
7
|
import { defaultKeysDir } from "../lib/auth-resolve.js";
|
|
@@ -8,6 +9,7 @@ import { classifyDaemonState } from "../lib/daemon-liveness.js";
|
|
|
8
9
|
import { renderVerifiedSummary } from "../lib/doctor-run.js";
|
|
9
10
|
import { isDetached, renderDetachedWarning } from "../lib/launchd-management.js";
|
|
10
11
|
import { FLAIR_MCP_PACKAGE, clearFlairCliVersionCache } from "../lib/mcp-spec.js";
|
|
12
|
+
import { planRedirectMigration, renderRedirectMigration } from "../lib/mcp-oauth-env.js";
|
|
11
13
|
import { createRegistryNoticePrinter, fetchLatestVersion, fetchVersionDeprecation, isStrictSemver } from "../lib/npm-registry.js";
|
|
12
14
|
import { classifyUpgradePriorLiveness } from "../lib/upgrade-prior-liveness.js";
|
|
13
15
|
import { decideAfterRestartFailure, decideDeprecatedRollback, formatKnownBrokenRollbackRestart } from "../lib/upgrade-rollback.js";
|
|
@@ -48,6 +50,21 @@ function doctorRunAfterUpgrade(...args) {
|
|
|
48
50
|
function flairPackageDir(...args) {
|
|
49
51
|
return cli.flairPackageDir(...args);
|
|
50
52
|
}
|
|
53
|
+
function stageMcpRedirect(packageRoot) {
|
|
54
|
+
try {
|
|
55
|
+
const migration = planRedirectMigration({
|
|
56
|
+
configPath: join(packageRoot, "config.yaml"),
|
|
57
|
+
env: process.env,
|
|
58
|
+
});
|
|
59
|
+
const line = renderRedirectMigration(migration);
|
|
60
|
+
if (line)
|
|
61
|
+
console.log(` ${line}`);
|
|
62
|
+
}
|
|
63
|
+
catch (err) {
|
|
64
|
+
const reason = err instanceof Error ? err.code ?? err.message : "unknown error";
|
|
65
|
+
console.error(`warning: MCP OAuth redirect migration failed (${reason}). Set OAUTH_GITHUB_REDIRECT_URI to your MCP issuer origin + /oauth in ${join(packageRoot, ".env")}, then run: flair restart.`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
51
68
|
function fleetSweepCallerExitMessage(...args) {
|
|
52
69
|
return cli.fleetSweepCallerExitMessage(...args);
|
|
53
70
|
}
|
|
@@ -120,6 +137,39 @@ function upgradeStatusSuffix(...args) {
|
|
|
120
137
|
function verifyAuthedGet(...args) {
|
|
121
138
|
return cli.verifyAuthedGet(...args);
|
|
122
139
|
}
|
|
140
|
+
/**
|
|
141
|
+
* The options `flair upgrade --target` hands fabricUpgrade(), from the
|
|
142
|
+
* command's options and resolved credentials. `opsUrl` is what every remote
|
|
143
|
+
* command resolves (`resolveOpsUrl`: --ops-target / FLAIR_OPS_TARGET, else
|
|
144
|
+
* derived from --target); deploy() sends the MQTT-off configuration, restart and read-back
|
|
145
|
+
* there.
|
|
146
|
+
*/
|
|
147
|
+
export function buildFabricUpgradeOptions(opts, creds, resolveOpsUrl) {
|
|
148
|
+
return {
|
|
149
|
+
target: opts.target,
|
|
150
|
+
project: opts.project,
|
|
151
|
+
// flair#926: `--flair-version`, never `opts.version` — that attribute name
|
|
152
|
+
// belongs to the program's `-v, --version` and never reaches this action.
|
|
153
|
+
version: opts.flairVersion,
|
|
154
|
+
harperVersion: opts.harperVersion,
|
|
155
|
+
fabricUser: creds.fabricUser,
|
|
156
|
+
fabricPassword: creds.fabricPassword,
|
|
157
|
+
check: opts.check ?? false,
|
|
158
|
+
restart: opts.restart !== false,
|
|
159
|
+
replicated: opts.replicated !== false,
|
|
160
|
+
keepMqttConfig: opts.keepMqttConfig ?? false,
|
|
161
|
+
// --no-verify reaches deploy(): it skips the served-API verification and
|
|
162
|
+
// the post-restart MQTT step there too.
|
|
163
|
+
verify: opts.verify !== false,
|
|
164
|
+
opsUrl: resolveOpsUrl({ target: opts.target, opsTarget: opts.opsTarget }),
|
|
165
|
+
// flair#878 — previously unreachable from this command; see
|
|
166
|
+
// FabricUpgradeOptions.
|
|
167
|
+
deployRetries: Number(opts.deployRetries ?? 0),
|
|
168
|
+
ignoreReplicationErrors: opts.ignoreReplicationErrors ?? false,
|
|
169
|
+
convergenceCheck: opts.convergenceCheck !== false,
|
|
170
|
+
convergenceTimeoutMs: opts.convergenceTimeout != null ? Number(opts.convergenceTimeout) : undefined,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
123
173
|
async function runFabricUpgrade(opts) {
|
|
124
174
|
const green = (s) => `\x1b[32m${s}\x1b[0m`;
|
|
125
175
|
const red = (s) => `\x1b[31m${s}\x1b[0m`;
|
|
@@ -149,26 +199,8 @@ async function runFabricUpgrade(opts) {
|
|
|
149
199
|
// resolver's own warning strings.
|
|
150
200
|
for (const w of credWarnings)
|
|
151
201
|
console.error(dim(w));
|
|
152
|
-
const upgradeOpts = {
|
|
153
|
-
|
|
154
|
-
project: opts.project,
|
|
155
|
-
// flair#926: `--flair-version`, never `opts.version` — that attribute name
|
|
156
|
-
// belongs to the program's `-v, --version` and never reaches this action.
|
|
157
|
-
version: opts.flairVersion,
|
|
158
|
-
harperVersion: opts.harperVersion,
|
|
159
|
-
fabricUser,
|
|
160
|
-
fabricPassword,
|
|
161
|
-
check,
|
|
162
|
-
restart: opts.restart !== false,
|
|
163
|
-
replicated: opts.replicated !== false,
|
|
164
|
-
// flair#878 — previously unreachable from this command; see
|
|
165
|
-
// FabricUpgradeOptions.
|
|
166
|
-
deployRetries: Number(opts.deployRetries ?? 0),
|
|
167
|
-
ignoreReplicationErrors: opts.ignoreReplicationErrors ?? false,
|
|
168
|
-
convergenceCheck: opts.convergenceCheck !== false,
|
|
169
|
-
convergenceTimeoutMs: opts.convergenceTimeout != null ? Number(opts.convergenceTimeout) : undefined,
|
|
170
|
-
};
|
|
171
|
-
console.log(`${green("→")} Upgrading Fabric Flair at ${upgradeOpts.target}`);
|
|
202
|
+
const upgradeOpts = buildFabricUpgradeOptions(opts, { fabricUser, fabricPassword }, cli.resolveEffectiveOpsUrl);
|
|
203
|
+
console.log(`${green("→")} Upgrading Fabric Flair at ${safeUrl(upgradeOpts.target)}`);
|
|
172
204
|
if (check)
|
|
173
205
|
console.log(dim(" (--check: plan only, no deploy)"));
|
|
174
206
|
try {
|
|
@@ -178,7 +210,7 @@ async function runFabricUpgrade(opts) {
|
|
|
178
210
|
if (!check && !opts.yes && process.stdin.isTTY) {
|
|
179
211
|
const { createInterface } = await import("node:readline");
|
|
180
212
|
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
181
|
-
const answer = await new Promise((res) => rl.question(`Deploy a fresh ${green("@tpsdev-ai/flair")} to ${upgradeOpts.target}? [y/N] `, (a) => { rl.close(); res(a); }));
|
|
213
|
+
const answer = await new Promise((res) => rl.question(`Deploy a fresh ${green("@tpsdev-ai/flair")} to ${safeUrl(upgradeOpts.target)}? [y/N] `, (a) => { rl.close(); res(a); }));
|
|
182
214
|
if (!/^y(es)?$/i.test(answer.trim())) {
|
|
183
215
|
console.log("Aborted.");
|
|
184
216
|
return;
|
|
@@ -735,7 +767,7 @@ export function register(program) {
|
|
|
735
767
|
.option("--tree <dir>", "Upgrade this extracted package tree in place (npm pack / plain-tree lane). Default: the serving instance's packed tree when that is not the npm-global install")
|
|
736
768
|
.option("--restart", "[deprecated] no-op — restart now happens automatically after upgrade; use --no-restart to opt out")
|
|
737
769
|
.option("--no-restart", "Skip the restart after upgrade (stage new packages now, restart later)")
|
|
738
|
-
.option("--no-verify", "Skip post-restart health/version/auth verification (default: verify — so a broken upgrade can't report success; see flair#635)")
|
|
770
|
+
.option("--no-verify", "Skip post-restart health/version/auth verification (default: verify — so a broken upgrade can't report success; see flair#635); with --target, also skips deploy()'s served-API verification and its post-restart MQTT step")
|
|
739
771
|
.option("--snapshot", "Take a pre-upgrade ~/.flair/data snapshot before the package swap, keep-last-3 retention (default: off — see `flair snapshot create` to take one by hand, or `flair backup` for a logical export; flair#637)")
|
|
740
772
|
.option("--no-engine-snapshot", "Skip the pre-upgrade snapshot even when the Harper engine version is changing (flair#1047). The snapshot is automatic on engine-version changes because the tested-downgrade guarantee does not hold across engine boundaries. Opting out prints what is being given up.")
|
|
741
773
|
.option("--all", "Show transitive packages (e.g. flair-client) in the listing — verbose mode for debugging dep versions")
|
|
@@ -758,6 +790,8 @@ export function register(program) {
|
|
|
758
790
|
.option("--harper-version <semver>", "Pin harper to this version for --target (default: registry latest, floored at the flair#513 fix)")
|
|
759
791
|
.option("--project <name>", "Fabric component name for --target", "flair")
|
|
760
792
|
.option("--no-replicated", "Disable cluster-wide replication for --target (default: replicated=true)")
|
|
793
|
+
.option("--keep-mqtt-config", "For --target: leave the target's MQTT configuration as it is (default: set every MQTT listener off in the target's configuration before deploying, then, after the deploy's restart, request the shared workers' restart for an isolated application and read the saved configuration back; --no-restart and --no-verify skip those two; the listeners are not probed)")
|
|
794
|
+
.option("--ops-target <url>", "For --target: operations API URL for the MQTT-off configuration, restart and read-back (env: FLAIR_OPS_TARGET; default: derived from --target)")
|
|
761
795
|
.option("--yes", "Skip the confirmation prompt for --target")
|
|
762
796
|
.option("--install-hooks", "Consent to installing missing SessionStart hooks (claude-code / Codex) during upgrade. The hook executes at every session start — upgrade will not write it unprompted. Interactive runs prompt; non-interactive runs state the gap and withhold ✅ unless this flag is passed.")
|
|
763
797
|
.option("--no-fleet-verify", "Skip the automatic post-upgrade fleet convergence sweep for --target (default: sweep runs — see flair#636)")
|
|
@@ -772,6 +806,21 @@ export function register(program) {
|
|
|
772
806
|
.action(async (opts) => {
|
|
773
807
|
// ── Fabric-upgrade branch ───────────────────────────────────────────────
|
|
774
808
|
if (opts.target) {
|
|
809
|
+
// Every URL the Fabric upgrade takes is checked before anything is
|
|
810
|
+
// printed: a user name, password, query or fragment is refused. An
|
|
811
|
+
// operations API URL derived from a target that passes keeps its scheme,
|
|
812
|
+
// host and path with the operations port (fabricUpgrade() and deploy()
|
|
813
|
+
// check it again).
|
|
814
|
+
const refusal = deployUrlRefusal([
|
|
815
|
+
[opts.target, "deploy target URL (--target)"],
|
|
816
|
+
[opts.opsTarget || process.env.FLAIR_OPS_TARGET, "operations API URL (--ops-target / FLAIR_OPS_TARGET)"],
|
|
817
|
+
]);
|
|
818
|
+
if (refusal) {
|
|
819
|
+
console.error(`\x1b[31m${refusal}\x1b[0m`);
|
|
820
|
+
process.exit(1);
|
|
821
|
+
}
|
|
822
|
+
if (!opts.check)
|
|
823
|
+
console.log("OAuth redirect migration is local-only; --target requires target-side OAuth environment configuration.");
|
|
775
824
|
await runFabricUpgrade(opts);
|
|
776
825
|
return;
|
|
777
826
|
}
|
|
@@ -1090,6 +1139,8 @@ export function register(program) {
|
|
|
1090
1139
|
"(see above), so that is not a statement about what is running.");
|
|
1091
1140
|
return;
|
|
1092
1141
|
}
|
|
1142
|
+
if (!checkOnly)
|
|
1143
|
+
stageMcpRedirect(treeLane?.dir ?? flairPackageDir());
|
|
1093
1144
|
console.log(anyAhead || unknownFindings.length > 0 ? "\nNo upgrades available." : "\n✅ Everything is up to date.");
|
|
1094
1145
|
return;
|
|
1095
1146
|
}
|
|
@@ -1125,6 +1176,8 @@ export function register(program) {
|
|
|
1125
1176
|
// run will do. `npm install -g` remains wrong for flair-mcp either way
|
|
1126
1177
|
// (#1168/#1208).
|
|
1127
1178
|
if (totalUpgrades === 0) {
|
|
1179
|
+
if (!checkOnly)
|
|
1180
|
+
stageMcpRedirect(treeLane?.dir ?? flairPackageDir());
|
|
1128
1181
|
if (missing.length > 0) {
|
|
1129
1182
|
const npmMissing = missing.filter((f) => f.name !== FLAIR_MCP_PACKAGE);
|
|
1130
1183
|
const mcpMissing = missing.some((f) => f.name === FLAIR_MCP_PACKAGE);
|
|
@@ -1389,6 +1442,8 @@ export function register(program) {
|
|
|
1389
1442
|
if (deprecatedRestartFlagUsed) {
|
|
1390
1443
|
console.error("warning: --restart is deprecated and is now a no-op — flair upgrade restarts by default. Use --no-restart to skip it.");
|
|
1391
1444
|
}
|
|
1445
|
+
const swappedPackageRoot = treePlan?.treeDir ?? flairPackageDir();
|
|
1446
|
+
stageMcpRedirect(swappedPackageRoot);
|
|
1392
1447
|
if (!shouldRestart) {
|
|
1393
1448
|
console.log("\nRun: flair restart to use the new version");
|
|
1394
1449
|
if (treePlan) {
|
|
@@ -1615,7 +1670,6 @@ export function register(program) {
|
|
|
1615
1670
|
// from disk AFTER the swap. `null` (flair itself wasn't swapped, or the new
|
|
1616
1671
|
// tree can't be verified) falls back to an in-process restart, announced.
|
|
1617
1672
|
const flairWasSwapped = flairIsUpgrading && !flairInstallFailed;
|
|
1618
|
-
const swappedPackageRoot = treePlan?.treeDir ?? flairPackageDir();
|
|
1619
1673
|
let newCli = null;
|
|
1620
1674
|
if (flairWasSwapped) {
|
|
1621
1675
|
const resolved = resolveInstalledFlairCli(swappedPackageRoot, expectedFlairVersion);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { resolveKeyPath, buildEd25519Auth } from "../lib/auth-resolve.js";
|
|
1
|
+
import { resolveKeyPath, buildEd25519Auth, requestTarget, requestUrl } from "../lib/auth-resolve.js";
|
|
2
|
+
import { encodeRecordId } from "../lib/record-id-path.js";
|
|
2
3
|
let cli;
|
|
3
4
|
/** Bind shared CLI helpers. cli.ts calls this immediately before register(program). */
|
|
4
5
|
export function bindCli(fns) {
|
|
@@ -22,14 +23,13 @@ function parseEntitiesOptionOrExit(csv) {
|
|
|
22
23
|
// (WorkspaceState.put(), resources/WorkspaceState.ts), so this is a
|
|
23
24
|
// self-declaration the server verifies 1:1, not attribution-from-body.
|
|
24
25
|
//
|
|
25
|
-
// (flair#679, measured against a real spawned Harper):
|
|
26
|
-
//
|
|
27
|
-
//
|
|
28
|
-
//
|
|
29
|
-
//
|
|
30
|
-
//
|
|
31
|
-
//
|
|
32
|
-
// unlike post(), does NOT default createdAt/timestamp/agentId — the CLI
|
|
26
|
+
// (flair#679, measured against a real spawned Harper): through Harper 5.1.x a
|
|
27
|
+
// bare POST /WorkspaceState 405'd ("does not have a post method implemented to
|
|
28
|
+
// handle HTTP method POST"); the Harper this repo now pins routes it to
|
|
29
|
+
// WorkspaceState.post() and accepts it (harper#1956; the sanity test in
|
|
30
|
+
// test/integration/workspace-orgevent-cli-e2e.test.ts asserts 201). The CLI
|
|
31
|
+
// writes with PUT /<Table>/<id>, which works on both, as `soul set` does (#498).
|
|
32
|
+
// put(), unlike post(), does NOT default createdAt/timestamp/agentId — the CLI
|
|
33
33
|
// supplies them all explicitly below.
|
|
34
34
|
export const MAX_WORKSPACE_FIELD_LENGTH = 2000;
|
|
35
35
|
/** Register the `flair workspace` command group (flair#1635). */
|
|
@@ -75,7 +75,9 @@ export function register(program) {
|
|
|
75
75
|
// ref overwrites the same record, which is intentional (one row per
|
|
76
76
|
// agent+ref, not an append log).
|
|
77
77
|
const id = `${agentId}:${opts.ref}`;
|
|
78
|
-
const
|
|
78
|
+
const path = `/WorkspaceState/${encodeRecordId(id)}`;
|
|
79
|
+
const url = requestUrl(baseUrl, path);
|
|
80
|
+
const auth = buildEd25519Auth(agentId, "PUT", requestTarget(url), keyPath);
|
|
79
81
|
// agentId IS included in the body now — WorkspaceState.put() (unlike
|
|
80
82
|
// post()) does not auto-attribute from the signature, it 403s any
|
|
81
83
|
// mismatch. This is a self-declaration the server verifies against the
|
|
@@ -99,7 +101,7 @@ export function register(program) {
|
|
|
99
101
|
body.summary = opts.summary;
|
|
100
102
|
if (entities && entities.length > 0)
|
|
101
103
|
body.entities = entities;
|
|
102
|
-
const res = await fetch(
|
|
104
|
+
const res = await fetch(url, {
|
|
103
105
|
method: "PUT",
|
|
104
106
|
headers: { "Content-Type": "application/json", Authorization: auth },
|
|
105
107
|
body: JSON.stringify(body),
|
package/dist/component-env.js
CHANGED
|
@@ -39,31 +39,20 @@
|
|
|
39
39
|
//
|
|
40
40
|
// Hence: the file this module generates carries `FLAIR_PUBLIC_URL` and nothing
|
|
41
41
|
// else, and `assertNoSecretKeys` is a runtime guard, not a comment.
|
|
42
|
+
import { parseMcpComponentEnv } from "./lib/mcp-oauth-env-core.js";
|
|
43
|
+
import { NEVER_GENERATED_SECRET_KEYS } from "./lib/secret-keys.js";
|
|
42
44
|
/** The file Harper's `loadEnv` plugin is pointed at by flair's config.yaml. */
|
|
43
45
|
export const COMPONENT_ENV_FILENAME = ".env";
|
|
44
46
|
/** The one key `flair deploy` supplies. */
|
|
45
47
|
export const PUBLIC_URL_KEY = "FLAIR_PUBLIC_URL";
|
|
46
|
-
/**
|
|
47
|
-
*
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
export
|
|
54
|
-
"HDB_ADMIN_PASSWORD",
|
|
55
|
-
"FLAIR_ADMIN_PASSWORD",
|
|
56
|
-
"FLAIR_ADMIN_PASS",
|
|
57
|
-
"FABRIC_PASSWORD",
|
|
58
|
-
"FLAIR_CLUSTER_ADMIN_PASS",
|
|
59
|
-
"CLI_TARGET_PASSWORD",
|
|
60
|
-
// The DCR initial access token (resources/dcr-gate.ts). It is a bearer
|
|
61
|
-
// credential for an unauthenticated public endpoint, so it belongs in the
|
|
62
|
-
// process environment, never in a deploy payload — that payload is ingested
|
|
63
|
-
// into an hdb_deployment row and replicated to every node, per the argument
|
|
64
|
-
// at the top of this file.
|
|
65
|
-
"FLAIR_OAUTH_DCR_TOKEN",
|
|
66
|
-
];
|
|
48
|
+
/** The component's MCP issuer origin, when the operator set one — the issuer the
|
|
49
|
+
* `@harperfast/oauth` authorization server advertises. */
|
|
50
|
+
export const MCP_ISSUER_KEY = "FLAIR_MCP_ISSUER";
|
|
51
|
+
// Re-exported from ./lib/secret-keys.js, which has no imports so a plain
|
|
52
|
+
// `node` script can load it without a build step (flair#2589). The list lives
|
|
53
|
+
// there; the deploy-payload rationale remains above. This module keeps the
|
|
54
|
+
// public name stable for existing importers.
|
|
55
|
+
export { NEVER_GENERATED_SECRET_KEYS };
|
|
67
56
|
/**
|
|
68
57
|
* A key name that looks like it carries a credential. Used for the operator-facing
|
|
69
58
|
* notice only — matching is on the NAME, and the value is never read, printed, or
|
|
@@ -73,7 +62,7 @@ export function looksLikeSecretKey(name) {
|
|
|
73
62
|
return /(PASSWORD|PASSWD|SECRET|TOKEN|_KEY|APIKEY|CREDENTIAL)/i.test(name);
|
|
74
63
|
}
|
|
75
64
|
/**
|
|
76
|
-
*
|
|
65
|
+
* Does this URL name a loopback or unspecified destination?
|
|
77
66
|
*
|
|
78
67
|
* Deliberately a TEXT test, not a DNS lookup: this decides what gets baked into a
|
|
79
68
|
* deployed artifact, and a resolver answer at deploy time is not a property of the
|
|
@@ -94,10 +83,23 @@ export function isLoopbackUrl(raw) {
|
|
|
94
83
|
return isLoopbackHost(host);
|
|
95
84
|
}
|
|
96
85
|
export function isLoopbackHost(host) {
|
|
97
|
-
const
|
|
86
|
+
const bare = host.replace(/^\[|\]$/g, "");
|
|
87
|
+
if (!/^[0-9a-z._:-]+$/i.test(bare))
|
|
88
|
+
return false;
|
|
89
|
+
let h;
|
|
90
|
+
try {
|
|
91
|
+
// The URL parser gives one lowercase spelling per IP literal:
|
|
92
|
+
// `127.1` -> `127.0.0.1`, `[0::1]` -> `[::1]`, `[::ffff:127.0.0.1]` -> `[::ffff:7f00:1]`.
|
|
93
|
+
h = new URL(`http://${bare.includes(":") ? `[${bare}]` : bare}`).hostname.replace(/\.$/, "");
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
98
|
if (h === "localhost" || h.endsWith(".localhost"))
|
|
99
99
|
return true;
|
|
100
|
-
if (h === "::
|
|
100
|
+
if (h === "0.0.0.0" || h === "[::]" || h === "[::ffff:0:0]")
|
|
101
|
+
return true;
|
|
102
|
+
if (h === "[::1]" || /^\[::ffff:7f[0-9a-f]{2}:[0-9a-f]{1,4}\]$/.test(h))
|
|
101
103
|
return true;
|
|
102
104
|
return /^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(h);
|
|
103
105
|
}
|
|
@@ -118,25 +120,13 @@ export function envKeyNames(text) {
|
|
|
118
120
|
}
|
|
119
121
|
return names;
|
|
120
122
|
}
|
|
121
|
-
/**
|
|
122
|
-
*
|
|
123
|
-
* `FLAIR_PUBLIC_URL`, which is not a secret; nothing here reads any other value.
|
|
124
|
-
*/
|
|
123
|
+
/** Return the named file value using the shared parser; the last assignment wins.
|
|
124
|
+
* This does not overlay the process environment. */
|
|
125
125
|
export function readEnvValue(text, key) {
|
|
126
126
|
if (!text)
|
|
127
127
|
return null;
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
if (!m || m[1] !== key)
|
|
131
|
-
continue;
|
|
132
|
-
let v = line.slice(line.indexOf("=") + 1).trim();
|
|
133
|
-
if ((v.startsWith('"') && v.endsWith('"') && v.length >= 2) ||
|
|
134
|
-
(v.startsWith("'") && v.endsWith("'") && v.length >= 2)) {
|
|
135
|
-
v = v.slice(1, -1);
|
|
136
|
-
}
|
|
137
|
-
return v;
|
|
138
|
-
}
|
|
139
|
-
return null;
|
|
128
|
+
const values = parseMcpComponentEnv(text);
|
|
129
|
+
return Object.prototype.hasOwnProperty.call(values, key) ? values[key] : null;
|
|
140
130
|
}
|
|
141
131
|
/**
|
|
142
132
|
* Throws if the transition from `existing` to `generated` INTRODUCES any key flair
|
|
@@ -199,7 +189,7 @@ export function planComponentEnv(existing, publicUrl) {
|
|
|
199
189
|
`proxy or CDN the existing value is the correct one, otherwise edit that file.`);
|
|
200
190
|
}
|
|
201
191
|
if (isLoopbackUrl(operatorValue)) {
|
|
202
|
-
notices.push(`${PUBLIC_URL_KEY} in ${COMPONENT_ENV_FILENAME} is a loopback address ` +
|
|
192
|
+
notices.push(`${PUBLIC_URL_KEY} in ${COMPONENT_ENV_FILENAME} is a loopback or unspecified address ` +
|
|
203
193
|
`(${operatorValue}). OAuth discovery and A2A discovery advertise it verbatim, so ` +
|
|
204
194
|
`remote clients will be told to connect to their own machine (flair#1000).`);
|
|
205
195
|
}
|
package/dist/deploy.js
CHANGED
|
@@ -4,10 +4,14 @@ import { cpSync, existsSync, mkdtempSync, readFileSync, readdirSync, rmSync, wri
|
|
|
4
4
|
import { tmpdir } from "node:os";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
import { createRequire } from "node:module";
|
|
7
|
-
import { COMPONENT_ENV_FILENAME, PUBLIC_URL_KEY, isLoopbackUrl, planComponentEnv, publicUrlRemedy, } from "./component-env.js";
|
|
7
|
+
import { COMPONENT_ENV_FILENAME, MCP_ISSUER_KEY, PUBLIC_URL_KEY, isLoopbackUrl, planComponentEnv, publicUrlRemedy, readEnvValue, } from "./component-env.js";
|
|
8
8
|
import { awaitOriginQuiescent, awaitReplicationConvergence, defaultConvergenceDeps, parseReplicationFailure, } from "./replication-convergence.js";
|
|
9
9
|
import { DEFAULT_STAMP_VERIFY_TIMEOUT_MS, verifyStampMigrationConverged } from "./stamp-migration-verify.js";
|
|
10
10
|
import { FABRIC_NPM_INSTALL_COMMAND } from "./fabric-npm-install.js";
|
|
11
|
+
import { discriminateMcpOAuthDiscovery, reportMcpOAuthDiscovery } from "./lib/mcp-enable.js";
|
|
12
|
+
import { mcpOAuthEnabledFromComponentEnv } from "./lib/mcp-oauth-env.js";
|
|
13
|
+
import { applyMqttOffConfiguration, assertSafeUrl, completeMqttOff, sharedWorkerRestartInstruction } from "./mqtt-off-deploy.js";
|
|
14
|
+
import { resolveOpsUrlFromTarget } from "./lib/ops-url.js";
|
|
11
15
|
// Files that must be PRESENT for a deploy root to be usable at all — a
|
|
12
16
|
// preflight sanity check, not the payload definition.
|
|
13
17
|
//
|
|
@@ -371,9 +375,9 @@ export function describeDeployFailure(failures, convergence) {
|
|
|
371
375
|
// their last message immediately before process.exit() — had been received,
|
|
372
376
|
// so REPLICATION_FAILURE_RE silently missed a match it should have made and
|
|
373
377
|
// runHarperDeploy fell through to the generic "exited with code N" error.
|
|
374
|
-
function spawnHarperCaptured(bin, args, cwd, env) {
|
|
378
|
+
function spawnHarperCaptured(bin, args, cwd, env, runtime = process.execPath) {
|
|
375
379
|
return new Promise((resolveP, rejectP) => {
|
|
376
|
-
const p = spawn(
|
|
380
|
+
const p = spawn(runtime, [bin, ...args], {
|
|
377
381
|
cwd,
|
|
378
382
|
stdio: ["inherit", "pipe", "pipe"],
|
|
379
383
|
env,
|
|
@@ -414,7 +418,7 @@ async function runHarperDeploy(bin, args, cwd, env, opts, targetUrl, project) {
|
|
|
414
418
|
const failures = [];
|
|
415
419
|
let lastConvergence = null;
|
|
416
420
|
for (let attempt = 1; attempt <= totalAttempts; attempt++) {
|
|
417
|
-
const { code, output } = await spawnHarperCaptured(bin, args, cwd, env);
|
|
421
|
+
const { code, output } = await spawnHarperCaptured(bin, args, cwd, env, opts.harperRuntime);
|
|
418
422
|
if (code === 0)
|
|
419
423
|
return { replicationWarning: false, convergedAfterReplicationError: false };
|
|
420
424
|
const isReplicationFailure = REPLICATION_FAILURE_RE.test(output);
|
|
@@ -875,6 +879,52 @@ export async function verifyDeployServing(o) {
|
|
|
875
879
|
await verifyResourcesServing(baseUrl, resources, fetchImpl);
|
|
876
880
|
onProgress?.(`served API verified non-404 for ${resources.length} resource(s)`);
|
|
877
881
|
}
|
|
882
|
+
/**
|
|
883
|
+
* flair#2283 — post-deploy verification that the target's OAuth discovery
|
|
884
|
+
* advertises the MCP token endpoint of an issuer the deploy knows.
|
|
885
|
+
*
|
|
886
|
+
* Runs the SAME discriminator `flair mcp enable` runs (src/lib/mcp-enable.ts),
|
|
887
|
+
* imported rather than re-derived. The discriminator binds a positive
|
|
888
|
+
* classification to a CALLER-KNOWN issuer: the document's own `issuer` must
|
|
889
|
+
* EQUAL one of the candidates this deploy knows independently of the document —
|
|
890
|
+
* the configured `FLAIR_PUBLIC_URL` / `FLAIR_MCP_ISSUER` read from the shipped
|
|
891
|
+
* component `.env`, plus the origin shipped to — and its `token_endpoint` must be
|
|
892
|
+
* that issuer's endpoint. A document advertising flair's own `<issuer>/OAuthToken`
|
|
893
|
+
* is a named failure when the shipped component `.env` implies MCP OAuth is enabled
|
|
894
|
+
* and the document's issuer is one of those candidates. An unreadable, non-JSON, or
|
|
895
|
+
* unrecognized document — including one whose issuer is not a candidate — is
|
|
896
|
+
* reported as unverified, never as a pass.
|
|
897
|
+
*
|
|
898
|
+
* The deploy cannot read the TARGET's environment; `mcpOAuthConfigured` and the
|
|
899
|
+
* `FLAIR_PUBLIC_URL` / `FLAIR_MCP_ISSUER` candidates are read from the `.env` it
|
|
900
|
+
* shipped.
|
|
901
|
+
*
|
|
902
|
+
* A staged `.env` read failure is reported by name before discovery is probed.
|
|
903
|
+
*/
|
|
904
|
+
export async function verifyDeployedMcpDiscovery(o) {
|
|
905
|
+
if (o.stagedEnvReadError) {
|
|
906
|
+
throw new Error(`deploy verification: could not read the staged .env; discovery not verified — ${o.stagedEnvReadError}`);
|
|
907
|
+
}
|
|
908
|
+
const discovery = await discriminateMcpOAuthDiscovery(o.url, {
|
|
909
|
+
fetchImpl: o.fetchImpl,
|
|
910
|
+
expectedIssuers: [o.url, ...(o.knownIssuers ?? [])],
|
|
911
|
+
});
|
|
912
|
+
const report = reportMcpOAuthDiscovery(discovery, o.mcpOAuthConfigured);
|
|
913
|
+
if (report.severity === "error") {
|
|
914
|
+
throw new Error(`deploy verification: ${report.lines.join(" ")}`);
|
|
915
|
+
}
|
|
916
|
+
if (report.severity === "warn") {
|
|
917
|
+
for (const line of report.lines)
|
|
918
|
+
console.warn(`⚠ flair deploy: ${line}`);
|
|
919
|
+
}
|
|
920
|
+
else {
|
|
921
|
+
for (const line of report.lines)
|
|
922
|
+
o.onProgress?.(line);
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
// The MQTT-off step of this channel lives in src/mqtt-off-deploy.ts; these
|
|
926
|
+
// re-exports keep it reachable from the deploy module.
|
|
927
|
+
export { applyMqttOffConfiguration, buildMqttOffOperation, completeMqttOff } from "./mqtt-off-deploy.js";
|
|
878
928
|
export async function deploy(opts) {
|
|
879
929
|
const errors = validateOptions(opts);
|
|
880
930
|
if (errors.length) {
|
|
@@ -886,6 +936,12 @@ export async function deploy(opts) {
|
|
|
886
936
|
const version = opts.version ?? pkg.version;
|
|
887
937
|
const project = opts.project ?? "flair";
|
|
888
938
|
const url = buildTargetUrl(opts);
|
|
939
|
+
// Every URL the channel uses is http or https with a host, and scheme, host,
|
|
940
|
+
// port and path only: anything else is refused before anything is sent or
|
|
941
|
+
// printed (src/mqtt-off-deploy.ts assertSafeUrl).
|
|
942
|
+
assertSafeUrl(url, "deploy target URL");
|
|
943
|
+
const opsUrl = opts.opsUrl ?? resolveOpsUrlFromTarget(url);
|
|
944
|
+
assertSafeUrl(opsUrl, "operations API URL");
|
|
889
945
|
if (opts.dryRun) {
|
|
890
946
|
return { url, project, version, packageRoot, dryRun: true };
|
|
891
947
|
}
|
|
@@ -896,6 +952,27 @@ export async function deploy(opts) {
|
|
|
896
952
|
}
|
|
897
953
|
const harperBin = resolveHarperBin(packageRoot);
|
|
898
954
|
const args = buildHarperDeployArgs(opts, url, project);
|
|
955
|
+
// MQTT off on the target's configuration before anything is deployed
|
|
956
|
+
// (src/mqtt-off-deploy.ts, step 1); read back after the deploy's restart below.
|
|
957
|
+
let mqttPeers = [];
|
|
958
|
+
if (opts.keepMqttConfig) {
|
|
959
|
+
opts.onProgress?.("--keep-mqtt-config: leaving the target's MQTT configuration as it is");
|
|
960
|
+
}
|
|
961
|
+
else {
|
|
962
|
+
({ peers: mqttPeers } = await applyMqttOffConfiguration({
|
|
963
|
+
url: opsUrl,
|
|
964
|
+
fabricUser: opts.fabricUser,
|
|
965
|
+
fabricPassword: opts.fabricPassword,
|
|
966
|
+
replicated: opts.replicated !== false,
|
|
967
|
+
fetchImpl: opts.operationsFetch,
|
|
968
|
+
onProgress: opts.onProgress,
|
|
969
|
+
}));
|
|
970
|
+
if (opts.restart === false) {
|
|
971
|
+
const notice = `--no-restart: the MQTT-off configuration takes effect when the target's worker threads restart; ${sharedWorkerRestartInstruction(opsUrl)}`;
|
|
972
|
+
console.warn(`⚠ flair deploy: ${notice}`);
|
|
973
|
+
opts.onProgress?.(notice);
|
|
974
|
+
}
|
|
975
|
+
}
|
|
899
976
|
// Credentials go via env, not argv, so they don't appear in `ps` output
|
|
900
977
|
// for the lifetime of the Harper child process. Harper's cliOperations
|
|
901
978
|
// reads CLI_TARGET_USERNAME / CLI_TARGET_PASSWORD as env fallbacks.
|
|
@@ -917,12 +994,57 @@ export async function deploy(opts) {
|
|
|
917
994
|
}
|
|
918
995
|
let replicationWarning;
|
|
919
996
|
let convergedAfterReplicationError;
|
|
997
|
+
// flair#2283: infer MCP OAuth enablement AND read the caller-known issuers from
|
|
998
|
+
// the shipped component `.env` before cleaning up the staged tree. This does not
|
|
999
|
+
// read target environment. Staging keeps an operator's FLAIR_PUBLIC_URL when it
|
|
1000
|
+
// differs from the deploy target (component-env.ts planComponentEnv), so the
|
|
1001
|
+
// shipped value — not the target URL alone — is the caller-known issuer the
|
|
1002
|
+
// discovery check binds against.
|
|
1003
|
+
let mcpOAuthConfigured = false;
|
|
1004
|
+
let deployedKnownIssuers = [];
|
|
1005
|
+
// Carry a staged `.env` read failure to discovery verification.
|
|
1006
|
+
let stagedEnvReadError = null;
|
|
920
1007
|
try {
|
|
921
1008
|
({ replicationWarning, convergedAfterReplicationError } = await runHarperDeploy(harperBin, args, staged.dir, childEnv, opts, url, project));
|
|
922
1009
|
}
|
|
923
1010
|
finally {
|
|
1011
|
+
try {
|
|
1012
|
+
const envPath = join(staged.dir, COMPONENT_ENV_FILENAME);
|
|
1013
|
+
const shippedEnvText = existsSync(envPath) ? readFileSync(envPath, "utf8") : null;
|
|
1014
|
+
mcpOAuthConfigured = mcpOAuthEnabledFromComponentEnv(shippedEnvText);
|
|
1015
|
+
deployedKnownIssuers = [readEnvValue(shippedEnvText, PUBLIC_URL_KEY), readEnvValue(shippedEnvText, MCP_ISSUER_KEY)].filter((issuer) => typeof issuer === "string" && issuer.trim() !== "");
|
|
1016
|
+
}
|
|
1017
|
+
catch (err) {
|
|
1018
|
+
mcpOAuthConfigured = false;
|
|
1019
|
+
deployedKnownIssuers = [];
|
|
1020
|
+
stagedEnvReadError = String(err?.message ?? err);
|
|
1021
|
+
}
|
|
924
1022
|
staged.cleanup();
|
|
925
1023
|
}
|
|
1024
|
+
// After the deploy's restart: read the saved configuration back and, for an
|
|
1025
|
+
// isolated application, request the shared workers' restart
|
|
1026
|
+
// (src/mqtt-off-deploy.ts, step 2). It reports what was set and requested;
|
|
1027
|
+
// it does not probe the listeners.
|
|
1028
|
+
if (!opts.keepMqttConfig && opts.restart !== false) {
|
|
1029
|
+
if (opts.mqttCheck ?? opts.verify !== false) {
|
|
1030
|
+
await completeMqttOff({
|
|
1031
|
+
url: opsUrl,
|
|
1032
|
+
project,
|
|
1033
|
+
fabricUser: opts.fabricUser,
|
|
1034
|
+
fabricPassword: opts.fabricPassword,
|
|
1035
|
+
replicated: opts.replicated !== false,
|
|
1036
|
+
peers: mqttPeers,
|
|
1037
|
+
fetchImpl: opts.operationsFetch,
|
|
1038
|
+
onProgress: opts.onProgress,
|
|
1039
|
+
});
|
|
1040
|
+
}
|
|
1041
|
+
else {
|
|
1042
|
+
const notice = `the post-restart MQTT step did not run${opts.mqttCheck === false ? "" : " (--no-verify)"}: the saved configuration was not read back, ` +
|
|
1043
|
+
`and no restart of the shared worker threads was requested for an isolated application; ${sharedWorkerRestartInstruction(opsUrl)} if Flair is isolated there`;
|
|
1044
|
+
console.warn(`⚠ flair deploy: ${notice}`);
|
|
1045
|
+
opts.onProgress?.(notice);
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
926
1048
|
// harper can print "Successfully deployed" for a component that isn't
|
|
927
1049
|
// actually serving anything (the incident this closes: an empty deploy,
|
|
928
1050
|
// reported success, /Memory 404ing in prod). Verify by curling the served
|
|
@@ -967,6 +1089,16 @@ export async function deploy(opts) {
|
|
|
967
1089
|
opts.onProgress?.(`issuer check did not run — ${issuerCheck.detail}`);
|
|
968
1090
|
}
|
|
969
1091
|
}
|
|
1092
|
+
// flair#2283: the SAME discovery discriminator `flair mcp enable` runs — does
|
|
1093
|
+
// the target's OAuth discovery advertise the expected MCP token endpoint?
|
|
1094
|
+
// See verifyDeployedMcpDiscovery.
|
|
1095
|
+
await verifyDeployedMcpDiscovery({
|
|
1096
|
+
url,
|
|
1097
|
+
mcpOAuthConfigured,
|
|
1098
|
+
knownIssuers: deployedKnownIssuers,
|
|
1099
|
+
stagedEnvReadError,
|
|
1100
|
+
onProgress: opts.onProgress,
|
|
1101
|
+
});
|
|
970
1102
|
}
|
|
971
1103
|
return {
|
|
972
1104
|
url,
|