@gajae-code/coding-agent 0.21.0 → 0.21.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +60 -0
- package/dist/types/config/autorouting-contract.d.ts +4 -4
- package/dist/types/config/autorouting-tier-map.d.ts +1 -1
- package/dist/types/config/keybindings.d.ts +1 -5
- package/dist/types/config/model-profile-activation.d.ts +30 -3
- package/dist/types/config/model-registry.d.ts +2 -0
- package/dist/types/config/models-config-schema.d.ts +8 -0
- package/dist/types/config/settings-schema.d.ts +7 -3
- package/dist/types/coordinator-mcp/canonical-json.d.ts +7 -0
- package/dist/types/extensibility/gjc-plugins/metadata.d.ts +1 -1
- package/dist/types/harness-control-plane/receipts.d.ts +1 -1
- package/dist/types/modes/components/settings-selector.d.ts +5 -2
- package/dist/types/modes/controllers/command-controller.d.ts +1 -1
- package/dist/types/modes/controllers/input-controller.d.ts +12 -0
- package/dist/types/modes/controllers/selector-controller.d.ts +1 -1
- package/dist/types/modes/interactive-mode.d.ts +1 -1
- package/dist/types/modes/shared/agent-wire/workflow-gate-schema.d.ts +1 -1
- package/dist/types/modes/types.d.ts +1 -1
- package/dist/types/session/agent-session.d.ts +101 -6
- package/dist/types/session/session-manager.d.ts +124 -9
- package/dist/types/setup/provider-onboarding.d.ts +55 -2
- package/dist/types/slash-commands/builtin-registry.d.ts +11 -0
- package/dist/types/utils/clipboard.d.ts +18 -0
- package/dist/types/utils/pasted-image-path.d.ts +2 -0
- package/dist/types/web/search/providers/keenable.d.ts +30 -0
- package/dist/types/web/search/types.d.ts +2 -2
- package/package.json +7 -7
- package/scripts/generate-sdk-operation-inventory.ts +28 -0
- package/src/cli/doctor/config-repairs.ts +1 -4
- package/src/cli/local-provider-smoke.ts +1 -4
- package/src/cli/public-command-help.ts +1 -1
- package/src/config/autorouting-contract.ts +5 -8
- package/src/config/autorouting-tier-map.ts +1 -1
- package/src/config/keybindings.ts +1 -2
- package/src/config/model-profile-activation.ts +332 -28
- package/src/config/model-registry.ts +156 -8
- package/src/config/models-config-schema.ts +27 -0
- package/src/config/settings-schema.ts +6 -0
- package/src/coordinator-mcp/canonical-json.ts +15 -0
- package/src/coordinator-mcp/policy.ts +1 -0
- package/src/coordinator-mcp/question-gate-codec.ts +1 -2
- package/src/coordinator-mcp/question-state.ts +2 -12
- package/src/coordinator-mcp/server.ts +1 -10
- package/src/customization/import.ts +1 -5
- package/src/discovery/mcp-compat.ts +1 -5
- package/src/discovery/mcp-json.ts +1 -4
- package/src/edit/notebook.ts +1 -5
- package/src/extensibility/gjc-plugins/lifecycle.ts +1 -3
- package/src/extensibility/gjc-plugins/metadata.ts +2 -5
- package/src/extensibility/gjc-plugins/schema.ts +1 -4
- package/src/gjc-runtime/deep-interview-crystallize.ts +1 -4
- package/src/gjc-runtime/deep-interview-runtime.ts +1 -4
- package/src/gjc-runtime/state-renderer.ts +1 -5
- package/src/gjc-runtime/tmux-owner-isolation.ts +1 -3
- package/src/gjc-runtime/ultragoal-owner-loss-recovery.ts +1 -4
- package/src/gjc-runtime/ultragoal-succession.ts +1 -4
- package/src/goals/continuation-timeout-guard.ts +1 -4
- package/src/harness-control-plane/receipts.ts +1 -1
- package/src/internal-urls/docs-index.generated.ts +4 -4
- package/src/migrate/mcp-mapper.ts +2 -4
- package/src/modes/components/hook-editor.ts +4 -8
- package/src/modes/components/hook-selector.ts +3 -1
- package/src/modes/components/settings-selector.ts +26 -2
- package/src/modes/controllers/command-controller.ts +4 -98
- package/src/modes/controllers/extension-ui-controller.ts +6 -14
- package/src/modes/controllers/goal-mode-controller.ts +4 -4
- package/src/modes/controllers/input-controller.ts +110 -46
- package/src/modes/controllers/plan-mode-controller.ts +6 -10
- package/src/modes/controllers/selector-controller.ts +66 -23
- package/src/modes/controllers/todo-command-controller.ts +2 -2
- package/src/modes/interactive-mode.ts +2 -2
- package/src/modes/prompt-action-autocomplete.ts +1 -1
- package/src/modes/runtime-init.ts +4 -4
- package/src/modes/shared/agent-wire/workflow-gate-schema.ts +1 -1
- package/src/modes/types.ts +1 -1
- package/src/modes/utils/hotkeys-markdown.ts +1 -1
- package/src/runtime-mcp/client.ts +1 -4
- package/src/runtime-mcp/elicitation.ts +1 -5
- package/src/runtime-mcp/protocol.ts +2 -4
- package/src/sdk/broker/lifecycle-ledger.ts +1 -0
- package/src/sdk/broker/lifecycle.ts +1 -0
- package/src/sdk/cli/rows.ts +2 -3
- package/src/sdk/cli/session-cli.ts +2 -8
- package/src/sdk/host/query/cursor.ts +1 -0
- package/src/sdk/host/reverse-leases.ts +1 -0
- package/src/sdk/lifecycle/service.ts +1 -0
- package/src/sdk/protocol/operation-inventory.generated.json +154 -0
- package/src/session/agent-session.ts +1877 -224
- package/src/session/btw-prefix-ledger.ts +1 -4
- package/src/session/internal/managed-gc-retirement-codec.ts +1 -4
- package/src/session/session-manager.ts +732 -224
- package/src/session/task-artifact-owner-codec.ts +1 -4
- package/src/session-import/claude.ts +1 -4
- package/src/session-import/detect.ts +1 -6
- package/src/session-import/provider-codex.ts +1 -6
- package/src/session-import/provider-service.ts +4 -0
- package/src/setup/hermes-setup.ts +1 -4
- package/src/setup/provider-onboarding.ts +514 -26
- package/src/slash-commands/builtin-registry.ts +26 -13
- package/src/slash-commands/helpers/todo.ts +3 -1
- package/src/task/delegation-hint.ts +1 -4
- package/src/task/executor.ts +4 -2
- package/src/task/provider-retry-status.ts +1 -4
- package/src/tools/json-tree.ts +1 -4
- package/src/tools/recipe/runners/pkg.ts +1 -5
- package/src/utils/clipboard.ts +155 -2
- package/src/utils/mac-file-urls.applescript +37 -0
- package/src/utils/pasted-image-path.ts +5 -0
- package/src/web/search/provider.ts +6 -0
- package/src/web/search/providers/keenable.ts +207 -0
- package/src/web/search/types.ts +2 -0
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
type AssistantMessageEventStream,
|
|
9
9
|
type AuthApiKeyOptions,
|
|
10
10
|
type AuthCredentialSelector,
|
|
11
|
+
type AuthCredentialSnapshotEntry,
|
|
11
12
|
applyFinalCodexGpt56ContextCap,
|
|
12
13
|
applyGeneratedModelPolicies,
|
|
13
14
|
type CacheRetention,
|
|
@@ -26,6 +27,7 @@ import {
|
|
|
26
27
|
googleGeminiCliModelManagerOptions,
|
|
27
28
|
isCodexGpt56Tier,
|
|
28
29
|
isKnownProvider,
|
|
30
|
+
isStoredApiKeyCredentialForProvider,
|
|
29
31
|
type Model,
|
|
30
32
|
type ModelManagerOptions,
|
|
31
33
|
type ModelMaxTokensSource,
|
|
@@ -126,9 +128,11 @@ import {
|
|
|
126
128
|
type ModelProfileConfig,
|
|
127
129
|
type ModelsConfig,
|
|
128
130
|
ModelsConfigSchema,
|
|
131
|
+
PROVIDER_CREDENTIAL_STORE,
|
|
129
132
|
ProfileDefinitionSchema,
|
|
130
133
|
type ProviderAuthMode,
|
|
131
134
|
type ProviderDiscovery,
|
|
135
|
+
type ProviderStoreCredential,
|
|
132
136
|
} from "./models-config-schema";
|
|
133
137
|
import {
|
|
134
138
|
buildProviderSelectionCatalog,
|
|
@@ -630,6 +634,7 @@ interface ProviderValidationConfig {
|
|
|
630
634
|
headers?: Record<string, string>;
|
|
631
635
|
apiKey?: string;
|
|
632
636
|
apiKeyEnv?: string;
|
|
637
|
+
credential?: ProviderStoreCredential;
|
|
633
638
|
api?: Api;
|
|
634
639
|
transport?: Model<Api>["transport"];
|
|
635
640
|
auth?: ProviderAuthMode;
|
|
@@ -657,6 +662,51 @@ function validateProviderConfiguration(
|
|
|
657
662
|
const hasProviderApi = !!config.api;
|
|
658
663
|
const configuredApi = config.api ?? (config.openaiCompat ? "openai-completions" : undefined);
|
|
659
664
|
const models = config.models;
|
|
665
|
+
if (config.credential === PROVIDER_CREDENTIAL_STORE) {
|
|
666
|
+
if (config.apiKey) {
|
|
667
|
+
throw new Error(
|
|
668
|
+
`Provider ${providerName}: "credential: store" cannot be combined with "apiKey"; "credential: store" already declares the credential.`,
|
|
669
|
+
);
|
|
670
|
+
}
|
|
671
|
+
if (config.apiKeyEnv) {
|
|
672
|
+
throw new Error(
|
|
673
|
+
`Provider ${providerName}: "credential: store" cannot be combined with "apiKeyEnv"; "credential: store" already declares the credential.`,
|
|
674
|
+
);
|
|
675
|
+
}
|
|
676
|
+
if (config.auth === "oauth") {
|
|
677
|
+
throw new Error(
|
|
678
|
+
`Provider ${providerName}: "credential: store" cannot be combined with "auth: oauth"; the store declaration already supplies an API key credential.`,
|
|
679
|
+
);
|
|
680
|
+
}
|
|
681
|
+
if (config.auth === "none") {
|
|
682
|
+
throw new Error(
|
|
683
|
+
`Provider ${providerName}: "credential: store" requires authentication and cannot be combined with "auth: none".`,
|
|
684
|
+
);
|
|
685
|
+
}
|
|
686
|
+
if (config.openaiCompat?.apiKey) {
|
|
687
|
+
throw new Error(
|
|
688
|
+
`Provider ${providerName}: "credential: store" cannot be combined with "openaiCompat.apiKey"; the local OpenAI-compatible descriptor declares its own credential.`,
|
|
689
|
+
);
|
|
690
|
+
}
|
|
691
|
+
if (config.openaiCompat?.apiKeyEnv) {
|
|
692
|
+
throw new Error(
|
|
693
|
+
`Provider ${providerName}: "credential: store" cannot be combined with "openaiCompat.apiKeyEnv"; the local OpenAI-compatible descriptor declares its own credential.`,
|
|
694
|
+
);
|
|
695
|
+
}
|
|
696
|
+
if (config.openaiCompat) {
|
|
697
|
+
// The compat descriptor marks the provider keyless/optional-auth, so a
|
|
698
|
+
// declared stored credential would not be enforced and requests could go
|
|
699
|
+
// out unauthenticated when the row is missing.
|
|
700
|
+
throw new Error(
|
|
701
|
+
`Provider ${providerName}: "credential: store" cannot be combined with "openaiCompat"; the local OpenAI-compatible descriptor marks the provider keyless, so the stored credential would not be enforced.`,
|
|
702
|
+
);
|
|
703
|
+
}
|
|
704
|
+
if (usesAwsCredentialChain(config.api) || models.some(model => usesAwsCredentialChain(model.api))) {
|
|
705
|
+
throw new Error(
|
|
706
|
+
`Provider ${providerName}: "credential: store" is not supported with "api: bedrock-converse-stream" at provider or model level; that API resolves credentials from its AWS credential chain.`,
|
|
707
|
+
);
|
|
708
|
+
}
|
|
709
|
+
}
|
|
660
710
|
if (
|
|
661
711
|
config.transport === "pi-native" &&
|
|
662
712
|
(config.streamIdleTimeoutMs !== undefined ||
|
|
@@ -679,6 +729,7 @@ function validateProviderConfiguration(
|
|
|
679
729
|
!config.compat &&
|
|
680
730
|
!config.apiKey &&
|
|
681
731
|
!config.apiKeyEnv &&
|
|
732
|
+
config.credential !== PROVIDER_CREDENTIAL_STORE &&
|
|
682
733
|
!config.disableStrictTools &&
|
|
683
734
|
!config.requestTransform &&
|
|
684
735
|
!config.cacheRetention &&
|
|
@@ -688,7 +739,7 @@ function validateProviderConfiguration(
|
|
|
688
739
|
!config.discovery
|
|
689
740
|
) {
|
|
690
741
|
throw new Error(
|
|
691
|
-
`Provider ${providerName}: must specify "baseUrl", "headers", "apiKey", "compat", "requestTransform", "cacheRetention", "streamIdleTimeoutMs", "disableStrictTools", "modelOverrides", "discovery", "openaiCompat", or "models"`,
|
|
742
|
+
`Provider ${providerName}: must specify "baseUrl", "headers", "apiKey", "compat", "requestTransform", "cacheRetention", "streamIdleTimeoutMs", "disableStrictTools", "modelOverrides", "discovery", "openaiCompat", "credential: store", or "models"`,
|
|
692
743
|
);
|
|
693
744
|
}
|
|
694
745
|
}
|
|
@@ -703,6 +754,7 @@ function validateProviderConfiguration(
|
|
|
703
754
|
: !usesProviderCredentialChain &&
|
|
704
755
|
!config.apiKey &&
|
|
705
756
|
!config.apiKeyEnv &&
|
|
757
|
+
config.credential !== PROVIDER_CREDENTIAL_STORE &&
|
|
706
758
|
(config.auth ?? "apiKey") !== "none";
|
|
707
759
|
if (requiresAuth) {
|
|
708
760
|
throw new Error(
|
|
@@ -711,7 +763,8 @@ function validateProviderConfiguration(
|
|
|
711
763
|
: `Provider ${providerName}: custom models need a credential source, but none is configured. ` +
|
|
712
764
|
`"auth" only selects the scheme ("auth: apiKey" does not supply a key). ` +
|
|
713
765
|
`Fix by adding "apiKeyEnv: <ENV_VAR>" (recommended) or "apiKey: <literal-key>", ` +
|
|
714
|
-
`or set "auth: none" if the endpoint is genuinely unauthenticated
|
|
766
|
+
`or set "auth: none" if the endpoint is genuinely unauthenticated. ` +
|
|
767
|
+
`A key already stored by an earlier provider setup or "auth login" is declared with "credential: store".`,
|
|
715
768
|
);
|
|
716
769
|
}
|
|
717
770
|
}
|
|
@@ -948,7 +1001,7 @@ function validateProviderConfiguration(
|
|
|
948
1001
|
}
|
|
949
1002
|
}
|
|
950
1003
|
|
|
951
|
-
function validateModelsConfig(config: ModelsConfig): void {
|
|
1004
|
+
export function validateModelsConfig(config: ModelsConfig): void {
|
|
952
1005
|
for (const [providerName, providerConfig] of Object.entries(config.providers ?? {})) {
|
|
953
1006
|
validateProviderConfiguration(
|
|
954
1007
|
providerName,
|
|
@@ -957,6 +1010,7 @@ function validateModelsConfig(config: ModelsConfig): void {
|
|
|
957
1010
|
headers: providerConfig.headers,
|
|
958
1011
|
apiKey: providerConfig.apiKey,
|
|
959
1012
|
apiKeyEnv: providerConfig.apiKeyEnv,
|
|
1013
|
+
credential: providerConfig.credential,
|
|
960
1014
|
api: providerConfig.api as Api | undefined,
|
|
961
1015
|
transport: providerConfig.transport,
|
|
962
1016
|
auth: (providerConfig.auth ?? "apiKey") as ProviderAuthMode,
|
|
@@ -2360,6 +2414,8 @@ export class ModelRegistry {
|
|
|
2360
2414
|
#keylessProviders: Set<string> = new Set();
|
|
2361
2415
|
#optionalAuthProviders: Set<string> = new Set();
|
|
2362
2416
|
#credentiallessAuthFallbackProviders: Map<string, string> = new Map();
|
|
2417
|
+
#storeCredentialDeclarationWarned: Set<string> = new Set();
|
|
2418
|
+
#pendingStoreCredentialDeclarationWarnings: Set<string> = new Set();
|
|
2363
2419
|
#providerEvidenceApiKeys: Map<string, string | undefined> = new Map();
|
|
2364
2420
|
#providerActivity: ReadonlyMap<string, ProviderActivityEvidence> = new Map();
|
|
2365
2421
|
#configuredProviderIds: ReadonlySet<string> = new Set();
|
|
@@ -2932,6 +2988,8 @@ export class ModelRegistry {
|
|
|
2932
2988
|
};
|
|
2933
2989
|
const expectedGeneration = this.#catalogRefreshGeneration;
|
|
2934
2990
|
const isCurrent = () => !this.#disposed && this.#catalogRefreshGeneration === expectedGeneration;
|
|
2991
|
+
let pendingDeclarationWarnings: string[] = [];
|
|
2992
|
+
let prunedDeclarationWarned: string[] = [];
|
|
2935
2993
|
const commit = () => {
|
|
2936
2994
|
if (finished) throw new Error("Models config reload candidate is no longer active");
|
|
2937
2995
|
if (!diagnostics.valid) throw new Error("Cannot commit an invalid models config reload candidate");
|
|
@@ -2956,6 +3014,18 @@ export class ModelRegistry {
|
|
|
2956
3014
|
// The captured source may precede the current disk revision.
|
|
2957
3015
|
this.#lastStaticLoadMtime = null;
|
|
2958
3016
|
committed = true;
|
|
3017
|
+
// Load-time pruning runs on the instance that loaded the config. A
|
|
3018
|
+
// staged publish swaps state without re-running this instance's load, so
|
|
3019
|
+
// prune its marks against the published provider set here too: otherwise
|
|
3020
|
+
// a provider removed and re-added through staged publish never warns
|
|
3021
|
+
// again because the live mark outlives the config that justified it.
|
|
3022
|
+
prunedDeclarationWarned = [];
|
|
3023
|
+
for (const provider of this.#storeCredentialDeclarationWarned) {
|
|
3024
|
+
if (this.#configuredProviderIds.has(provider)) continue;
|
|
3025
|
+
this.#storeCredentialDeclarationWarned.delete(provider);
|
|
3026
|
+
prunedDeclarationWarned.push(provider);
|
|
3027
|
+
}
|
|
3028
|
+
pendingDeclarationWarnings = [...registry.#pendingStoreCredentialDeclarationWarnings];
|
|
2959
3029
|
} catch (error) {
|
|
2960
3030
|
this.#swapReloadableState(registry);
|
|
2961
3031
|
this.#reconcileOwnedConfigApiKeys(this.#ownedConfigApiKeys, registry.#ownedConfigApiKeys);
|
|
@@ -2969,6 +3039,12 @@ export class ModelRegistry {
|
|
|
2969
3039
|
this.#reconcileOwnedConfigApiKeys(this.#ownedConfigApiKeys, registry.#ownedConfigApiKeys);
|
|
2970
3040
|
this.#acceptedModelsConfigPresent = previousConfigPresent;
|
|
2971
3041
|
this.#acceptedConfigValue = previousConfigValue;
|
|
3042
|
+
// The publish is being undone before it is durable: drop the warnings it
|
|
3043
|
+
// would have emitted so no log line survives for a config that is no
|
|
3044
|
+
// longer in effect, and restore the marks this publish pruned.
|
|
3045
|
+
pendingDeclarationWarnings = [];
|
|
3046
|
+
for (const provider of prunedDeclarationWarned) this.#storeCredentialDeclarationWarned.add(provider);
|
|
3047
|
+
prunedDeclarationWarned = [];
|
|
2972
3048
|
committed = false;
|
|
2973
3049
|
}
|
|
2974
3050
|
finished = true;
|
|
@@ -2977,6 +3053,11 @@ export class ModelRegistry {
|
|
|
2977
3053
|
const finalize = () => {
|
|
2978
3054
|
if (finished) return;
|
|
2979
3055
|
if (!committed) throw new Error("Cannot finalize an unpublished models configuration");
|
|
3056
|
+
// A publish becomes durable only here. Emit the deferred declaration
|
|
3057
|
+
// warnings now so a rolled-back publish produces no stale log line.
|
|
3058
|
+
const warnings = pendingDeclarationWarnings;
|
|
3059
|
+
pendingDeclarationWarnings = [];
|
|
3060
|
+
this.#emitStoreCredentialDeclarationWarnings(warnings);
|
|
2980
3061
|
finished = true;
|
|
2981
3062
|
this.#catalogRefreshGeneration++;
|
|
2982
3063
|
this.#notifyCatalogChanged();
|
|
@@ -3505,6 +3586,13 @@ export class ModelRegistry {
|
|
|
3505
3586
|
error: configError,
|
|
3506
3587
|
} = this.#loadCustomModels();
|
|
3507
3588
|
this.#keylessProviders = keylessProviders;
|
|
3589
|
+
// Descriptor-level credentialless providers (e.g. `devin`, which authenticates
|
|
3590
|
+
// through its own CLI) must be keyless from the first static load. Registering
|
|
3591
|
+
// them only during the discovery sweep left registries that never sweep —
|
|
3592
|
+
// subagents reusing or rebuilding a registry, `refresh("offline")` — treating
|
|
3593
|
+
// them as unauthenticated, so managed fallback chains skipped or failed them.
|
|
3594
|
+
// A provider configured in models.yml keeps the auth mode configured there.
|
|
3595
|
+
this.#registerCredentiallessDescriptorProviders(configuredProviders);
|
|
3508
3596
|
this.#discoveryManager.setProviders(discoverableProviders);
|
|
3509
3597
|
this.#configuredProviderIds = new Set(configuredProviders);
|
|
3510
3598
|
this.#configuredDiscoveryProviderIds = new Set(discoverableProviders.map(provider => provider.provider));
|
|
@@ -4060,6 +4148,19 @@ export class ModelRegistry {
|
|
|
4060
4148
|
}
|
|
4061
4149
|
}
|
|
4062
4150
|
|
|
4151
|
+
#emitStoreCredentialDeclarationWarnings(providers: Iterable<string>): string[] {
|
|
4152
|
+
const added: string[] = [];
|
|
4153
|
+
for (const provider of providers) {
|
|
4154
|
+
if (this.#storeCredentialDeclarationWarned.has(provider)) continue;
|
|
4155
|
+
this.#storeCredentialDeclarationWarned.add(provider);
|
|
4156
|
+
added.push(provider);
|
|
4157
|
+
logger.warn("provider declares credential: store but no stored API-key credential exists for it", {
|
|
4158
|
+
provider,
|
|
4159
|
+
});
|
|
4160
|
+
}
|
|
4161
|
+
return added;
|
|
4162
|
+
}
|
|
4163
|
+
|
|
4063
4164
|
#loadCustomModels(): CustomModelsResult {
|
|
4064
4165
|
this.#configuredApiKeyEnvNames.clear();
|
|
4065
4166
|
const loaded = this.#modelsConfigSource ?? this.#modelsConfigFile.tryLoad();
|
|
@@ -4080,6 +4181,9 @@ export class ModelRegistry {
|
|
|
4080
4181
|
found: true,
|
|
4081
4182
|
};
|
|
4082
4183
|
} else if (status === "not-found") {
|
|
4184
|
+
// No configured providers remain, so no declaration marks are current.
|
|
4185
|
+
this.#storeCredentialDeclarationWarned.clear();
|
|
4186
|
+
this.#pendingStoreCredentialDeclarationWarnings.clear();
|
|
4083
4187
|
return {
|
|
4084
4188
|
models: [],
|
|
4085
4189
|
overrides: new Map(),
|
|
@@ -4098,10 +4202,31 @@ export class ModelRegistry {
|
|
|
4098
4202
|
const discoverableProviders: DiscoveryProviderConfig[] = [];
|
|
4099
4203
|
const providerEntries = Object.entries(value.providers ?? {});
|
|
4100
4204
|
const configuredProviders = new Set(Object.keys(value.providers ?? {}));
|
|
4205
|
+
let storedCredentialRows: readonly AuthCredentialSnapshotEntry[] | undefined;
|
|
4206
|
+
const hasStoredApiKeyCredential = (provider: string): boolean => {
|
|
4207
|
+
// Only a stored api_key row resolves a `credential: store` declaration;
|
|
4208
|
+
// runtime keys, config overrides, OAuth rows, env mapping, and fallback
|
|
4209
|
+
// resolvers are different credential sources. The row predicate is shared
|
|
4210
|
+
// with provider setup's cleanup so the two scopes cannot drift apart.
|
|
4211
|
+
storedCredentialRows ??= this.authStorage.exportSnapshot().credentials;
|
|
4212
|
+
return storedCredentialRows.some(entry => isStoredApiKeyCredentialForProvider(entry, provider));
|
|
4213
|
+
};
|
|
4101
4214
|
|
|
4102
4215
|
for (const [providerName, providerConfig] of providerEntries) {
|
|
4103
4216
|
const credentialPinActive = !this.#stagedReloadCandidate && this.authStorage.hasAnyCredentialPin(providerName);
|
|
4104
4217
|
const authMode = (providerConfig.auth ?? "apiKey") as ProviderAuthMode;
|
|
4218
|
+
if (
|
|
4219
|
+
providerConfig.credential === PROVIDER_CREDENTIAL_STORE &&
|
|
4220
|
+
!hasStoredApiKeyCredential(providerName) &&
|
|
4221
|
+
!this.#storeCredentialDeclarationWarned.has(providerName)
|
|
4222
|
+
) {
|
|
4223
|
+
if (this.#stagedReloadCandidate) {
|
|
4224
|
+
// A candidate may be rolled back; defer the warning until publish.
|
|
4225
|
+
this.#pendingStoreCredentialDeclarationWarnings.add(providerName);
|
|
4226
|
+
} else {
|
|
4227
|
+
this.#emitStoreCredentialDeclarationWarnings([providerName]);
|
|
4228
|
+
}
|
|
4229
|
+
}
|
|
4105
4230
|
const isOAuth = resolveCustomModelIsOAuth(
|
|
4106
4231
|
(providerConfig.api as Api | undefined) ?? "openai-completions",
|
|
4107
4232
|
providerConfig.auth as ProviderAuthMode | undefined,
|
|
@@ -4283,6 +4408,14 @@ export class ModelRegistry {
|
|
|
4283
4408
|
allModelOverrides.set(providerName, perModel);
|
|
4284
4409
|
}
|
|
4285
4410
|
}
|
|
4411
|
+
// A mark only describes the config currently loaded. Without pruning, a
|
|
4412
|
+
// provider removed and re-added with a missing key would never warn again.
|
|
4413
|
+
for (const provider of this.#storeCredentialDeclarationWarned) {
|
|
4414
|
+
if (!configuredProviders.has(provider)) this.#storeCredentialDeclarationWarned.delete(provider);
|
|
4415
|
+
}
|
|
4416
|
+
for (const provider of this.#pendingStoreCredentialDeclarationWarnings) {
|
|
4417
|
+
if (!configuredProviders.has(provider)) this.#pendingStoreCredentialDeclarationWarnings.delete(provider);
|
|
4418
|
+
}
|
|
4286
4419
|
|
|
4287
4420
|
return {
|
|
4288
4421
|
models: this.#parseModels(value),
|
|
@@ -5265,6 +5398,25 @@ export class ModelRegistry {
|
|
|
5265
5398
|
];
|
|
5266
5399
|
}
|
|
5267
5400
|
|
|
5401
|
+
/** Mark descriptors that allow unauthenticated use as keyless with optional auth. */
|
|
5402
|
+
#registerCredentiallessDescriptorProviders(
|
|
5403
|
+
excludedProviderIds: ReadonlySet<string> = new Set(),
|
|
5404
|
+
providerFilter?: ReadonlySet<string>,
|
|
5405
|
+
): void {
|
|
5406
|
+
const disabledProviders = getDisabledProviderIdsFromSettings(this.#settings);
|
|
5407
|
+
for (const descriptor of PROVIDER_DESCRIPTORS) {
|
|
5408
|
+
if (
|
|
5409
|
+
!descriptor.allowUnauthenticated ||
|
|
5410
|
+
disabledProviders.has(descriptor.providerId) ||
|
|
5411
|
+
excludedProviderIds.has(descriptor.providerId) ||
|
|
5412
|
+
(providerFilter !== undefined && !providerFilter.has(descriptor.providerId))
|
|
5413
|
+
)
|
|
5414
|
+
continue;
|
|
5415
|
+
this.#keylessProviders.add(descriptor.providerId);
|
|
5416
|
+
this.#optionalAuthProviders.add(descriptor.providerId);
|
|
5417
|
+
}
|
|
5418
|
+
}
|
|
5419
|
+
|
|
5268
5420
|
async #collectBuiltInModelManagerOptions(
|
|
5269
5421
|
excludedProviderIds: ReadonlySet<string> = new Set(),
|
|
5270
5422
|
providerFilter?: ReadonlySet<string>,
|
|
@@ -5285,11 +5437,7 @@ export class ModelRegistry {
|
|
|
5285
5437
|
!excludedProviderIds.has(descriptor.providerId) &&
|
|
5286
5438
|
(providerFilter === undefined || providerFilter.has(descriptor.providerId)),
|
|
5287
5439
|
);
|
|
5288
|
-
|
|
5289
|
-
if (!descriptor.allowUnauthenticated) continue;
|
|
5290
|
-
this.#keylessProviders.add(descriptor.providerId);
|
|
5291
|
-
this.#optionalAuthProviders.add(descriptor.providerId);
|
|
5292
|
-
}
|
|
5440
|
+
this.#registerCredentiallessDescriptorProviders(excludedProviderIds, providerFilter);
|
|
5293
5441
|
// Use peekApiKey to avoid OAuth token refresh during discovery.
|
|
5294
5442
|
// The token is only needed if the dynamic fetch fires (cache miss),
|
|
5295
5443
|
// and failures there are handled gracefully.
|
|
@@ -225,11 +225,38 @@ export const ProviderAuthSchema = z.enum(["apiKey", "none", "oauth"]);
|
|
|
225
225
|
export type ProviderAuthMode = z.infer<typeof ProviderAuthSchema>;
|
|
226
226
|
export type ProviderDiscovery = z.infer<typeof ProviderDiscoverySchema>;
|
|
227
227
|
|
|
228
|
+
/**
|
|
229
|
+
* The one spelling of the `credential: store` declaration. The schema, the
|
|
230
|
+
* loader's provider validation, and provider setup all derive from this
|
|
231
|
+
* constant so the literal cannot drift between writer and reader.
|
|
232
|
+
*/
|
|
233
|
+
export const PROVIDER_CREDENTIAL_STORE = "store" as const;
|
|
234
|
+
export type ProviderStoreCredential = typeof PROVIDER_CREDENTIAL_STORE;
|
|
235
|
+
|
|
228
236
|
const ProviderConfigSchema = z
|
|
229
237
|
.object({
|
|
230
238
|
baseUrl: z.string().min(1).optional(),
|
|
231
239
|
apiKey: z.string().min(1).optional(),
|
|
232
240
|
apiKeyEnv: z.string().min(1).optional(),
|
|
241
|
+
/**
|
|
242
|
+
* Declares that the provider's API key lives in the local credential
|
|
243
|
+
* store (`agent.db`) rather than in `apiKey`/`apiKeyEnv`. Provider setup
|
|
244
|
+
* writes both the key and this declaration for pasted credentials;
|
|
245
|
+
* `auth login` stores credentials but never edits `models.yml`, so after a
|
|
246
|
+
* login add this declaration by hand. The runtime resolves it through the
|
|
247
|
+
* same stored-credential layer used by every other provider; the field
|
|
248
|
+
* exists so the loader can tell a deliberate store-backed provider from
|
|
249
|
+
* one that simply forgot a credential source.
|
|
250
|
+
*
|
|
251
|
+
* Ambiguous when combined with any other credential source (`apiKey`,
|
|
252
|
+
* `apiKeyEnv`, `openaiCompat.apiKey`, `openaiCompat.apiKeyEnv`), and
|
|
253
|
+
* incompatible with `auth: none`, `auth: oauth`, and
|
|
254
|
+
* `api: bedrock-converse-stream` at provider or model level. It does not
|
|
255
|
+
* pin a credential row and is not verified at load time; a provider whose
|
|
256
|
+
* stored credential is missing resolves no stored credential until one is
|
|
257
|
+
* stored (the registry logs a warning at load).
|
|
258
|
+
*/
|
|
259
|
+
credential: z.literal(PROVIDER_CREDENTIAL_STORE).optional(),
|
|
233
260
|
api: z
|
|
234
261
|
.enum([
|
|
235
262
|
"openai-completions",
|
|
@@ -4128,6 +4128,7 @@ export const SETTINGS_SCHEMA = {
|
|
|
4128
4128
|
"synthetic",
|
|
4129
4129
|
"parallel",
|
|
4130
4130
|
"searxng",
|
|
4131
|
+
"keenable",
|
|
4131
4132
|
] as const,
|
|
4132
4133
|
default: "auto",
|
|
4133
4134
|
ui: {
|
|
@@ -4185,6 +4186,11 @@ export const SETTINGS_SCHEMA = {
|
|
|
4185
4186
|
{ value: "synthetic", label: "Synthetic", description: "Requires SYNTHETIC_API_KEY" },
|
|
4186
4187
|
{ value: "parallel", label: "Parallel", description: "Requires PARALLEL_API_KEY" },
|
|
4187
4188
|
{ value: "searxng", label: "SearXNG", description: "Requires SEARXNG_ENDPOINT or searxng.endpoint" },
|
|
4189
|
+
{
|
|
4190
|
+
value: "keenable",
|
|
4191
|
+
label: "Keenable",
|
|
4192
|
+
description: "Keyless; optional KEENABLE_API_KEY raises rate limits",
|
|
4193
|
+
},
|
|
4188
4194
|
],
|
|
4189
4195
|
},
|
|
4190
4196
|
},
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Byte-stable JSON for coordinator idempotency and outbox digests: keys are
|
|
3
|
+
* sorted by code unit. Unlike `sdk/broker/canonical-json.ts` it does not omit
|
|
4
|
+
* `undefined` properties, so persisted digests of the same value stay stable
|
|
5
|
+
* across both the server and question-state writers.
|
|
6
|
+
*/
|
|
7
|
+
export function canonicalJson(value: unknown): string {
|
|
8
|
+
if (value === null || typeof value !== "object") return JSON.stringify(value);
|
|
9
|
+
if (Array.isArray(value)) return `[${value.map(canonicalJson).join(",")}]`;
|
|
10
|
+
const record = value as Record<string, unknown>;
|
|
11
|
+
return `{${Object.keys(record)
|
|
12
|
+
.sort()
|
|
13
|
+
.map(key => `${JSON.stringify(key)}:${canonicalJson(record[key])}`)
|
|
14
|
+
.join(",")}}`;
|
|
15
|
+
}
|
|
@@ -30,6 +30,7 @@ export interface CoordinatorNamespace {
|
|
|
30
30
|
identity: string;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
/** Namespace digests: sorted keys; rejects undefined/function/symbol/bigint instead of encoding them. */
|
|
33
34
|
function canonicalJson(value: unknown): string {
|
|
34
35
|
if (value === null || typeof value === "boolean" || typeof value === "number") return JSON.stringify(value);
|
|
35
36
|
if (typeof value === "string") return JSON.stringify(value);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as crypto from "node:crypto";
|
|
2
|
+
import { isRecord } from "@gajae-code/utils";
|
|
2
3
|
import { compileGateSchema, schemaHash, validateGateAnswer } from "../modes/shared/agent-wire/workflow-gate-schema";
|
|
3
4
|
import type { JsonSchema, WorkflowGate } from "../modes/shared/agent-wire/workflow-gate-types";
|
|
4
5
|
import { buildAskGateAnswerSchema, validateAskGateStageState } from "../modes/shared/agent-wire/workflow-gate-types";
|
|
@@ -126,8 +127,6 @@ export interface PrivateAskGateCodecV1 {
|
|
|
126
127
|
}
|
|
127
128
|
|
|
128
129
|
const MAX_TEXT = 4096;
|
|
129
|
-
const isRecord = (value: unknown): value is Record<string, unknown> =>
|
|
130
|
-
typeof value === "object" && value !== null && !Array.isArray(value);
|
|
131
130
|
const boundedText = (value: unknown, max = 256): value is string =>
|
|
132
131
|
typeof value === "string" && /\S/u.test(value) && Buffer.byteLength(value) <= max;
|
|
133
132
|
function sameKeys(value: Record<string, unknown>, permitted: readonly string[]): boolean {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import * as fs from "node:fs/promises";
|
|
3
3
|
import * as path from "node:path";
|
|
4
|
-
import { logger } from "@gajae-code/utils";
|
|
4
|
+
import { isRecord, logger } from "@gajae-code/utils";
|
|
5
5
|
import { withFileLock } from "../config/file-lock";
|
|
6
|
+
import { canonicalJson } from "./canonical-json";
|
|
6
7
|
import { ensureCoordinatorDirectory, syncCoordinatorDirectory, writeCoordinatorAtomic } from "./durability";
|
|
7
8
|
import type { PrivateAskGateCodecV1, PublicReason } from "./question-gate-codec";
|
|
8
9
|
|
|
@@ -403,15 +404,6 @@ const PUBLIC_CLAIM_LEASE_MS = 30_000;
|
|
|
403
404
|
export const COORDINATOR_SESSION_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
|
|
404
405
|
export const COORDINATOR_REPORT_ID_PATTERN = /^report-[a-f0-9]{64}$/;
|
|
405
406
|
const digest = (value: string): string => createHash("sha256").update(value).digest("hex");
|
|
406
|
-
const canonicalJson = (value: unknown): string => {
|
|
407
|
-
if (value === null || typeof value !== "object") return JSON.stringify(value);
|
|
408
|
-
if (Array.isArray(value)) return `[${value.map(canonicalJson).join(",")}]`;
|
|
409
|
-
const record = value as Record<string, unknown>;
|
|
410
|
-
return `{${Object.keys(record)
|
|
411
|
-
.sort()
|
|
412
|
-
.map(key => `${JSON.stringify(key)}:${canonicalJson(record[key])}`)
|
|
413
|
-
.join(",")}}`;
|
|
414
|
-
};
|
|
415
407
|
const lockOptions = (signal?: AbortSignal) => (signal ? { signal } : undefined);
|
|
416
408
|
|
|
417
409
|
function publicDeliveryFor(event: OutboxEventV1): PublicDeliveryV1 {
|
|
@@ -706,8 +698,6 @@ function migrateLegacyTransactionV1(transaction: CoordinatorSessionTransactionV1
|
|
|
706
698
|
}
|
|
707
699
|
|
|
708
700
|
function assertTransaction(transaction: CoordinatorSessionTransactionV1, namespaceId: string, sessionId: string): void {
|
|
709
|
-
const isRecord = (value: unknown): value is Record<string, unknown> =>
|
|
710
|
-
typeof value === "object" && value !== null && !Array.isArray(value);
|
|
711
701
|
migrateLegacyTransactionV1(transaction);
|
|
712
702
|
const isTime = (value: unknown) => typeof value === "string" && Number.isFinite(Date.parse(value));
|
|
713
703
|
const safeId = (value: unknown) => typeof value === "string" && /^[a-zA-Z0-9][a-zA-Z0-9_.:-]{0,127}$/.test(value);
|
|
@@ -42,6 +42,7 @@ import {
|
|
|
42
42
|
} from "../sdk/session-activation";
|
|
43
43
|
import { SessionListTraversalError, sessionListPageFromResponse, traverseSessionList } from "../sdk/session-list";
|
|
44
44
|
import { sanitizeSdkStartupMessage } from "../sdk/startup-capability";
|
|
45
|
+
import { canonicalJson } from "./canonical-json";
|
|
45
46
|
import {
|
|
46
47
|
ackCodexWakeEvent,
|
|
47
48
|
bindDelegateCodexHandoff,
|
|
@@ -1398,16 +1399,6 @@ async function writeCoordinatorIdempotencyFile(file: string, value: CoordinatorT
|
|
|
1398
1399
|
await writeCoordinatorAtomic(file, `${JSON.stringify(value)}\n`);
|
|
1399
1400
|
}
|
|
1400
1401
|
|
|
1401
|
-
function canonicalJson(value: unknown): string {
|
|
1402
|
-
if (value === null || typeof value !== "object") return JSON.stringify(value);
|
|
1403
|
-
if (Array.isArray(value)) return `[${value.map(canonicalJson).join(",")}]`;
|
|
1404
|
-
const record = value as Record<string, unknown>;
|
|
1405
|
-
return `{${Object.keys(record)
|
|
1406
|
-
.sort()
|
|
1407
|
-
.map(key => `${JSON.stringify(key)}:${canonicalJson(record[key])}`)
|
|
1408
|
-
.join(",")}}`;
|
|
1409
|
-
}
|
|
1410
|
-
|
|
1411
1402
|
function sensitivePublicField(key: string): boolean {
|
|
1412
1403
|
return /^(?:token|secret|credential(?:s)?|authorization|password|api[_-]?key|endpoint|url|uri)$/i.test(key);
|
|
1413
1404
|
}
|
|
@@ -29,7 +29,7 @@ import * as fsSync from "node:fs";
|
|
|
29
29
|
import * as fs from "node:fs/promises";
|
|
30
30
|
import * as os from "node:os";
|
|
31
31
|
import * as path from "node:path";
|
|
32
|
-
import { parseFrontmatter, tryParseJson } from "@gajae-code/utils";
|
|
32
|
+
import { isRecord, parseFrontmatter, tryParseJson } from "@gajae-code/utils";
|
|
33
33
|
import { YAML } from "bun";
|
|
34
34
|
import type { MCPServer } from "../capability/mcp";
|
|
35
35
|
import { normalizeClaudeMcpJson, normalizeCodexMcpToml, validateMCPCompatServer } from "../discovery/mcp-compat";
|
|
@@ -287,10 +287,6 @@ function toMCPServerConfig(server: MCPServer): MCPServerConfig {
|
|
|
287
287
|
return config as unknown as MCPServerConfig;
|
|
288
288
|
}
|
|
289
289
|
|
|
290
|
-
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
291
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
292
|
-
}
|
|
293
|
-
|
|
294
290
|
interface DestinationMcpState {
|
|
295
291
|
/** Existing server entries, or null when the destination is unusable. */
|
|
296
292
|
servers: Record<string, unknown> | null;
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* foreign files are never implicit competing runtime authorities, and user-home
|
|
10
10
|
* (`~/.claude`, `~/.codex`) configuration is never scanned.
|
|
11
11
|
*/
|
|
12
|
-
import { tryParseJson } from "@gajae-code/utils";
|
|
12
|
+
import { isRecord, tryParseJson } from "@gajae-code/utils";
|
|
13
13
|
import { type MCPServer, mcpCapability } from "../capability/mcp";
|
|
14
14
|
import type { LoadResult, SourceMeta } from "../capability/types";
|
|
15
15
|
import { createSourceMeta, expandEnvVarsDeep } from "./helpers";
|
|
@@ -21,10 +21,6 @@ const PROVIDER_IDS = {
|
|
|
21
21
|
|
|
22
22
|
const PROTOTYPE_SENSITIVE_SERVER_NAMES = new Set(["__proto__", "prototype", "constructor"]);
|
|
23
23
|
|
|
24
|
-
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
25
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
24
|
function isStringRecord(value: unknown): value is Record<string, string> {
|
|
29
25
|
return isRecord(value) && Object.values(value).every(item => typeof item === "string");
|
|
30
26
|
}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import * as fs from "node:fs";
|
|
10
10
|
import * as fsPromises from "node:fs/promises";
|
|
11
11
|
import * as path from "node:path";
|
|
12
|
-
import { logger, tryParseJson } from "@gajae-code/utils";
|
|
12
|
+
import { isRecord, logger, tryParseJson } from "@gajae-code/utils";
|
|
13
13
|
import { registerProvider } from "../capability";
|
|
14
14
|
import { type ReadFileOptions, readFile } from "../capability/fs";
|
|
15
15
|
import { type MCPServer, mcpCapability } from "../capability/mcp";
|
|
@@ -61,9 +61,6 @@ interface MCPConfigFile {
|
|
|
61
61
|
export interface MCPJsonLoadResult extends LoadResult<MCPServer> {
|
|
62
62
|
disabledServers: string[];
|
|
63
63
|
}
|
|
64
|
-
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
65
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
66
|
-
}
|
|
67
64
|
function isStringArray(value: unknown): value is string[] {
|
|
68
65
|
return Array.isArray(value) && value.every(item => typeof item === "string");
|
|
69
66
|
}
|
package/src/edit/notebook.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as path from "node:path";
|
|
2
|
-
import { isEnoent } from "@gajae-code/utils";
|
|
2
|
+
import { isEnoent, isRecord } from "@gajae-code/utils";
|
|
3
3
|
|
|
4
4
|
export type NotebookCellType = "code" | "markdown" | "raw";
|
|
5
5
|
|
|
@@ -26,10 +26,6 @@ export function isNotebookPath(filePath: string): boolean {
|
|
|
26
26
|
return path.extname(filePath).toLowerCase() === ".ipynb";
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
30
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
29
|
function isCellType(value: unknown): value is NotebookCellType {
|
|
34
30
|
return value === "code" || value === "markdown" || value === "raw";
|
|
35
31
|
}
|
|
@@ -2,6 +2,7 @@ import * as crypto from "node:crypto";
|
|
|
2
2
|
import * as nodeFs from "node:fs";
|
|
3
3
|
import * as fs from "node:fs/promises";
|
|
4
4
|
import * as path from "node:path";
|
|
5
|
+
import { isRecord } from "@gajae-code/utils";
|
|
5
6
|
import {
|
|
6
7
|
candidateRegistryEntry,
|
|
7
8
|
type GjcBundleTransactionDecision,
|
|
@@ -254,9 +255,6 @@ function safeInstalledRoot(scope: GjcPluginScope, cwd: string, pluginRoot: strin
|
|
|
254
255
|
if (!relative || relative.startsWith(`..${path.sep}`) || relative === ".." || path.isAbsolute(relative)) return null;
|
|
255
256
|
return root;
|
|
256
257
|
}
|
|
257
|
-
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
258
|
-
return typeof value === "object" && value !== null;
|
|
259
|
-
}
|
|
260
258
|
|
|
261
259
|
function isStringArray(value: unknown): value is string[] {
|
|
262
260
|
return Array.isArray(value) && value.every(item => typeof item === "string");
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import * as fs from "node:fs/promises";
|
|
3
3
|
import { upgradeJsonSchemaTo202012 } from "@gajae-code/ai/utils/schema";
|
|
4
|
+
import { isRecord } from "@gajae-code/utils";
|
|
4
5
|
import { resolveWithinRoot } from "./paths";
|
|
5
6
|
import { GjcPluginLoadError, type JsonSchema202012, PluginImplementationHashMismatchError } from "./types";
|
|
6
7
|
|
|
7
8
|
export const JSON_SCHEMA_202012_URI = "https://json-schema.org/draft/2020-12/schema";
|
|
8
9
|
|
|
9
|
-
/** Stable JSON serialization used for schema hashes and registry fingerprints. */
|
|
10
|
+
/** Stable JSON serialization used for schema hashes and registry fingerprints. Throws on an explicit undefined value or object key and on non-finite numbers; bigints fail in JSON.stringify. Sparse array holes are not visited by map and produce invalid JSON, so callers must not pass sparse arrays. */
|
|
10
11
|
export function canonicalJson(value: unknown): string {
|
|
11
12
|
if (value === null || typeof value !== "object") {
|
|
12
13
|
if (typeof value === "number" && !Number.isFinite(value)) throw new Error("JSON value must be finite");
|
|
@@ -35,10 +36,6 @@ export async function verifyImplementationHash(filePath: string, expected: strin
|
|
|
35
36
|
return actual;
|
|
36
37
|
}
|
|
37
38
|
|
|
38
|
-
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
39
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
39
|
function cloneCanonical(value: unknown): unknown {
|
|
43
40
|
if (Array.isArray(value)) return value.map(cloneCanonical);
|
|
44
41
|
if (isRecord(value)) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isRecord } from "@gajae-code/utils";
|
|
1
2
|
import {
|
|
2
3
|
FUNCTION_HOOK_CAPABILITIES,
|
|
3
4
|
type FunctionHookCapability,
|
|
@@ -95,10 +96,6 @@ const MCP_SERVER_ALIAS_UNSUPPORTED_KEYS = [
|
|
|
95
96
|
|
|
96
97
|
const MCP_TRANSPORTS: readonly GjcPluginMcpTransport[] = ["stdio", "http", "sse"];
|
|
97
98
|
|
|
98
|
-
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
99
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
99
|
function rejectUnknownKeys(
|
|
103
100
|
value: Record<string, unknown>,
|
|
104
101
|
allowed: readonly string[],
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
+
import { isRecord } from "@gajae-code/utils";
|
|
2
3
|
|
|
3
4
|
export type CrystalClassification = "confirmed" | "inferred" | "disputed";
|
|
4
5
|
export type CrystalItemKind = "goal" | "constraint" | "decision" | "acceptance_criterion" | "non_goal";
|
|
@@ -295,10 +296,6 @@ type CrystalSemanticProfile = {
|
|
|
295
296
|
stateValue: string;
|
|
296
297
|
};
|
|
297
298
|
|
|
298
|
-
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
299
|
-
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
300
|
-
}
|
|
301
|
-
|
|
302
299
|
function text(value: unknown, name: string, max = MAX_TEXT): string {
|
|
303
300
|
if (typeof value !== "string" || value.trim() === "") throw new Error(`${name} must be non-empty text`);
|
|
304
301
|
const result = value.normalize("NFC").trim();
|