@indigoai-us/hq-cloud 6.18.104 → 6.18.106
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/bin/legacy-sync-wake.d.ts +25 -0
- package/dist/bin/legacy-sync-wake.d.ts.map +1 -0
- package/dist/bin/legacy-sync-wake.js +159 -0
- package/dist/bin/legacy-sync-wake.js.map +1 -0
- package/dist/bin/sync-runner-company.d.ts.map +1 -1
- package/dist/bin/sync-runner-company.js +6 -8
- package/dist/bin/sync-runner-company.js.map +1 -1
- package/dist/bin/sync-runner-watch-loop.d.ts +2 -0
- package/dist/bin/sync-runner-watch-loop.d.ts.map +1 -1
- package/dist/bin/sync-runner-watch-loop.js +76 -1
- package/dist/bin/sync-runner-watch-loop.js.map +1 -1
- package/dist/bin/sync-runner.d.ts +3 -0
- package/dist/bin/sync-runner.d.ts.map +1 -1
- package/dist/bin/sync-runner.js +9 -0
- package/dist/bin/sync-runner.js.map +1 -1
- package/dist/cli/conflict.d.ts +8 -2
- package/dist/cli/conflict.d.ts.map +1 -1
- package/dist/cli/conflict.js +15 -10
- package/dist/cli/conflict.js.map +1 -1
- package/dist/cli/share.d.ts +8 -0
- package/dist/cli/share.d.ts.map +1 -1
- package/dist/cli/share.js +231 -30
- package/dist/cli/share.js.map +1 -1
- package/dist/cli/sync.d.ts.map +1 -1
- package/dist/cli/sync.js +33 -2
- package/dist/cli/sync.js.map +1 -1
- package/dist/lib/same-path-upload-lock.d.ts +39 -1
- package/dist/lib/same-path-upload-lock.d.ts.map +1 -1
- package/dist/lib/same-path-upload-lock.js +177 -1
- package/dist/lib/same-path-upload-lock.js.map +1 -1
- package/dist/object-io.d.ts +12 -0
- package/dist/object-io.d.ts.map +1 -1
- package/dist/object-io.js +28 -1
- package/dist/object-io.js.map +1 -1
- package/dist/outposts/command.d.ts.map +1 -1
- package/dist/outposts/command.js +3 -1
- package/dist/outposts/command.js.map +1 -1
- package/dist/outposts/company.d.ts +10 -1
- package/dist/outposts/company.d.ts.map +1 -1
- package/dist/outposts/company.js +17 -0
- package/dist/outposts/company.js.map +1 -1
- package/dist/sync-core.d.ts +13 -4
- package/dist/sync-core.d.ts.map +1 -1
- package/dist/sync-core.js +22 -4
- package/dist/sync-core.js.map +1 -1
- package/dist/types.d.ts +6 -4
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -49,7 +49,8 @@ import { DEFAULT_REALTIME_AUTHORIZATION_TIMEOUT_MS } from "../sync/realtime-roll
|
|
|
49
49
|
import { RealtimeTelemetrySpan, writeRealtimeTelemetryToStderr, } from "../sync/realtime-telemetry.js";
|
|
50
50
|
import { InlineSyncWorkerAdapter, } from "../sync/sync-work.js";
|
|
51
51
|
import { buildRoutePullArgv, buildScopedPushArgv, buildScopedDrainPullArgv, buildTargetedPullArgv, isWatchRouteSelected, routeChangeToTarget, routeKey, scopePathForRoute, } from "./sync-runner-watch-routes.js";
|
|
52
|
-
import { resolveSkipCompanies } from "./sync-runner-planning.js";
|
|
52
|
+
import { buildFanoutPlan, resolveSkipCompanies } from "./sync-runner-planning.js";
|
|
53
|
+
import { LegacySyncWakeBridge } from "./legacy-sync-wake.js";
|
|
53
54
|
import { buildPassRequestArgv } from "./sync-pass-request.js";
|
|
54
55
|
const FULL_RECONCILE_EVERY_TICKS = 10;
|
|
55
56
|
const warnedUnresolvedReceiverCompanies = new Set();
|
|
@@ -3149,6 +3150,77 @@ export async function runWatchLoop(argv, parsed, deps, runtime) {
|
|
|
3149
3150
|
}
|
|
3150
3151
|
};
|
|
3151
3152
|
let nextCoordinatorCausality = 0;
|
|
3153
|
+
const locallyLegacyTarget = (target) => {
|
|
3154
|
+
const route = target.personalMode ? { kind: "personal" } : { kind: "company", slug: target.slug };
|
|
3155
|
+
return !stopped && isWatchRouteSelected(route, watchRouteSelection) &&
|
|
3156
|
+
(target.personalMode || !resolveSkipCompanies().has(target.slug)) &&
|
|
3157
|
+
!fs.existsSync(path.join(getStateDir(), "sync-core", "engines", target.uid, ".hq", "sync-core", "owned", `${target.uid}.json`));
|
|
3158
|
+
};
|
|
3159
|
+
const wakeToken = deps.getAccessToken ?? runtime.defaultGetAccessToken;
|
|
3160
|
+
const wakeClaims = deps.getIdTokenClaims ?? runtime.defaultGetIdTokenClaims;
|
|
3161
|
+
const normalizedWakeClaims = (raw) => {
|
|
3162
|
+
if (!raw || typeof raw !== "object" || !("sub" in raw) || typeof raw.sub !== "string" || !raw.sub)
|
|
3163
|
+
return null;
|
|
3164
|
+
return {
|
|
3165
|
+
sub: raw.sub,
|
|
3166
|
+
email: "email" in raw && typeof raw.email === "string" ? raw.email : undefined,
|
|
3167
|
+
"custom:entityType": "custom:entityType" in raw && typeof raw["custom:entityType"] === "string" ? raw["custom:entityType"] : undefined,
|
|
3168
|
+
"custom:entityUid": "custom:entityUid" in raw && typeof raw["custom:entityUid"] === "string" ? raw["custom:entityUid"] : undefined,
|
|
3169
|
+
};
|
|
3170
|
+
};
|
|
3171
|
+
const identityOf = (raw) => {
|
|
3172
|
+
const claims = normalizedWakeClaims(raw);
|
|
3173
|
+
return claims ? JSON.stringify([claims.sub, claims["custom:entityUid"] ?? null]) : null;
|
|
3174
|
+
};
|
|
3175
|
+
const resolveLegacyWakeTarget = deps.resolveLegacyWakeTarget ?? (async (expected) => {
|
|
3176
|
+
await wakeToken();
|
|
3177
|
+
const claims = normalizedWakeClaims(wakeClaims());
|
|
3178
|
+
const identity = identityOf(claims);
|
|
3179
|
+
if (!identity)
|
|
3180
|
+
return null;
|
|
3181
|
+
const client = new VaultClient({ apiUrl: runtime.apiUrl, authToken: wakeToken, region: runtime.region });
|
|
3182
|
+
const memberships = expected.personalMode ? [] : (await client.listMyMemberships())
|
|
3183
|
+
.filter((member) => member.status === "active" && member.companyUid === expected.uid);
|
|
3184
|
+
if (!expected.personalMode && memberships.length === 0)
|
|
3185
|
+
return null;
|
|
3186
|
+
const result = await buildFanoutPlan({
|
|
3187
|
+
memberships, companies: !expected.personalMode, personal: expected.personalMode === true,
|
|
3188
|
+
skipPersonal: watchRouteSelection.skipPersonal, client, claims,
|
|
3189
|
+
resolveSkipPersonal: (flag) => flag || watchRouteSelection.skipPersonal,
|
|
3190
|
+
skipCompanies: resolveSkipCompanies(),
|
|
3191
|
+
});
|
|
3192
|
+
await wakeToken();
|
|
3193
|
+
if (identityOf(wakeClaims()) !== identity || result.status !== "plan")
|
|
3194
|
+
return null;
|
|
3195
|
+
return result.plan.find((target) => target.uid === expected.uid && target.slug === expected.slug &&
|
|
3196
|
+
(target.personalMode === true) === (expected.personalMode === true)) ?? null;
|
|
3197
|
+
});
|
|
3198
|
+
const currentLegacyTarget = async (target) => {
|
|
3199
|
+
if (!locallyLegacyTarget(target))
|
|
3200
|
+
return null;
|
|
3201
|
+
try {
|
|
3202
|
+
const current = await resolveLegacyWakeTarget(target);
|
|
3203
|
+
return current && current.uid === target.uid && current.slug === target.slug &&
|
|
3204
|
+
(current.personalMode === true) === (target.personalMode === true) && locallyLegacyTarget(current) ? current : null;
|
|
3205
|
+
}
|
|
3206
|
+
catch {
|
|
3207
|
+
return null;
|
|
3208
|
+
}
|
|
3209
|
+
};
|
|
3210
|
+
const legacyWakeBridge = eventPush && drainRunsPull && resolveEventSync(process.env.HQ_SYNC_EVENT_SYNC) && runtime.subscribeTargets
|
|
3211
|
+
? new LegacySyncWakeBridge({
|
|
3212
|
+
statePath: path.join(getStateDir(), "work-mesh", "sync-wake.json"),
|
|
3213
|
+
canPull: async (target) => (await currentLegacyTarget(target)) !== null,
|
|
3214
|
+
pull: async (target) => {
|
|
3215
|
+
const route = target.personalMode ? { kind: "personal" } : { kind: "company", slug: target.uid };
|
|
3216
|
+
const outcome = await runGuarded(buildRoutePullArgv(route, passArgv), async () => {
|
|
3217
|
+
if (!await currentLegacyTarget(target))
|
|
3218
|
+
throw new Error("legacy wake no longer authorized");
|
|
3219
|
+
}, "slow", "chore", false, undefined, false, undefined, false, undefined, "sync-wake");
|
|
3220
|
+
return passExitCode(outcome) === 0;
|
|
3221
|
+
},
|
|
3222
|
+
}) : null;
|
|
3223
|
+
const detachWakeTargets = runtime.subscribeTargets?.((targets, complete) => legacyWakeBridge?.setTargets(targets, complete));
|
|
3152
3224
|
const realtimeWork = (source, direction, paths, lane, sizeClass = "unknown") => ({
|
|
3153
3225
|
class: "realtime",
|
|
3154
3226
|
source,
|
|
@@ -5334,6 +5406,7 @@ export async function runWatchLoop(argv, parsed, deps, runtime) {
|
|
|
5334
5406
|
// the guarded queue, but every surface must still be constructed once.
|
|
5335
5407
|
const firstActivation = !eventPushSurfacesActivated;
|
|
5336
5408
|
eventPushSurfacesActivated = true;
|
|
5409
|
+
legacyWakeBridge?.start();
|
|
5337
5410
|
const clock = deps.clock ?? systemClock;
|
|
5338
5411
|
// Quiet-period debounce + max-wait ceiling (HQ_SYNC_EVENT_DEBOUNCE_MS /
|
|
5339
5412
|
// HQ_SYNC_EVENT_MAX_WAIT_MS): rapid-fire editor bursts collapse into one
|
|
@@ -6106,6 +6179,8 @@ export async function runWatchLoop(argv, parsed, deps, runtime) {
|
|
|
6106
6179
|
if (stopped)
|
|
6107
6180
|
return shutdownPromise ?? Promise.resolve();
|
|
6108
6181
|
stopped = true;
|
|
6182
|
+
legacyWakeBridge?.stop();
|
|
6183
|
+
detachWakeTargets?.();
|
|
6109
6184
|
clearInterval(watcherPushStagesTimer);
|
|
6110
6185
|
if (durableWatcherPersistTimer !== undefined)
|
|
6111
6186
|
clearTimeout(durableWatcherPersistTimer);
|