@lesliechan721/aw 0.1.0-beta.76 → 0.1.0-beta.79
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/scripts/test-plugin-scripts.js +31 -3
- package/dist/scripts/test-plugin-scripts.js.map +1 -1
- package/dist/src/commands/public-lifecycle-result.d.ts +3 -1
- package/dist/src/commands/public-lifecycle-result.js +59 -2
- package/dist/src/commands/public-lifecycle-result.js.map +1 -1
- package/dist/src/commands/public-plugin-query.js +8 -5
- package/dist/src/commands/public-plugin-query.js.map +1 -1
- package/dist/src/commands/rebuild-command.d.ts +1 -0
- package/dist/src/commands/rebuild-command.js +13 -1
- package/dist/src/commands/rebuild-command.js.map +1 -1
- package/dist/src/commands/rebuild-platform-integration.js +4 -3
- package/dist/src/commands/rebuild-platform-integration.js.map +1 -1
- package/dist/src/commands/runtime.d.ts +1 -1
- package/dist/src/commands/runtime.js +23 -4
- package/dist/src/commands/runtime.js.map +1 -1
- package/dist/src/commands/wizard.js +3 -2
- package/dist/src/commands/wizard.js.map +1 -1
- package/dist/src/index.js +4 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/output/public-result.d.ts +5 -0
- package/dist/src/output/public-result.js +10 -0
- package/dist/src/output/public-result.js.map +1 -1
- package/dist/src/platforms/capabilities.js +8 -5
- package/dist/src/platforms/capabilities.js.map +1 -1
- package/dist/src/platforms/contracts.d.ts +1 -0
- package/dist/src/platforms/discovery.d.ts +11 -0
- package/dist/src/platforms/discovery.js +53 -4
- package/dist/src/platforms/discovery.js.map +1 -1
- package/dist/src/platforms/gemini-consent.d.ts +2 -2
- package/dist/src/platforms/gemini-consent.js +8 -6
- package/dist/src/platforms/gemini-consent.js.map +1 -1
- package/dist/src/platforms/inspection-grok.js +7 -2
- package/dist/src/platforms/inspection-grok.js.map +1 -1
- package/dist/src/platforms/inspection-native.js +3 -4
- package/dist/src/platforms/inspection-native.js.map +1 -1
- package/dist/src/platforms/inspection-opencode.js +3 -2
- package/dist/src/platforms/inspection-opencode.js.map +1 -1
- package/dist/src/platforms/inspection-pi.js +0 -4
- package/dist/src/platforms/inspection-pi.js.map +1 -1
- package/dist/src/platforms/inspection-query.d.ts +7 -0
- package/dist/src/platforms/inspection-query.js +69 -9
- package/dist/src/platforms/inspection-query.js.map +1 -1
- package/dist/src/platforms/inspection.d.ts +2 -0
- package/dist/src/platforms/inspection.js +8 -0
- package/dist/src/platforms/inspection.js.map +1 -1
- package/dist/src/platforms/lifecycle-native-services.js +2 -2
- package/dist/src/platforms/lifecycle-native-services.js.map +1 -1
- package/dist/src/platforms/lifecycle-native.js +21 -15
- package/dist/src/platforms/lifecycle-native.js.map +1 -1
- package/dist/src/platforms/lifecycle.js +25 -9
- package/dist/src/platforms/lifecycle.js.map +1 -1
- package/dist/src/portable/recovery.d.ts +2 -1
- package/dist/src/portable/recovery.js +4 -2
- package/dist/src/portable/recovery.js.map +1 -1
- package/dist/src/portable/writer.d.ts +3 -0
- package/dist/src/portable/writer.js +8 -3
- package/dist/src/portable/writer.js.map +1 -1
- package/dist/src/recovery/coordinator.js +21 -0
- package/dist/src/recovery/coordinator.js.map +1 -1
- package/dist/src/recovery/demand.d.ts +6 -0
- package/dist/src/recovery/demand.js +20 -7
- package/dist/src/recovery/demand.js.map +1 -1
- package/dist/src/recovery/joint-demand.js +22 -2
- package/dist/src/recovery/joint-demand.js.map +1 -1
- package/dist/src/recovery/receipt.d.ts +2 -0
- package/dist/src/recovery/status.d.ts +10 -0
- package/dist/src/recovery/status.js +218 -37
- package/dist/src/recovery/status.js.map +1 -1
- package/dist/src/recovery/types.d.ts +2 -3
- package/dist/src/tui/components.js +9 -0
- package/dist/src/tui/components.js.map +1 -1
- package/dist/src/tui/controller.js +1 -0
- package/dist/src/tui/controller.js.map +1 -1
- package/dist/src/tui/diagnostics.d.ts +3 -0
- package/dist/src/tui/diagnostics.js.map +1 -1
- package/dist/src/tui/model.d.ts +3 -1
- package/dist/src/tui/model.js +27 -6
- package/dist/src/tui/model.js.map +1 -1
- package/dist/src/utils/catalog-source-references.d.ts +8 -0
- package/dist/src/utils/catalog-source-references.js +36 -10
- package/dist/src/utils/catalog-source-references.js.map +1 -1
- package/dist/src/utils/codex-native-observation.js +5 -1
- package/dist/src/utils/codex-native-observation.js.map +1 -1
- package/dist/src/utils/inventory-recovery-diagnostic.d.ts +4 -0
- package/dist/src/utils/inventory-recovery-diagnostic.js +15 -0
- package/dist/src/utils/inventory-recovery-diagnostic.js.map +1 -0
- package/package.json +3 -3
|
@@ -22,8 +22,13 @@ import { resolvePartialCatalogOperationContext } from '../utils/catalog-operatio
|
|
|
22
22
|
import { checkAwCapabilitySupport, readPluginManifest } from '../utils/manifest.js';
|
|
23
23
|
import { IMPLEMENTED_AW_CAPABILITIES } from '../commands/aw-capabilities.js';
|
|
24
24
|
import { resolvePluginMetaDependencyClosure } from '../utils/plugin-dependencies.js';
|
|
25
|
-
import { installationInvocation } from '../platforms/discovery.js';
|
|
25
|
+
import { installationInvocation, selectNativeProduct } from '../platforms/discovery.js';
|
|
26
26
|
import { DEFAULT_AGENT_VERSION_PROBE_TIMEOUT_MS } from '../constants.js';
|
|
27
|
+
import { inventoryRecoveryDiagnostic } from '../utils/inventory-recovery-diagnostic.js';
|
|
28
|
+
import { selectedNativeConsumer } from '../platforms/inspection.js';
|
|
29
|
+
import { measureRecoveryPerformanceStage } from './performance.js';
|
|
30
|
+
import { createNativeQuerySession } from '../platforms/inspection-query.js';
|
|
31
|
+
import { readCatalogSourcesConfigSnapshot } from '../utils/catalog-sources.js';
|
|
27
32
|
const NATIVE_READ_ERRORS = new Set(['nativeStateUnreadable', 'stateInventoryFailed', 'configReadFailed',
|
|
28
33
|
'configInvalid', 'componentInspectionFailed', 'targetInspectionFailed', 'codexNativeObservationFailed',
|
|
29
34
|
'nativeObservationFailed', 'nativeObservationUnavailable']);
|
|
@@ -41,6 +46,7 @@ async function readAdapterObservations(options, context, demand) {
|
|
|
41
46
|
return { observations, existing, owned };
|
|
42
47
|
}
|
|
43
48
|
const ctx = { cwd: context.executionCwd, env: context.env, signal: options.signal, runner: options.nativeCliRunner,
|
|
49
|
+
discoveryCache: options.discoveryCache, nativeQuerySession: options.nativeQuerySession,
|
|
44
50
|
codexObservationSession: options.codexObservationSession, observeNative: options.observeNative };
|
|
45
51
|
for (const platform of selected) {
|
|
46
52
|
options.signal?.throwIfAborted();
|
|
@@ -52,9 +58,9 @@ async function readAdapterObservations(options, context, demand) {
|
|
|
52
58
|
const adapter = getAgentPluginAdapter(platform);
|
|
53
59
|
let ownedSession;
|
|
54
60
|
try {
|
|
55
|
-
const discovery = await adapter.discover(ctx);
|
|
61
|
+
const discovery = await measureRecoveryPerformanceStage(options, 'status.discovery', () => adapter.discover(ctx));
|
|
56
62
|
if (platform === 'codex') {
|
|
57
|
-
const product = discovery.installations
|
|
63
|
+
const product = selectNativeProduct(discovery.installations);
|
|
58
64
|
if (product) {
|
|
59
65
|
const invocation = await installationInvocation(product, ctx, []);
|
|
60
66
|
const manager = { kind: product.product === 'app' ? 'app' : 'system', version: product.version ?? 'unknown',
|
|
@@ -91,8 +97,9 @@ async function readAdapterObservations(options, context, demand) {
|
|
|
91
97
|
reasonCode: entry.reasonCode, execution: 'not-run',
|
|
92
98
|
recoveryActions: ['aw target list', `aw plugin sync ${root.pluginId} --context ${demand.scope} --target ${platform}`],
|
|
93
99
|
}] : []);
|
|
94
|
-
observation.blockers.push(...resolution.
|
|
100
|
+
observation.blockers.push(...resolution.diagnostics.map((entry) => ({ ...entry })));
|
|
95
101
|
if (!resolution.bindings.length) {
|
|
102
|
+
observation.blockers.push(...resolution.exclusions.map((entry) => diagnostic(entry.reasonCode)));
|
|
96
103
|
observation.blockers.push(...discovery.diagnostics.map((entry) => ({ code: entry.code, message: entry.message })));
|
|
97
104
|
if (!observation.blockers.length)
|
|
98
105
|
observation.blockers.push(diagnostic(discovery.availability === 'missing' ? 'client-missing' : 'nativeObservationUnavailable'));
|
|
@@ -103,7 +110,7 @@ async function readAdapterObservations(options, context, demand) {
|
|
|
103
110
|
const currentMatches = [];
|
|
104
111
|
const versions = [];
|
|
105
112
|
for (const binding of resolution.bindings) {
|
|
106
|
-
const live = await adapter.inspect(ctx, binding);
|
|
113
|
+
const live = await measureRecoveryPerformanceStage(options, 'status.adapter.inspect', () => adapter.inspect(ctx, binding));
|
|
107
114
|
versions.push(live.packageVersion);
|
|
108
115
|
options.signal?.throwIfAborted();
|
|
109
116
|
observation.deploymentObservations.push({ bindingId: binding.id, products: binding.consumers, after: live });
|
|
@@ -203,19 +210,17 @@ async function readAdapterObservations(options, context, demand) {
|
|
|
203
210
|
// Codex CLI 0.167.0 loads user plugin Skills without the independent
|
|
204
211
|
// Hook/project trust gate. This is component applicability, not trust
|
|
205
212
|
// inferred from activation, and requires complete current evidence.
|
|
213
|
+
const selectedProduct = selectNativeProduct(binding.consumers);
|
|
214
|
+
const selectedConsumer = selectedNativeConsumer(binding, live);
|
|
206
215
|
if (binding.route === 'codex-marketplace' && binding.scope.kind === 'user'
|
|
207
216
|
&& !plugin.manifest.artifacts && staticComponents.length > 0
|
|
208
217
|
&& staticComponents.every((component) => component.kind === 'skill')
|
|
209
218
|
&& unmet.length === 0 && staticSupplements.length === 0 && currentProjection
|
|
210
219
|
&& live.registration === 'present' && profile.kinds.skill.status === 'supported'
|
|
211
|
-
&&
|
|
212
|
-
&&
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
&& consumer.activation === 'enabled' && ['unknown', 'trusted', 'not-applicable'].includes(consumer.trust)).length === 1)) {
|
|
216
|
-
for (const consumer of live.consumers)
|
|
217
|
-
if (consumer.trust === 'unknown')
|
|
218
|
-
consumer.trust = 'not-applicable';
|
|
220
|
+
&& selectedProduct?.product === 'cli' && selectedProduct.version === '0.167.0'
|
|
221
|
+
&& profile.qualifiedConsumers?.skill?.some((qualified) => qualified.product === selectedProduct.product && qualified.version === selectedProduct.version)
|
|
222
|
+
&& selectedConsumer?.activation === 'enabled' && selectedConsumer.trust === 'unknown') {
|
|
223
|
+
selectedConsumer.trust = 'not-applicable';
|
|
219
224
|
}
|
|
220
225
|
live.components.push(...supplements.components);
|
|
221
226
|
observation.inputDrift ||= inputDrift || supplementDrift || nativeContentDrift;
|
|
@@ -223,15 +228,16 @@ async function readAdapterObservations(options, context, demand) {
|
|
|
223
228
|
emptyMatches.push(confirmedEmpty);
|
|
224
229
|
observation.blockers.push(...unmet.map((entry) => diagnostic(entry.reasonCode)));
|
|
225
230
|
const requiresComponents = expectedCount > 0 || unmet.length > 0 || Boolean(plugin.manifest.artifacts);
|
|
226
|
-
if (!confirmedEmpty && requiresComponents &&
|
|
231
|
+
if (!confirmedEmpty && requiresComponents && selectedConsumer && [selectedConsumer].some((consumer) => consumer.trust === 'required' || consumer.trust === 'blocked')
|
|
227
232
|
&& !observation.blockers.some((entry) => entry.code === 'nativeTrustRequired')) {
|
|
228
233
|
observation.blockers.push(diagnostic('nativeTrustRequired'));
|
|
229
234
|
}
|
|
230
235
|
const supplementOnly = !plugin.manifest.artifacts && staticSupplements.length > 0 && packageExpectedCount === 0;
|
|
231
236
|
const absent = !supplementOnly && live.package === 'absent' && ['absent', 'not-applicable'].includes(live.registration);
|
|
237
|
+
const consumers = selectedConsumer ? [selectedConsumer] : [];
|
|
232
238
|
const unknown = !supplementOnly && (live.package === 'unknown' || live.registration === 'unknown'
|
|
233
|
-
||
|
|
234
|
-
const inactive = !supplementOnly && (live.registration === 'absent' ||
|
|
239
|
+
|| !consumers.length || consumers.some((consumer) => consumer.activation === 'unknown' || consumer.trust === 'unknown'));
|
|
240
|
+
const inactive = !supplementOnly && (live.registration === 'absent' || consumers.some((consumer) => consumer.activation === 'disabled' || consumer.activation === 'blocked'
|
|
235
241
|
|| consumer.trust === 'blocked' || consumer.trust === 'required'));
|
|
236
242
|
if (confirmedEmpty) {
|
|
237
243
|
const inactiveScope = live.registration === 'absent'
|
|
@@ -480,15 +486,35 @@ export async function readScopedRecoveryStatus(options) {
|
|
|
480
486
|
options.onDemand?.(demand);
|
|
481
487
|
options.signal?.throwIfAborted();
|
|
482
488
|
const ownerInventory = options.nativeObservations ? { references: [], errors: [] }
|
|
483
|
-
: await inventoryCatalogSourceReferences({ cwd: context.executionCwd, env: context.env, scope: options.scope
|
|
489
|
+
: await measureRecoveryPerformanceStage(options, 'status.inventory', () => inventoryCatalogSourceReferences({ cwd: context.executionCwd, env: context.env, scope: options.scope,
|
|
490
|
+
knownPluginNames: demand.plugins.map((plugin) => plugin.manifest.name), collectPathEvidence: false,
|
|
491
|
+
observationPlugins: options.observationPlugins }));
|
|
484
492
|
options.signal?.throwIfAborted();
|
|
485
493
|
const candidates = ownerInventory.references.filter((entry) => entry.scope === options.scope
|
|
486
|
-
&& entry.sourceId && entry.pluginName && isPlatformTarget(entry.platform) && entry.platform !== 'generic'
|
|
494
|
+
&& entry.sourceId && entry.pluginName && isPlatformTarget(entry.platform) && entry.platform !== 'generic'
|
|
495
|
+
&& (!options.observationPlugins || options.observationPlugins.has(`${entry.sourceId}/${entry.pluginName}`)
|
|
496
|
+
|| options.observationPlugins.has(entry.pluginName))
|
|
497
|
+
&& (!options.targets || options.targets.includes(entry.platform)));
|
|
487
498
|
const observedPlugins = new Map(demand.plugins.map((plugin) => [plugin.pluginId, plugin]));
|
|
488
|
-
|
|
499
|
+
const catalog = demand.catalogOperationContext ?? options.catalogOperationContext;
|
|
500
|
+
const catalogSources = options.catalogSources ?? new Map();
|
|
501
|
+
for (const source of catalog?.catalog.sources ?? [])
|
|
502
|
+
if (!catalogSources.has(source.sourceId))
|
|
503
|
+
catalogSources.set(source.sourceId, source);
|
|
489
504
|
if (candidates.some((entry) => !observedPlugins.has(`${entry.sourceId}/${entry.pluginName}`))) {
|
|
490
505
|
try {
|
|
491
|
-
|
|
506
|
+
const missing = [...new Set(candidates.map((entry) => entry.sourceId))].filter((id) => !catalogSources.has(id));
|
|
507
|
+
if (missing.length) {
|
|
508
|
+
const config = await readCatalogSourcesConfigSnapshot(context.env);
|
|
509
|
+
const configured = new Set(config.config.sources.map((source) => source.id));
|
|
510
|
+
const sourceIds = missing.filter((id) => configured.has(id));
|
|
511
|
+
if (sourceIds.length) {
|
|
512
|
+
const additional = await resolvePartialCatalogOperationContext({ env: context.env, signal: options.signal,
|
|
513
|
+
configSnapshot: config, sourceIds });
|
|
514
|
+
for (const source of additional.catalog.sources)
|
|
515
|
+
catalogSources.set(source.sourceId, source);
|
|
516
|
+
}
|
|
517
|
+
}
|
|
492
518
|
}
|
|
493
519
|
catch (error) {
|
|
494
520
|
rethrowFatalError(error);
|
|
@@ -498,7 +524,7 @@ export async function readScopedRecoveryStatus(options) {
|
|
|
498
524
|
const pluginId = `${candidate.sourceId}/${candidate.pluginName}`;
|
|
499
525
|
if (observedPlugins.has(pluginId))
|
|
500
526
|
continue;
|
|
501
|
-
const source =
|
|
527
|
+
const source = catalogSources.get(candidate.sourceId)?.resolution;
|
|
502
528
|
if (!source?.manifest.entries.some((entry) => entry.name === candidate.pluginName))
|
|
503
529
|
continue;
|
|
504
530
|
try {
|
|
@@ -583,9 +609,10 @@ export async function readScopedRecoveryStatus(options) {
|
|
|
583
609
|
delivery: { kind: 'native', platform: entry.platform }, observation: 'unknown', content: 'unknown',
|
|
584
610
|
backend: { retainedPackage: true, ownedComponents: [{ ...component, state: 'present' }] } });
|
|
585
611
|
}
|
|
586
|
-
const portableExtra =
|
|
587
|
-
|
|
588
|
-
|
|
612
|
+
const portableExtra = options.targets && !options.targets.includes('generic') ? { targets: [], complete: true }
|
|
613
|
+
: await inspectPortableExtraInstalled({
|
|
614
|
+
scope: options.scope, context, env: context.env, signal: options.signal, plugins: options.observationPlugins,
|
|
615
|
+
});
|
|
589
616
|
options.signal?.throwIfAborted();
|
|
590
617
|
const portableObserved = portableExtra.targets
|
|
591
618
|
.filter((entry) => !expected(entry.pluginId, entry.agent))
|
|
@@ -594,13 +621,52 @@ export async function readScopedRecoveryStatus(options) {
|
|
|
594
621
|
observation: entry.observation, content: entry.content,
|
|
595
622
|
backend: { skill: entry.skill, logicalIdentity: entry.logicalIdentity } }));
|
|
596
623
|
const extraObserved = [...nativeExtraObserved, ...portableObserved];
|
|
624
|
+
const relevantErrors = ownerInventory.errors.filter((error) => {
|
|
625
|
+
const relevance = error.relevance;
|
|
626
|
+
if (relevance.global)
|
|
627
|
+
return true;
|
|
628
|
+
if (options.targets && relevance.platform && !options.targets.includes(relevance.platform))
|
|
629
|
+
return false;
|
|
630
|
+
if (!options.observationPlugins)
|
|
631
|
+
return true;
|
|
632
|
+
if (!relevance.pluginName && !relevance.sourceId)
|
|
633
|
+
return true;
|
|
634
|
+
return [...options.observationPlugins].some((id) => {
|
|
635
|
+
const parsed = parsePluginId(id);
|
|
636
|
+
const plugin = observedPlugins.get(id);
|
|
637
|
+
return (!relevance.sourceId || !parsed.sourceId || relevance.sourceId === parsed.sourceId)
|
|
638
|
+
&& (!relevance.pluginName || relevance.pluginName === parsed.pluginName
|
|
639
|
+
|| relevance.componentName && plugin?.manifest.extensions?.agents?.some((agent) => agent.name === relevance.componentName));
|
|
640
|
+
});
|
|
641
|
+
});
|
|
597
642
|
const result = await statusFromObservations({ ...options, context, demand,
|
|
598
643
|
nativeObservations: options.nativeObservations ?? adapters.observations, extraObserved,
|
|
599
644
|
portableCoverage: portableExtra.complete, portableInstalled: portableExtra.targets,
|
|
600
645
|
nativeReadErrors: [
|
|
601
|
-
...
|
|
646
|
+
...relevantErrors.map(inventoryRecoveryDiagnostic),
|
|
602
647
|
...adapters.observations.flatMap((entry) => entry.blockers.filter((error) => NATIVE_READ_ERRORS.has(error.code))),
|
|
603
|
-
]
|
|
648
|
+
] });
|
|
649
|
+
result.coverage.requestComplete = result.coverage.native && result.coverage.portable;
|
|
650
|
+
result.coverage.native &&= ownerInventory.errors.length === 0;
|
|
651
|
+
for (const target of result.inventory?.flatMap((entry) => entry.targetResults) ?? []) {
|
|
652
|
+
for (const error of relevantErrors) {
|
|
653
|
+
const relevance = error.relevance;
|
|
654
|
+
const identity = parsePluginId(target.pluginId);
|
|
655
|
+
if (!relevance.global && (relevance.platform && relevance.platform !== target.agent
|
|
656
|
+
|| relevance.sourceId && relevance.sourceId !== identity.sourceId
|
|
657
|
+
|| relevance.scope && relevance.scope !== target.scope
|
|
658
|
+
&& !(relevance.scope === 'user' && target.scope === 'project' && ['codex', 'claude', 'gemini', 'copilot'].includes(target.agent))
|
|
659
|
+
|| relevance.projectLocationKey && relevance.projectLocationKey !== context.projectKey
|
|
660
|
+
|| relevance.pluginName && relevance.pluginName !== identity.pluginName
|
|
661
|
+
&& !(relevance.componentName && observedPlugins.get(target.pluginId)?.manifest.extensions?.agents?.some((agent) => agent.name === relevance.componentName))))
|
|
662
|
+
continue;
|
|
663
|
+
target.blockers.push(inventoryRecoveryDiagnostic(error));
|
|
664
|
+
if (target.content === 'satisfied') {
|
|
665
|
+
target.content = 'unknown';
|
|
666
|
+
target.observation = 'unknown';
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
}
|
|
604
670
|
result.existingTargets = [
|
|
605
671
|
...adapters.existing,
|
|
606
672
|
...portableExtra.targets.map((target) => ({ pluginId: target.pluginId, agent: target.agent, scope: options.scope })),
|
|
@@ -661,7 +727,17 @@ export function aggregateConvergence(allSatisfied, residue) {
|
|
|
661
727
|
: allSatisfied === null || residue === 'unknown' ? null : true;
|
|
662
728
|
}
|
|
663
729
|
export async function readRecoveryStatus(options, preparedDemand) {
|
|
664
|
-
const
|
|
730
|
+
const nativeQuerySession = createNativeQuerySession();
|
|
731
|
+
try {
|
|
732
|
+
return await readRecoveryStatusWithQueries({ ...options, nativeQuerySession }, preparedDemand);
|
|
733
|
+
}
|
|
734
|
+
finally {
|
|
735
|
+
await nativeQuerySession.dispose();
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
async function readRecoveryStatusWithQueries(options, preparedDemand) {
|
|
739
|
+
options = { ...options, discoveryCache: new Map(), catalogSources: new Map() };
|
|
740
|
+
const snapshot = preparedDemand ?? await measureRecoveryPerformanceStage(options, 'status.demand', () => readJointDemand(options));
|
|
665
741
|
if (options.codexObservationSession || options.nativeObservations) {
|
|
666
742
|
return readRecoveryStatusInSession(options, snapshot);
|
|
667
743
|
}
|
|
@@ -691,15 +767,90 @@ export async function readRecoveryStatus(options, preparedDemand) {
|
|
|
691
767
|
}
|
|
692
768
|
}
|
|
693
769
|
}
|
|
770
|
+
/** An empty demand or inventory does not establish that the selected Catalog is readable. */
|
|
771
|
+
async function checkUndeclaredSelection(options, snapshot) {
|
|
772
|
+
const demands = [snapshot.user, ...(snapshot.project ? [snapshot.project] : [])];
|
|
773
|
+
const known = new Set(demands.flatMap((demand) => demand.plugins.map((plugin) => plugin.pluginId)));
|
|
774
|
+
const selectors = (options.plugins ?? []).filter((selector) => ![...known].some((id) => id === selector || !selector.includes('/') && parsePluginId(id).pluginName === selector));
|
|
775
|
+
if (!selectors.length)
|
|
776
|
+
return [];
|
|
777
|
+
const sources = options.catalogSources ?? new Map();
|
|
778
|
+
for (const source of [options.catalogOperationContext, ...demands.map((demand) => demand.catalogOperationContext)]
|
|
779
|
+
.flatMap((context) => context?.catalog.sources ?? []))
|
|
780
|
+
if (!sources.has(source.sourceId))
|
|
781
|
+
sources.set(source.sourceId, source);
|
|
782
|
+
const errors = [];
|
|
783
|
+
try {
|
|
784
|
+
const config = await readCatalogSourcesConfigSnapshot(options.env);
|
|
785
|
+
const configured = new Set(config.config.sources.map((source) => source.id));
|
|
786
|
+
const wanted = new Set(selectors.flatMap((selector) => parsePluginId(selector).sourceId
|
|
787
|
+
? [parsePluginId(selector).sourceId] : [...configured]));
|
|
788
|
+
const missing = [...wanted].filter((id) => configured.has(id) && !sources.has(id));
|
|
789
|
+
if (missing.length) {
|
|
790
|
+
const context = await resolvePartialCatalogOperationContext({ sourceIds: missing, configSnapshot: config,
|
|
791
|
+
env: options.env, signal: options.signal });
|
|
792
|
+
for (const source of context.catalog.sources)
|
|
793
|
+
sources.set(source.sourceId, source);
|
|
794
|
+
}
|
|
795
|
+
for (const selector of selectors) {
|
|
796
|
+
const { sourceId, pluginName } = parsePluginId(selector);
|
|
797
|
+
const candidates = sourceId ? [sourceId] : [...configured];
|
|
798
|
+
const code = sourceId && !configured.has(sourceId) ? 'sourceMissing'
|
|
799
|
+
: candidates.some((id) => !sources.get(id)?.resolution) ? 'sourceActiveUnavailable'
|
|
800
|
+
: !candidates.some((id) => sources.get(id)?.resolution?.manifest.entries.some((entry) => entry.name === pluginName))
|
|
801
|
+
? 'pluginUnavailable' : undefined;
|
|
802
|
+
if (code)
|
|
803
|
+
errors.push({ code, message: 'The selected plugin or its Catalog source could not be confirmed.',
|
|
804
|
+
...(sourceId ? { pluginId: selector, subject: { pluginId: selector, sourceId } } : {}) });
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
catch (error) {
|
|
808
|
+
rethrowFatalError(error);
|
|
809
|
+
options.signal?.throwIfAborted();
|
|
810
|
+
errors.push({ code: 'catalogReadFailed', message: 'The selected Catalog source could not be read.' });
|
|
811
|
+
}
|
|
812
|
+
return errors;
|
|
813
|
+
}
|
|
694
814
|
async function readRecoveryStatusInSession(options, snapshot) {
|
|
695
|
-
const
|
|
815
|
+
const selectionErrors = await checkUndeclaredSelection(options, snapshot);
|
|
816
|
+
const globalPlan = deriveJointDemand(snapshot);
|
|
817
|
+
const plan = options.targets ? deriveJointDemand({ ...snapshot, preferences: snapshot.preferences
|
|
818
|
+
? { ...snapshot.preferences, targets: [...new Set([...snapshot.preferences.targets, ...options.targets])] } : null }) : globalPlan;
|
|
819
|
+
const matchesPlugin = (id) => !options.plugins?.length || options.plugins.some((selector) => selector === id || !selector.includes('/') && parsePluginId(id).pluginName === selector);
|
|
820
|
+
const selected = Boolean(options.plugins?.length || options.targets);
|
|
821
|
+
const observationPlugins = options.plugins?.length ? new Set(plan.placements.filter((item) => matchesPlugin(item.pluginId)
|
|
822
|
+
|| item.contributions.some((contribution) => matchesPlugin(contribution.root))).map((item) => item.pluginId)) : undefined;
|
|
823
|
+
if (observationPlugins) {
|
|
824
|
+
const plugins = [...new Map([snapshot.user, ...(snapshot.project ? [snapshot.project] : [])]
|
|
825
|
+
.flatMap((demand) => demand.plugins).map((plugin) => [plugin.pluginId, plugin])).values()];
|
|
826
|
+
for (const id of observationPlugins) {
|
|
827
|
+
const plugin = plugins.find((entry) => entry.pluginId === id);
|
|
828
|
+
if (!plugin)
|
|
829
|
+
continue;
|
|
830
|
+
for (const dependency of plugin.manifest.dependencies ?? [])
|
|
831
|
+
observationPlugins.add(`${plugin.sourceId}/${dependency}`);
|
|
832
|
+
const slots = new Set(plugin.manifest.extensions?.agents?.map((agent) => agent.name) ?? []);
|
|
833
|
+
for (const candidate of plugins)
|
|
834
|
+
if (candidate.manifest.extensions?.agents?.some((agent) => slots.has(agent.name))) {
|
|
835
|
+
observationPlugins.add(candidate.pluginId);
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
if (observationPlugins)
|
|
840
|
+
for (const plugin of options.plugins ?? [])
|
|
841
|
+
observationPlugins.add(plugin);
|
|
842
|
+
const selectedPlacement = (item) => (!options.targets || options.targets.includes(item.target)) && (!observationPlugins || observationPlugins.has(item.pluginId));
|
|
696
843
|
const scopes = [snapshot.user, ...(snapshot.project ? [snapshot.project] : [])];
|
|
697
844
|
const observed = [];
|
|
698
845
|
for (const demand of scopes) {
|
|
699
|
-
const nodes = plan.placements.filter((item) => item.scope === demand.scope
|
|
846
|
+
const nodes = plan.placements.filter((item) => selectedPlacement(item) && (item.scope === demand.scope
|
|
700
847
|
|| demand.scope === 'project' && ['codex', 'claude', 'gemini', 'copilot'].includes(item.target)
|
|
701
|
-
&& item.contributions.some((contribution) => contribution.scope === 'project'));
|
|
848
|
+
&& item.contributions.some((contribution) => contribution.scope === 'project')));
|
|
702
849
|
const expanded = { ...demand,
|
|
850
|
+
plugins: [...new Map([...demand.plugins, ...nodes.map((item) => item.plugin)]
|
|
851
|
+
.map((plugin) => [plugin.pluginId, plugin])).values()],
|
|
852
|
+
catalogOperationContext: demand.catalogOperationContext ?? snapshot.user.catalogOperationContext
|
|
853
|
+
?? snapshot.project?.catalogOperationContext,
|
|
703
854
|
userProviders: demand.scope === 'project' ? Object.fromEntries((snapshot.preferences?.targets ?? []).map((target) => [target,
|
|
704
855
|
plan.placements.filter((item) => item.scope === 'user' && item.target === target
|
|
705
856
|
&& !nodes.some((project) => project.scope === 'project' && project.pluginId === item.pluginId && project.target === item.target)).map((item) => item.pluginId)])) : {},
|
|
@@ -708,7 +859,7 @@ async function readRecoveryStatusInSession(options, snapshot) {
|
|
|
708
859
|
blockers: [], plugin: item.plugin,
|
|
709
860
|
}])).values()] };
|
|
710
861
|
observed.push(await readScopedRecoveryStatus({ ...options, onNativeStatus: undefined, scope: demand.scope,
|
|
711
|
-
cwd: snapshot.context.projectRoot ?? options.cwd, targets:
|
|
862
|
+
cwd: snapshot.context.projectRoot ?? options.cwd, observationPlugins, targets: options.targets, demandOverride: expanded }));
|
|
712
863
|
}
|
|
713
864
|
const allTargets = observed.flatMap((status) => status.inventory?.flatMap((item) => item.targetResults) ?? []).map((target) => {
|
|
714
865
|
const providers = plan.placements.filter((placement) => placement.pluginId === target.pluginId && placement.target === target.agent
|
|
@@ -792,14 +943,18 @@ async function readRecoveryStatusInSession(options, snapshot) {
|
|
|
792
943
|
const extraObserved = observed.flatMap((status) => status.extraObserved)
|
|
793
944
|
.filter((item) => !expected.has(`${item.pluginId}\0${item.agent}\0${item.scope}`));
|
|
794
945
|
const targets = visibleInventory.flatMap((item) => item.targetResults);
|
|
795
|
-
const
|
|
796
|
-
|
|
946
|
+
const globalTargets = targets.filter((target) => globalPlan.roots.some((root) => root.pluginId === target.pluginId && root.target === target.agent && root.scope === target.scope));
|
|
947
|
+
const fullObservation = !selected || globalPlan.placements.every(selectedPlacement);
|
|
948
|
+
const knownFailure = globalPlan.errors.some((error) => ['targetsNotConfigured', 'dependencyExcluded', 'dependencyContractInvalid', 'targetPlacementConflict'].includes(error.code))
|
|
949
|
+
|| globalTargets.some((target) => ['absent', 'drifted', 'conflict'].includes(target.content ?? 'unknown')
|
|
797
950
|
|| target.blockers.some((entry) => entry.code === 'awCapabilityUnsupported'));
|
|
798
|
-
const uncertain = !
|
|
951
|
+
const uncertain = !fullObservation || !globalPlan.complete || globalTargets.some((target) => target.content === 'unknown' || target.blockers.length > 0);
|
|
799
952
|
const allSatisfied = knownFailure ? false : uncertain ? null : true;
|
|
800
|
-
const nativeCoverage = observed.every((status) => status.coverage.native);
|
|
801
|
-
const portableCoverage = observed.every((status) => status.coverage.portable);
|
|
802
|
-
const errors = [...
|
|
953
|
+
const nativeCoverage = !selected && observed.every((status) => status.coverage.native);
|
|
954
|
+
const portableCoverage = !selected && observed.every((status) => status.coverage.portable);
|
|
955
|
+
const errors = [...new Map([...selectionErrors, ...plan.errors.filter((error) => !selected || !error.pluginId
|
|
956
|
+
|| !observationPlugins || observationPlugins.has(error.pluginId)), ...observed.flatMap((status) => status.errors)]
|
|
957
|
+
.map((error) => [JSON.stringify(error), error])).values()];
|
|
803
958
|
const result = { schemaVersion: 1, kind: 'aw-recovery-status', scope: snapshot.context.context, ok: errors.length === 0,
|
|
804
959
|
intent: { state: scopes.some((demand) => demand.intent.state === 'invalid') ? 'invalid'
|
|
805
960
|
: scopes.some((demand) => demand.intent.state === 'unreadable') ? 'unreadable'
|
|
@@ -815,6 +970,32 @@ async function readRecoveryStatusInSession(options, snapshot) {
|
|
|
815
970
|
unconfirmed: targets.filter((target) => target.content === 'unknown').length,
|
|
816
971
|
ready: targets.filter((target) => target.content === 'satisfied').length },
|
|
817
972
|
allSatisfied, inSync: aggregateConvergence(allSatisfied, extraObserved.length ? 'present' : nativeCoverage && portableCoverage ? 'absent' : 'unknown'), errors };
|
|
973
|
+
if (options.plugins?.length) {
|
|
974
|
+
for (const target of allTargets.filter((target) => matchesPlugin(target.pluginId))) {
|
|
975
|
+
if (visibleInventory.some((entry) => entry.pluginId === target.pluginId))
|
|
976
|
+
continue;
|
|
977
|
+
visibleInventory.push({ pluginId: target.pluginId, source: parsePluginId(target.pluginId).sourceId, sourceState: 'ready', blockers: [],
|
|
978
|
+
targetResults: allTargets.filter((entry) => entry.pluginId === target.pluginId).map((entry) => ({ ...entry,
|
|
979
|
+
requirementScope: entry.contributions?.[0]?.scope,
|
|
980
|
+
satisfaction: entry.content === 'satisfied' ? entry.scope === 'user' && entry.contributions?.some((contribution) => contribution.scope === 'project')
|
|
981
|
+
? 'inherited-user' : 'installed' : entry.content === 'unknown' ? 'unknown' : 'pending' })) });
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
if (selected) {
|
|
985
|
+
result.inventory = result.inventory?.filter((entry) => matchesPlugin(entry.pluginId)).map((entry) => ({ ...entry,
|
|
986
|
+
targetResults: entry.targetResults.filter((target) => !options.targets || options.targets.includes(target.agent)) })) ?? null;
|
|
987
|
+
const requested = result.inventory?.flatMap((entry) => entry.targetResults) ?? [];
|
|
988
|
+
result.coverage.requestComplete = observed.every((status) => status.coverage.requestComplete ?? (status.coverage.native && status.coverage.portable))
|
|
989
|
+
&& result.errors.length === 0 && result.inventory !== null
|
|
990
|
+
&& result.inventory.every((entry) => entry.sourceState === 'ready' && entry.blockers.length === 0)
|
|
991
|
+
&& allTargets.every((target) => target.content !== 'unknown'
|
|
992
|
+
&& target.blockers.every((blocker) => blocker.code === 'needs-preparation' && ['absent', 'drifted'].includes(target.content ?? '')))
|
|
993
|
+
&& requested.every((target) => target.content !== 'unknown');
|
|
994
|
+
result.counts = { blocked: requested.filter((target) => target.blockers.length).length,
|
|
995
|
+
pending: requested.filter((target) => target.satisfaction === 'pending').length,
|
|
996
|
+
unconfirmed: requested.filter((target) => target.content === 'unknown').length,
|
|
997
|
+
ready: requested.filter((target) => target.content === 'satisfied').length };
|
|
998
|
+
}
|
|
818
999
|
await options.onNativeStatus?.(result, snapshot.context.context === 'project' ? snapshot.project : snapshot.user);
|
|
819
1000
|
options.signal?.throwIfAborted();
|
|
820
1001
|
return result;
|