@experiture/xyra-cli 0.5.1 → 0.6.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/README.md +30 -10
- package/dist/auth/administrationSession.js +25 -0
- package/dist/auth/administrationSession.js.map +1 -0
- package/dist/auth/oauthClient.js +13 -3
- package/dist/auth/oauthClient.js.map +1 -1
- package/dist/auth/session.js +50 -12
- package/dist/auth/session.js.map +1 -1
- package/dist/chat/runtimeChatClient.js +23217 -0
- package/dist/chat/runtimeChatClient.js.map +7 -0
- package/dist/commands/chat.js +175 -0
- package/dist/commands/chat.js.map +1 -0
- package/dist/commands/generatedCommandRegistry.js +17 -2
- package/dist/commands/generatedCommandRegistry.js.map +1 -1
- package/dist/commands/login.js +5 -1
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/mcpContext.js +7 -3
- package/dist/commands/mcpContext.js.map +1 -1
- package/dist/commands/session.js +13 -6
- package/dist/commands/session.js.map +1 -1
- package/dist/commands/tools.js +1 -1
- package/dist/commands/tools.js.map +1 -1
- package/dist/config/configStore.js +669 -86
- package/dist/config/configStore.js.map +7 -1
- package/dist/config/environments.js +13 -0
- package/dist/config/environments.js.map +1 -1
- package/dist/errors/CliError.js +4 -1
- package/dist/errors/CliError.js.map +1 -1
- package/dist/evaluation/localSession.js +62 -0
- package/dist/evaluation/localSession.js.map +1 -0
- package/dist/index.js +55 -20
- package/dist/index.js.map +1 -1
- package/dist/mcp/confirmation.js +14 -17
- package/dist/mcp/confirmation.js.map +1 -1
- package/dist/mcp/mcpClient.js +274 -114
- package/dist/mcp/mcpClient.js.map +7 -1
- package/dist/output/console.js +3 -1
- package/dist/output/console.js.map +1 -1
- package/package.json +9 -3
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../libs/xyra-types/src/xyra-administration.ts", "../../../../libs/xyra-types/src/canonical-runtime-json.ts", "../../src/config/configStore.ts", "../../src/errors/CliError.ts", "../../src/config/environments.ts"],
|
|
4
|
+
"sourcesContent": ["/** A requested maintenance target. It is never a runtime identity or an authorization decision. */\nexport type XyraAdministrationTargetV1 =\n | Readonly<{ targetKind: 'global-resource'; managedProductId: 'xyra-ai' }>\n | Readonly<{ targetKind: 'configuration-owner'; configurationTenantId: string; managedProductId: string }>\n | Readonly<{ targetKind: 'customer-resource'; targetTenantId: string; activeProductId: string }>;\n\nexport type XyraAccessPurposeV1 = 'runtime' | 'administration';\nexport type XyraAuthorityDecisionPhaseV1 = 'discovery' | 'execution';\n\nexport type XyraAdministrationRequestV1 = Readonly<{\n operationId: string;\n target: XyraAdministrationTargetV1;\n}>;\n\n/** Auth-resolved relationship facts, without a permission snapshot or runtime licence grant. */\nexport type XyraAdministrationResolvedTargetV1 =\n | Readonly<{ targetKind: 'global-resource'; managedProductId: 'xyra-ai'; relationshipKind: 'global-resource' }>\n | Readonly<{ targetKind: 'configuration-owner' | 'customer-resource'; managedProductId: string;\n relationshipKind: 'native-product-tenant'; activeProductId: 'xyra-ai'; actualTenantId: string;\n licensedProductId: 'xyra-ai'; commercialState: string }>\n | Readonly<{ targetKind: 'configuration-owner' | 'customer-resource'; managedProductId: string;\n relationshipKind: 'embedded-product-entitlement'; activeProductId: string; actualTenantId: string;\n licenseSourceProductId: string; licensedProductId: 'xyra-ai'; licenseOwnerTenantId: string;\n bindingId: string; entitlementId: string; sourceEntitlementId: string; commercialState: string }>;\n\nexport type XyraAdministrationDecisionV1 = Readonly<{\n operationId: string;\n purpose: XyraAuthorityDecisionPhaseV1;\n accessPurpose: 'administration';\n allowed: boolean;\n code: string;\n productId: 'xyra-ai';\n operatorTenantId: string | null;\n targetTenantId: string | null;\n grantId: string | null;\n target: XyraAdministrationTargetV1;\n resolvedTarget: XyraAdministrationResolvedTargetV1 | null;\n}>;\n\n/** Protected execution/approval scope, not a permission grant and never a public argument. */\nexport type XyraAdministrationExecutionScopeV1 = Readonly<{\n accessPurpose: 'administration';\n resourceAudience: string;\n administrationTransport: 'native-http' | 'delegated-oauth';\n actorOperatorTenantId: string | null;\n targetHash: string;\n target: XyraAdministrationTargetV1;\n resolvedTarget: XyraAdministrationResolvedTargetV1;\n}>;\n\nconst identifier = (value: unknown): value is string => typeof value === 'string'\n && /^[A-Za-z0-9][A-Za-z0-9._:-]{0,49}$/.test(value);\nconst guid = (value: unknown): value is string => typeof value === 'string'\n && /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i.test(value)\n && value !== '00000000-0000-0000-0000-000000000000';\nconst record = (value: unknown): value is Record<string, unknown> => value !== null\n && typeof value === 'object' && !Array.isArray(value);\nconst exact = (value: Record<string, unknown>, keys: readonly string[]): boolean =>\n Object.keys(value).length === keys.length && keys.every(key => Object.prototype.hasOwnProperty.call(value, key));\n\n/** Strictly parse the closed object shape; raw duplicate JSON keys belong to the transport parser. */\nexport function parseXyraAdministrationTargetV1(value: unknown): XyraAdministrationTargetV1 | null {\n if (!record(value)) return null;\n if (value.targetKind === 'global-resource' && exact(value, ['targetKind', 'managedProductId'])\n && value.managedProductId === 'xyra-ai') {\n return { targetKind: 'global-resource', managedProductId: 'xyra-ai' };\n }\n if (value.targetKind === 'configuration-owner'\n && exact(value, ['targetKind', 'configurationTenantId', 'managedProductId'])\n && identifier(value.configurationTenantId) && identifier(value.managedProductId)) {\n return { targetKind: 'configuration-owner', configurationTenantId: value.configurationTenantId,\n managedProductId: value.managedProductId };\n }\n if (value.targetKind === 'customer-resource'\n && exact(value, ['targetKind', 'targetTenantId', 'activeProductId'])\n && identifier(value.targetTenantId) && identifier(value.activeProductId)) {\n return { targetKind: 'customer-resource', targetTenantId: value.targetTenantId, activeProductId: value.activeProductId };\n }\n return null;\n}\n\n/** Stable exact tuple for cache/request binding, excluding display text and mutable capabilities. */\nexport function xyraAdministrationTargetKeyV1(target: XyraAdministrationTargetV1): string {\n return JSON.stringify(target.targetKind === 'global-resource'\n ? [target.targetKind, target.managedProductId]\n : target.targetKind === 'configuration-owner'\n ? [target.targetKind, target.configurationTenantId, target.managedProductId]\n : [target.targetKind, target.targetTenantId, target.activeProductId]);\n}\n\n/** Validate independent Auth facts against the exact request, never infer a missing relationship. */\nexport function parseXyraAdministrationResolvedTargetV1(\n value: unknown, target: XyraAdministrationTargetV1,\n): XyraAdministrationResolvedTargetV1 | null {\n if (!record(value) || value.targetKind !== target.targetKind) return null;\n const managedProductId = target.targetKind === 'customer-resource' ? 'xyra-ai' : target.managedProductId;\n if (value.managedProductId !== managedProductId) return null;\n if (target.targetKind === 'global-resource') {\n return exact(value, ['targetKind', 'managedProductId', 'relationshipKind']) && value.relationshipKind === 'global-resource'\n ? { targetKind: 'global-resource', managedProductId: 'xyra-ai', relationshipKind: 'global-resource' } : null;\n }\n const base = ['targetKind', 'managedProductId', 'relationshipKind', 'activeProductId', 'actualTenantId', 'licensedProductId', 'commercialState'];\n const embedded = ['licenseSourceProductId', 'licenseOwnerTenantId', 'bindingId', 'entitlementId', 'sourceEntitlementId'];\n const isNative = value.relationshipKind === 'native-product-tenant';\n if ((!isNative && value.relationshipKind !== 'embedded-product-entitlement')\n || !exact(value, isNative ? base : [...base, ...embedded]) || value.licensedProductId !== 'xyra-ai'\n || !base.filter(key => !['targetKind', 'relationshipKind'].includes(key)).every(key => identifier(value[key]))\n || (isNative ? value.activeProductId !== 'xyra-ai' : !embedded.every(key => identifier(value[key])))\n || value.actualTenantId !== (target.targetKind === 'customer-resource' ? target.targetTenantId : target.configurationTenantId)\n || (target.targetKind === 'customer-resource' && value.activeProductId !== target.activeProductId)\n || (target.targetKind === 'configuration-owner' && value.activeProductId !== target.managedProductId)\n || (!isNative && (value.licenseSourceProductId !== value.activeProductId\n || !['bindingId', 'entitlementId', 'sourceEntitlementId'].every(key => guid(value[key]))\n || (target.targetKind === 'configuration-owner' && value.licenseOwnerTenantId !== target.configurationTenantId)))) return null;\n return { ...value } as XyraAdministrationResolvedTargetV1;\n}\n\n/** Parse a decision only for the operation, phase and target that were actually requested. */\nexport function parseXyraAdministrationDecisionV1(value: unknown,\n request: XyraAdministrationRequestV1, purpose: XyraAuthorityDecisionPhaseV1,\n): XyraAdministrationDecisionV1 | null {\n if (!record(value) || !exact(value, ['operationId', 'purpose', 'accessPurpose', 'allowed', 'code', 'productId',\n 'operatorTenantId', 'targetTenantId', 'grantId', 'target', 'resolvedTarget'])\n || value.operationId !== request.operationId || value.purpose !== purpose || value.accessPurpose !== 'administration'\n || value.productId !== 'xyra-ai' || typeof value.allowed !== 'boolean' || typeof value.code !== 'string'\n || !/^[A-Z0-9_.]{1,160}$/.test(value.code)\n || !(value.operatorTenantId === null || identifier(value.operatorTenantId))\n || !(value.grantId === null || guid(value.grantId))) return null;\n const target = parseXyraAdministrationTargetV1(value.target);\n if (!target || xyraAdministrationTargetKeyV1(target) !== xyraAdministrationTargetKeyV1(request.target)\n || value.targetTenantId !== (target.targetKind === 'global-resource' ? null\n : target.targetKind === 'configuration-owner' ? target.configurationTenantId : target.targetTenantId)) return null;\n const resolvedTarget = parseXyraAdministrationResolvedTargetV1(value.resolvedTarget, target);\n if (value.allowed) {\n if (!resolvedTarget || (value.code === 'AUTHORIZATION.ALLOWED.SUPER_USER'\n ? value.operatorTenantId !== null || value.grantId !== null\n : !['AUTHORIZATION.ALLOWED', 'AUTHORIZATION.ALLOWED.LICENSEE'].includes(value.code) || value.operatorTenantId === null || value.grantId === null)) return null;\n if (value.code === 'AUTHORIZATION.ALLOWED.LICENSEE'\n && (target.targetKind === 'global-resource' || resolvedTarget.relationshipKind !== 'embedded-product-entitlement'\n || resolvedTarget.licenseOwnerTenantId !== value.operatorTenantId || resolvedTarget.activeProductId === 'xyra-ai')) return null;\n } else if (value.code.startsWith('AUTHORIZATION.ALLOWED') || value.resolvedTarget !== null) return null;\n return { ...value, target, resolvedTarget } as XyraAdministrationDecisionV1;\n}\n", "export type CanonicalRuntimeJsonFailureReasonV1 =\n | 'cyclic_value'\n | 'non_finite_number'\n | 'non_plain_object'\n | 'sparse_array'\n | 'unsupported_value'\n | 'invalid_unicode'\n | 'symbol_key'\n | 'accessor_property';\n\nexport class CanonicalRuntimeJsonErrorV1 extends TypeError {\n readonly code = 'XYRA.RUNTIME.CANONICAL_JSON_INVALID' as const;\n\n constructor(\n readonly reason: CanonicalRuntimeJsonFailureReasonV1,\n readonly path: string,\n ) {\n super(`Canonical runtime JSON rejected ${reason} at ${path}.`);\n this.name = 'CanonicalRuntimeJsonErrorV1';\n }\n}\n\nfunction invalid(reason: CanonicalRuntimeJsonFailureReasonV1, path: string): never {\n throw new CanonicalRuntimeJsonErrorV1(reason, path);\n}\n\nfunction compareOrdinal(left: string, right: string): number {\n return left < right ? -1 : left > right ? 1 : 0;\n}\n\nfunction objectPath(parent: string, key: string): string {\n return `${parent}[${JSON.stringify(key)}]`;\n}\n\nfunction assertCanonicalString(value: string, path: string): void {\n for (let index = 0; index < value.length; index += 1) {\n const codeUnit = value.charCodeAt(index);\n if (codeUnit === 0) invalid('invalid_unicode', path);\n if (codeUnit >= 0xd800 && codeUnit <= 0xdbff) {\n const next = value.charCodeAt(index + 1);\n if (!(next >= 0xdc00 && next <= 0xdfff)) invalid('invalid_unicode', path);\n index += 1;\n } else if (codeUnit >= 0xdc00 && codeUnit <= 0xdfff) {\n invalid('invalid_unicode', path);\n }\n }\n}\n\nfunction isPlainJsonObject(value: object): value is Record<string, unknown> {\n const prototype = Object.getPrototypeOf(value);\n return prototype === Object.prototype || prototype === null;\n}\n\nfunction canonicalize(\n value: unknown,\n path: string,\n ancestors: Set<object>,\n): null | boolean | number | string | readonly unknown[] | Readonly<Record<string, unknown>> {\n if (value === null || typeof value === 'boolean') return value;\n if (typeof value === 'string') {\n assertCanonicalString(value, path);\n return value;\n }\n if (typeof value === 'number') {\n if (!Number.isFinite(value)) invalid('non_finite_number', path);\n return value;\n }\n if (typeof value !== 'object') invalid('unsupported_value', path);\n if (ancestors.has(value)) invalid('cyclic_value', path);\n ancestors.add(value);\n try {\n if (Array.isArray(value)) {\n if (Object.getOwnPropertySymbols(value).length > 0) invalid('symbol_key', path);\n const ownKeys = Object.keys(value);\n if (ownKeys.length !== value.length) invalid('sparse_array', path);\n const result: unknown[] = [];\n for (let index = 0; index < value.length; index += 1) {\n if (!Object.prototype.hasOwnProperty.call(value, index)) invalid('sparse_array', `${path}[${index}]`);\n const descriptor = Object.getOwnPropertyDescriptor(value, String(index));\n if (!descriptor || descriptor.get || descriptor.set) invalid('accessor_property', `${path}[${index}]`);\n result.push(canonicalize(descriptor.value, `${path}[${index}]`, ancestors));\n }\n return result;\n }\n if (!isPlainJsonObject(value)) invalid('non_plain_object', path);\n if (Object.getOwnPropertySymbols(value).length > 0) invalid('symbol_key', path);\n const result: Record<string, unknown> = {};\n for (const key of Object.keys(value).sort(compareOrdinal)) {\n assertCanonicalString(key, objectPath(path, key));\n const descriptor = Object.getOwnPropertyDescriptor(value, key);\n if (!descriptor || descriptor.get || descriptor.set) {\n invalid('accessor_property', objectPath(path, key));\n }\n result[key] = canonicalize(descriptor.value, objectPath(path, key), ancestors);\n }\n return result;\n } finally {\n ancestors.delete(value);\n }\n}\n\n/**\n * Canonical compact JSON for executable runtime contracts.\n *\n * This is intentionally different from pretty, newline-terminated signed\n * inventory artifacts. It accepts only ordinary JSON values and preserves\n * array order while sorting object keys by locale-independent ordinal order.\n */\nexport function canonicalRuntimeJsonV1(value: unknown): string {\n return JSON.stringify(canonicalize(value, '$', new Set<object>()));\n}\n\n/** Browser-safe exact UTF-8 bytes for the canonical representation. */\nexport function canonicalRuntimeUtf8BytesV1(value: unknown): Uint8Array {\n return new TextEncoder().encode(canonicalRuntimeJsonV1(value));\n}\n\n/** Browser-safe exact UTF-8 byte length for a string already validated here. */\nexport function canonicalRuntimeUtf8ByteLengthV1(value: unknown): number {\n return canonicalRuntimeUtf8BytesV1(value).byteLength;\n}\n\nexport interface BoundedRuntimeJsonLimitsV1 {\n readonly maximumBytes?: number;\n readonly maximumDepth?: number;\n}\n\nexport class BoundedRuntimeJsonErrorV1 extends SyntaxError {\n constructor(readonly reason: string) {\n super(`Bounded runtime JSON rejected ${reason}.`);\n this.name = 'BoundedRuntimeJsonErrorV1';\n }\n}\n\nconst boundedInvalid = (reason: string): never => { throw new BoundedRuntimeJsonErrorV1(reason); };\n/**\n * Reviewed ceiling for bounded runtime JSON. The default stays one mebibyte so\n * existing callers are unchanged; callers that own a larger reviewed artifact\n * may request up to this ceiling. The measured worst-case evaluation turn\n * evidence is about 1.14 MiB, because a frozen turn carries the exact model\n * input for every stage, including the router's context evidence.\n */\nexport const MAXIMUM_BOUNDED_RUNTIME_JSON_BYTES_V1 = 2_097_152;\nfunction boundedLimits(limits: BoundedRuntimeJsonLimitsV1) {\n const maximumBytes = limits.maximumBytes ?? 1048576;\n const maximumDepth = limits.maximumDepth ?? 16;\n if (!Number.isSafeInteger(maximumBytes) || maximumBytes < 1 || maximumBytes > MAXIMUM_BOUNDED_RUNTIME_JSON_BYTES_V1\n || !Number.isSafeInteger(maximumDepth) || maximumDepth < 1 || maximumDepth > 24) boundedInvalid('limits');\n return { maximumBytes, maximumDepth };\n}\nfunction boundedUnicode(value: string): boolean {\n for (let index = 0; index < value.length; index += 1) {\n const unit = value.charCodeAt(index);\n if (unit >= 0xd800 && unit <= 0xdbff) {\n const next = value.charCodeAt(++index);\n if (!(next >= 0xdc00 && next <= 0xdfff)) return false;\n } else if (unit >= 0xdc00 && unit <= 0xdfff) return false;\n }\n return true;\n}\n\n// One descriptor-based copy owner serves wire JSON and ordinary in-process data.\n// The latter preserves optional undefined values and the evaluation observation\n// limits; it is never used by the wire JSON parser or as canonical JSON evidence.\nfunction copyBoundedRuntimeData(input: unknown, maximumBytes: number, maximumDepth: number, jsonOnly: boolean, preserveKeyOrder = false): unknown {\n let nodes = 0; let characters = 0; const ancestors = new Set<object>();\n function copy(value: unknown, depth: number): unknown {\n if (++nodes > (jsonOnly ? 200000 : 100000) || depth > maximumDepth) boundedInvalid('shape');\n if (value === null || typeof value === 'boolean' || (!jsonOnly && value === undefined)) return value;\n if (typeof value === 'number' && Number.isFinite(value)) return value;\n if (typeof value === 'string') {\n characters += value.length;\n if (jsonOnly ? characters > maximumBytes || !boundedUnicode(value)\n : value.length > 1048576 || characters > 16777216) boundedInvalid('text');\n return value;\n }\n if (!value || typeof value !== 'object' || ancestors.has(value)) boundedInvalid('shape');\n const objectValue = value as object;\n const array = Array.isArray(objectValue); const prototype = Object.getPrototypeOf(objectValue);\n const arrayLength = array ? (objectValue as unknown[]).length : 0;\n if (array ? prototype !== Array.prototype && (jsonOnly || prototype !== null)\n : prototype !== Object.prototype && prototype !== null) boundedInvalid('shape');\n const keys = Reflect.ownKeys(objectValue);\n if (keys.length > 10001 || keys.some(key => typeof key !== 'string')) boundedInvalid('shape');\n if (array && keys.length !== arrayLength + 1) boundedInvalid('array');\n const seen = new Set<string>(); const result: Record<string, unknown> | unknown[] = array ? [] : {};\n ancestors.add(objectValue);\n try {\n for (const key of (jsonOnly || array || preserveKeyOrder ? keys : keys.sort()) as string[]) {\n if (array && key === 'length') continue;\n const descriptor = Object.getOwnPropertyDescriptor(objectValue, key)!;\n if (!descriptor.enumerable || !('value' in descriptor) || key.length > (jsonOnly ? 160 : 256)\n || (jsonOnly && seen.has(key.toLowerCase()))\n || (array && (!/^(0|[1-9][0-9]*)$/.test(key) || Number(key) >= arrayLength))) boundedInvalid('shape');\n seen.add(key.toLowerCase());\n Object.defineProperty(result, key, { enumerable: true, writable: true, configurable: true, value: copy(descriptor.value, depth + 1) });\n }\n } finally { ancestors.delete(objectValue); }\n return result;\n }\n return copy(input, 0);\n}\n\n/** Detached in-process values; source order can be retained for existing definition fingerprints. */\nexport function boundedRuntimeDataV1<T>(input: T, preserveKeyOrder = false): T {\n return copyBoundedRuntimeData(input, 16777216, 24, false, preserveKeyOrder) as T;\n}\n\n/** Detached, closed-over-data JSON value with bounded depth, nodes, keys and canonical UTF-8 size. */\nexport function boundedRuntimeJsonDataV1(input: unknown, limits: BoundedRuntimeJsonLimitsV1 = {}): unknown {\n const { maximumBytes, maximumDepth } = boundedLimits(limits);\n const value = copyBoundedRuntimeData(input, maximumBytes, maximumDepth, true);\n if (canonicalRuntimeUtf8ByteLengthV1(value) > maximumBytes) boundedInvalid('bytes');\n return value;\n}\n\n/** Parses already fatal-UTF-8-decoded JSON without duplicate keys or lossy integer conversion. */\nexport function parseBoundedRuntimeJsonV1(source: string, limits: BoundedRuntimeJsonLimitsV1 = {}): unknown {\n const { maximumBytes, maximumDepth } = boundedLimits(limits);\n if (typeof source !== 'string' || source.length > maximumBytes || !boundedUnicode(source)\n || new TextEncoder().encode(source).byteLength > maximumBytes) boundedInvalid('bytes');\n let index = 0; let nodes = 0;\n const whitespace = () => { while (/[\\x20\\t\\r\\n]/.test(source[index] ?? '\\0')) index += 1; };\n function string(): string {\n const start = index;\n if (source[index++] !== '\"') boundedInvalid('string');\n while (index < source.length) {\n const char = source[index++];\n if (char === '\\\\') { index += 1; continue; }\n if (char === '\"') {\n try {\n const parsed = JSON.parse(source.slice(start, index));\n if (!boundedUnicode(parsed)) boundedInvalid('unicode');\n return parsed;\n } catch (error) {\n if (error instanceof BoundedRuntimeJsonErrorV1) throw error;\n boundedInvalid('string');\n }\n }\n }\n return boundedInvalid('string');\n }\n function value(depth: number): void {\n if (++nodes > 200000 || depth > maximumDepth) boundedInvalid('shape');\n whitespace(); const char = source[index];\n if (char === '\"') { string(); return; }\n if (char === '{') {\n index += 1; whitespace(); const seen = new Set<string>();\n if (source[index] === '}') { index += 1; return; }\n for (;;) {\n const item = string().toLowerCase();\n if (seen.has(item)) boundedInvalid('duplicate_key');\n seen.add(item); whitespace();\n if (source[index++] !== ':') boundedInvalid('object');\n value(depth + 1); whitespace();\n const end = source[index++];\n if (end === '}') return;\n if (end !== ',') boundedInvalid('object');\n whitespace();\n }\n }\n if (char === '[') {\n index += 1; whitespace();\n if (source[index] === ']') { index += 1; return; }\n let count = 0;\n for (;;) {\n if (++count > 10000) boundedInvalid('array');\n value(depth + 1); whitespace();\n const end = source[index++];\n if (end === ']') return;\n if (end !== ',') boundedInvalid('array');\n whitespace();\n }\n }\n const token = /^(?:true|false|null|-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?)/.exec(source.slice(index));\n if (!token) boundedInvalid('value');\n const tokenText = token![0];\n if (/^-?\\d/.test(tokenText)) {\n const numeric = Number(tokenText);\n if (!Number.isFinite(numeric)) boundedInvalid('number');\n if (Number.isInteger(numeric)) {\n if (!Number.isSafeInteger(numeric)) boundedInvalid('number');\n const parts = /^(-?)(\\d+)(?:\\.(\\d+))?(?:[eE]([+-]?\\d+))?$/.exec(tokenText)!;\n let digits = (parts[2] + (parts[3] ?? '')).replace(/^0+/, '');\n let power = Number(parts[4] ?? 0) - (parts[3]?.length ?? 0);\n if (digits) {\n const trimmed = digits.replace(/0+$/, ''); power += digits.length - trimmed.length; digits = trimmed;\n if (power < 0 || digits.length + power > 16 || Number(digits + '0'.repeat(power)) !== Math.abs(numeric)) boundedInvalid('number');\n }\n }\n }\n index += tokenText.length;\n }\n value(0); whitespace();\n if (index !== source.length) boundedInvalid('trailing');\n try { return boundedRuntimeJsonDataV1(JSON.parse(source), limits); }\n catch (error) {\n if (error instanceof BoundedRuntimeJsonErrorV1) throw error;\n return boundedInvalid('json');\n }\n}\n", "import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { homedir } from 'node:os';\nimport { dirname, join } from 'node:path';\nimport { CliError, CliErrorCodes } from '../errors/CliError';\nimport {parseXyraAdministrationTargetV1} from '@xyra/types/xyra-administration';\nimport {parseBoundedRuntimeJsonV1} from '@xyra/types/canonical-runtime-json';\nimport {\n DEFAULT_ENVIRONMENTS,\n DEFAULT_ENVIRONMENT_NAME,\n XyraEnvironment,\n} from './environments';\n\n/** Non-secret CLI config persisted to disk. Never holds tokens. */\nexport interface CliConfig {\n activeEnvironment: string;\n environments: Record<string, XyraEnvironment>;\n}\n\nconst CONFIG_DIR =\n process.env.XYRA_CLI_CONFIG_DIR ?? join(homedir(), '.config', 'xyra');\nconst CONFIG_PATH = join(CONFIG_DIR, 'config.json');\n\nfunction requireHttpsOrTest(name: string, url: string): void {\n let parsed: URL;\n try {\n parsed = new URL(url);\n } catch {\n throw new CliError(CliErrorCodes.ConfigInvalid, `Environment '${name}' has an invalid URL: ${url}`);\n }\n const isTestDomain = parsed.hostname.endsWith('.test');\n if (parsed.protocol !== 'https:' && !isTestDomain) {\n throw new CliError(\n CliErrorCodes.ConfigInvalid,\n `Environment '${name}' must use https (got ${parsed.protocol}//${parsed.host}).`,\n );\n }\n}\n\nfunction requireHttpOrigin(name: string, url: string): void {\n let parsed: URL;\n try {\n parsed = new URL(url);\n } catch {\n throw new CliError(CliErrorCodes.ConfigInvalid, `Environment '${name}' has an invalid URL: ${url}`);\n }\n const isLocalhost = parsed.hostname === 'localhost' || parsed.hostname === '127.0.0.1';\n const isTestDomain = parsed.hostname.endsWith('.test');\n const allowedProtocol = parsed.protocol === 'https:' || (parsed.protocol === 'http:' && (isLocalhost || isTestDomain));\n if (!allowedProtocol || parsed.username || parsed.password || parsed.search || parsed.hash\n || (parsed.pathname !== '/' && parsed.pathname !== '')) {\n throw new CliError(\n CliErrorCodes.ConfigInvalid,\n `Environment '${name}' must be an HTTP(S) origin without credentials, path, query, or fragment.`,\n );\n }\n}\n\nexport function validateEnvironment(env: XyraEnvironment): void {\n for (const [field, url] of [\n ['mcpUrl', env.mcpUrl],\n ['authorizationEndpoint', env.authorizationEndpoint],\n ['tokenEndpoint', env.tokenEndpoint],\n ] as const) {\n if (!url) {\n throw new CliError(CliErrorCodes.ConfigInvalid, `Environment '${env.name}' is missing ${field}.`);\n }\n requireHttpsOrTest(`${env.name}.${field}`, url);\n }\n if (!env.orchestratorUrl) {\n throw new CliError(CliErrorCodes.ConfigInvalid, `Environment '${env.name}' is missing orchestratorUrl.`);\n }\n requireHttpOrigin(`${env.name}.orchestratorUrl`, env.orchestratorUrl);\n if (!env.clientId) {\n throw new CliError(CliErrorCodes.ConfigInvalid, `Environment '${env.name}' is missing clientId.`);\n }\n if (!env.redirectPath.startsWith('/')) {\n throw new CliError(CliErrorCodes.ConfigInvalid, `Environment '${env.name}' redirectPath must start with '/'.`);\n }\n}\n\nexport class ConfigStore {\n constructor(\n private readonly path: string = CONFIG_PATH,\n private readonly activeEnvironmentOverride?: string,\n private readonly accessPurposeOverride?:string,\n private readonly administrationTargetOverride?:string,\n private readonly sessionNameOverride?:string,\n ) {}\n getSessionName():string|undefined{return this.sessionNameOverride;}\n\n load(): CliConfig {\n if (!existsSync(this.path)) {\n return {\n activeEnvironment: this.activeEnvironmentOverride ?? DEFAULT_ENVIRONMENT_NAME,\n environments: { ...DEFAULT_ENVIRONMENTS },\n };\n }\n let raw: CliConfig;\n try {\n raw = JSON.parse(readFileSync(this.path, 'utf8')) as CliConfig;\n } catch {\n throw new CliError(CliErrorCodes.ConfigInvalid, `Config file at ${this.path} is not valid JSON.`);\n }\n // Merge built-in defaults so new default envs appear without a rewrite,\n // but user-defined overrides win.\n const environments = Object.fromEntries(\n Object.entries({ ...DEFAULT_ENVIRONMENTS, ...(raw.environments ?? {}) })\n .map(([name, env]) => [\n name,\n DEFAULT_ENVIRONMENTS[name] ? { ...DEFAULT_ENVIRONMENTS[name], ...env } : env,\n ]),\n );\n const activeEnvironment = this.activeEnvironmentOverride ?? raw.activeEnvironment ?? DEFAULT_ENVIRONMENT_NAME;\n return { activeEnvironment, environments };\n }\n\n save(config: CliConfig): void {\n mkdirSync(dirname(this.path), { recursive: true });\n writeFileSync(this.path, `${JSON.stringify(config, null, 2)}\\n`, { mode: 0o600 });\n }\n\n listEnvironments(): { name: string; active: boolean }[] {\n const config = this.load();\n return Object.keys(config.environments)\n .sort()\n .map((name) => ({ name, active: name === config.activeEnvironment }));\n }\n\n getActiveEnvironment(): XyraEnvironment {\n const config = this.load();\n const env = config.environments[config.activeEnvironment];\n if (!env) {\n throw new CliError(\n CliErrorCodes.EnvironmentNotFound,\n `Active environment '${config.activeEnvironment}' is not defined. Run 'xyra env use <name>'.`,\n );\n }\n validateEnvironment(env);\n if(env.accessPurpose!==undefined||env.administrationTarget!==undefined)throw new CliError(CliErrorCodes.ConfigInvalid,\n 'Purpose and selected administration target are invocation-only, not stored environment or actor fields.');\n const purpose=this.accessPurposeOverride??'runtime';\n if(!['runtime','administration'].includes(purpose)||(purpose==='runtime'&&this.administrationTargetOverride!==undefined))\n throw new CliError(CliErrorCodes.InvalidArguments,'Select runtime or administration; a maintenance target requires administration purpose.');\n if(purpose==='runtime')return env;\n const profile=env.administrationOAuth;\n if(!profile||!profile.clientId||!/^[A-Za-z0-9][A-Za-z0-9._:-]{0,99}$/.test(profile.clientId)||profile.clientId===env.clientId\n ||env.mcpUrl!==env.oauthResource||!Array.isArray(profile.scopes)||profile.scopes.length>100\n ||!profile.scopes.includes('openid')||!profile.scopes.includes('offline_access')\n ||profile.scopes.some(scope=>typeof scope!=='string'||!/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/.test(scope))\n ||!profile.redirectPath||!/^\\/callback\\/[A-Za-z0-9_-]+$/.test(profile.redirectPath))\n throw new CliError(CliErrorCodes.ConfigInvalid,`Environment '${env.name}' needs its registered Xyra-owned public administration CLI profile.`,\n 'Configure administrationOAuth with its separate native client, approved loopback callback path and delegated scopes; do not reuse the runtime or HTTPS connector client.');\n let selected:unknown;\n try{selected=this.administrationTargetOverride===undefined?{targetKind:'global-resource',managedProductId:'xyra-ai'}\n :parseBoundedRuntimeJsonV1(this.administrationTargetOverride,{maximumBytes:8192,maximumDepth:4});}\n catch{throw new CliError(CliErrorCodes.InvalidArguments,'The administration target must be one bounded JSON object without repeated fields.');}\n const target=parseXyraAdministrationTargetV1(selected);\n if(!target)throw new CliError(CliErrorCodes.InvalidArguments,'Select one complete global, configuration-owner or customer administration target.');\n return {...env,clientId:profile.clientId,redirectPath:profile.redirectPath,scopes:[...profile.scopes],accessPurpose:'administration',administrationTarget:target};\n }\n\n useEnvironment(name: string): XyraEnvironment {\n const config = this.load();\n const env = config.environments[name];\n if (!env) {\n throw new CliError(\n CliErrorCodes.EnvironmentNotFound,\n `Environment '${name}' is not defined. Known: ${Object.keys(config.environments).join(', ')}.`,\n );\n }\n validateEnvironment(env);\n config.activeEnvironment = name;\n this.save({ ...config, activeEnvironment: name });\n return env;\n }\n}\n", "/**\n * CliError - explicit, fail-loud CLI error with a stable local code.\n * Local codes are prefixed XYRA.CLI.* so they never collide with canonical\n * server-side Xyra codes (which are preserved verbatim from MCP results).\n */\nexport class CliError extends Error {\n readonly code: string;\n readonly hint?: string;\n readonly httpStatus?: number;\n\n constructor(code: string, message: string, hint?: string, httpStatus?: number) {\n super(message);\n this.name = 'CliError';\n this.code = code;\n this.hint = hint;\n this.httpStatus = httpStatus;\n }\n}\n\nexport const CliErrorCodes = {\n ConfigInvalid: 'XYRA.CLI.CONFIG_INVALID',\n EnvironmentNotFound: 'XYRA.CLI.ENVIRONMENT_NOT_FOUND',\n NotAuthenticated: 'XYRA.CLI.NOT_AUTHENTICATED',\n OAuthStateMismatch: 'XYRA.CLI.OAUTH_STATE_MISMATCH',\n OAuthCallbackError: 'XYRA.CLI.OAUTH_CALLBACK_ERROR',\n TokenStoreUnavailable: 'XYRA.CLI.TOKEN_STORE_UNAVAILABLE',\n TokenExchangeFailed: 'XYRA.CLI.TOKEN_EXCHANGE_FAILED',\n InsufficientScope: 'XYRA.CLI.INSUFFICIENT_SCOPE',\n McpProtocolError: 'XYRA.CLI.MCP_PROTOCOL_ERROR',\n ToolCallFailed: 'XYRA.CLI.TOOL_CALL_FAILED',\n ChatRequestFailed: 'XYRA.CLI.CHAT_REQUEST_FAILED',\n InvalidArguments: 'XYRA.CLI.INVALID_ARGUMENTS',\n ConfirmationRequired: 'XYRA.CLI.CONFIRMATION_REQUIRED',\n AmbiguousAlias: 'XYRA.CLI.AMBIGUOUS_ALIAS',\n} as const;\n", "/**\n * Environment definitions. These are NON-SECRET connection profiles only.\n * Tokens are never stored here (see auth/tokenStore.ts).\n *\n * Defaults are grounded in the CLI spec (verified against Auth/MCP code\n * 2026-07-07): delegated public PKCE client `experiture-xyra-mcp-delegated`,\n * offline_access enabled (migration 20260707013000). Tool access is resolved\n * from the delegated user's real permissions, not a CLI-specific mode scope.\n */\nexport interface XyraEnvironment {\n name: string;\n mcpUrl: string;\n orchestratorUrl: string;\n oauthResource: string;\n authorizationEndpoint: string;\n tokenEndpoint: string;\n clientId: string;\n /** Exact registered loopback callback path (gate G1). Port is dynamic. */\n redirectPath: string;\n /** OIDC/delegated-login scopes. offline_access is required for refresh. */\n scopes: string[];\n /** Separate Xyra-owned public native CLI registration; never the connector or runtime client. */\n administrationOAuth?: {clientId:string;redirectPath:string;scopes:string[]};\n /** Transient purpose and selected resource, never persisted as actor/runtime identity. */\n accessPurpose?:'runtime'|'administration';\n administrationTarget?:import('@xyra/types/xyra-administration').XyraAdministrationTargetV1;\n}\n\nexport const DEFAULT_ENVIRONMENTS: Record<string, XyraEnvironment> = {\n dev: {\n name: 'dev',\n mcpUrl: 'https://mcp.dev.experiture.ai/mcp',\n orchestratorUrl: 'https://orchestrator.dev.experiture.ai',\n oauthResource: 'https://mcp.dev.experiture.ai/mcp',\n authorizationEndpoint: 'https://dev.app.experiture.ai/api/auth/oauth/authorize',\n tokenEndpoint: 'https://dev.app.experiture.ai/api/auth/oauth/token',\n clientId: 'experiture-xyra-mcp-delegated',\n redirectPath: '/callback/QYfSVwRg9okE',\n scopes: ['openid', 'profile', 'email', 'offline_access'],\n },\n staging: {\n name: 'staging',\n mcpUrl: 'https://mcp.staging.experiture.ai/mcp',\n orchestratorUrl: 'https://app.experiture.ai',\n oauthResource: 'https://mcp.staging.experiture.ai/mcp',\n authorizationEndpoint: 'https://app.experiture.ai/api/auth/oauth/authorize',\n tokenEndpoint: 'https://app.experiture.ai/api/auth/oauth/token',\n clientId: 'experiture-xyra-mcp-delegated',\n redirectPath: '/callback/QYfSVwRg9okE',\n scopes: ['openid', 'profile', 'email', 'offline_access'],\n },\n local: {\n name: 'local',\n mcpUrl: 'https://app.experiture.test/mcp',\n orchestratorUrl: 'http://localhost:8000',\n oauthResource: 'https://mcp.dev.experiture.ai/mcp',\n authorizationEndpoint: 'https://app.experiture.test/api/auth/oauth/authorize',\n tokenEndpoint: 'https://app.experiture.test/api/auth/oauth/token',\n clientId: 'experiture-xyra-mcp-delegated',\n redirectPath: '/callback/QYfSVwRg9okE',\n scopes: ['openid', 'profile', 'email', 'offline_access'],\n },\n};\n\nexport const DEFAULT_ENVIRONMENT_NAME = 'dev';\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6DA,IAAAA,SAAA,kCAAAC;AAqBA,IAAAD,SAAA,gCAAA;AASA,IAAAA,SAAA,0CAAA;AA2BA,IAAAA,SAAA,oCAAA;AApEA,QAAM,aAAa,CAAC,UAAoC,OAAO,UAAU,YACpE,qCAAqC,KAAK,KAAK;AACpD,QAAM,OAAO,CAAC,UAAoC,OAAO,UAAU,YAC9D,kEAAkE,KAAK,KAAK,KAC5E,UAAU;AACf,QAAM,SAAS,CAAC,UAAqD,UAAU,QAC1E,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK;AACtD,QAAM,QAAQ,CAAC,OAAgC,SAC7C,OAAO,KAAK,KAAK,EAAE,WAAW,KAAK,UAAU,KAAK,MAAM,SAAO,OAAO,UAAU,eAAe,KAAK,OAAO,GAAG,CAAC;AAGjH,aAAgBC,iCAAgC,OAAc;AAC5D,UAAI,CAAC,OAAO,KAAK;AAAG,eAAO;AAC3B,UAAI,MAAM,eAAe,qBAAqB,MAAM,OAAO,CAAC,cAAc,kBAAkB,CAAC,KACxF,MAAM,qBAAqB,WAAW;AACzC,eAAO,EAAE,YAAY,mBAAmB,kBAAkB,UAAS;MACrE;AACA,UAAI,MAAM,eAAe,yBACpB,MAAM,OAAO,CAAC,cAAc,yBAAyB,kBAAkB,CAAC,KACxE,WAAW,MAAM,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
|
|
7
|
+
}
|
|
@@ -5,6 +5,7 @@ exports.DEFAULT_ENVIRONMENTS = {
|
|
|
5
5
|
dev: {
|
|
6
6
|
name: 'dev',
|
|
7
7
|
mcpUrl: 'https://mcp.dev.experiture.ai/mcp',
|
|
8
|
+
orchestratorUrl: 'https://orchestrator.dev.experiture.ai',
|
|
8
9
|
oauthResource: 'https://mcp.dev.experiture.ai/mcp',
|
|
9
10
|
authorizationEndpoint: 'https://dev.app.experiture.ai/api/auth/oauth/authorize',
|
|
10
11
|
tokenEndpoint: 'https://dev.app.experiture.ai/api/auth/oauth/token',
|
|
@@ -12,9 +13,21 @@ exports.DEFAULT_ENVIRONMENTS = {
|
|
|
12
13
|
redirectPath: '/callback/QYfSVwRg9okE',
|
|
13
14
|
scopes: ['openid', 'profile', 'email', 'offline_access'],
|
|
14
15
|
},
|
|
16
|
+
staging: {
|
|
17
|
+
name: 'staging',
|
|
18
|
+
mcpUrl: 'https://mcp.staging.experiture.ai/mcp',
|
|
19
|
+
orchestratorUrl: 'https://app.experiture.ai',
|
|
20
|
+
oauthResource: 'https://mcp.staging.experiture.ai/mcp',
|
|
21
|
+
authorizationEndpoint: 'https://app.experiture.ai/api/auth/oauth/authorize',
|
|
22
|
+
tokenEndpoint: 'https://app.experiture.ai/api/auth/oauth/token',
|
|
23
|
+
clientId: 'experiture-xyra-mcp-delegated',
|
|
24
|
+
redirectPath: '/callback/QYfSVwRg9okE',
|
|
25
|
+
scopes: ['openid', 'profile', 'email', 'offline_access'],
|
|
26
|
+
},
|
|
15
27
|
local: {
|
|
16
28
|
name: 'local',
|
|
17
29
|
mcpUrl: 'https://app.experiture.test/mcp',
|
|
30
|
+
orchestratorUrl: 'http://localhost:8000',
|
|
18
31
|
oauthResource: 'https://mcp.dev.experiture.ai/mcp',
|
|
19
32
|
authorizationEndpoint: 'https://app.experiture.test/api/auth/oauth/authorize',
|
|
20
33
|
tokenEndpoint: 'https://app.experiture.test/api/auth/oauth/token',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"environments.js","sourceRoot":"","sources":["../../src/config/environments.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"environments.js","sourceRoot":"","sources":["../../src/config/environments.ts"],"names":[],"mappings":";;;AA4Ba,QAAA,oBAAoB,GAAoC;IACnE,GAAG,EAAE;QACH,IAAI,EAAE,KAAK;QACX,MAAM,EAAE,mCAAmC;QAC3C,eAAe,EAAE,wCAAwC;QACzD,aAAa,EAAE,mCAAmC;QAClD,qBAAqB,EAAE,wDAAwD;QAC/E,aAAa,EAAE,oDAAoD;QACnE,QAAQ,EAAE,+BAA+B;QACzC,YAAY,EAAE,wBAAwB;QACtC,MAAM,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,gBAAgB,CAAC;KACzD;IACD,OAAO,EAAE;QACP,IAAI,EAAE,SAAS;QACf,MAAM,EAAE,uCAAuC;QAC/C,eAAe,EAAE,2BAA2B;QAC5C,aAAa,EAAE,uCAAuC;QACtD,qBAAqB,EAAE,oDAAoD;QAC3E,aAAa,EAAE,gDAAgD;QAC/D,QAAQ,EAAE,+BAA+B;QACzC,YAAY,EAAE,wBAAwB;QACtC,MAAM,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,gBAAgB,CAAC;KACzD;IACD,KAAK,EAAE;QACL,IAAI,EAAE,OAAO;QACb,MAAM,EAAE,iCAAiC;QACzC,eAAe,EAAE,uBAAuB;QACxC,aAAa,EAAE,mCAAmC;QAClD,qBAAqB,EAAE,sDAAsD;QAC7E,aAAa,EAAE,kDAAkD;QACjE,QAAQ,EAAE,+BAA+B;QACzC,YAAY,EAAE,wBAAwB;QACtC,MAAM,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,gBAAgB,CAAC;KACzD;CACF,CAAC;AAEW,QAAA,wBAAwB,GAAG,KAAK,CAAC"}
|
package/dist/errors/CliError.js
CHANGED
|
@@ -9,11 +9,13 @@ exports.CliErrorCodes = exports.CliError = void 0;
|
|
|
9
9
|
class CliError extends Error {
|
|
10
10
|
code;
|
|
11
11
|
hint;
|
|
12
|
-
|
|
12
|
+
httpStatus;
|
|
13
|
+
constructor(code, message, hint, httpStatus) {
|
|
13
14
|
super(message);
|
|
14
15
|
this.name = 'CliError';
|
|
15
16
|
this.code = code;
|
|
16
17
|
this.hint = hint;
|
|
18
|
+
this.httpStatus = httpStatus;
|
|
17
19
|
}
|
|
18
20
|
}
|
|
19
21
|
exports.CliError = CliError;
|
|
@@ -28,6 +30,7 @@ exports.CliErrorCodes = {
|
|
|
28
30
|
InsufficientScope: 'XYRA.CLI.INSUFFICIENT_SCOPE',
|
|
29
31
|
McpProtocolError: 'XYRA.CLI.MCP_PROTOCOL_ERROR',
|
|
30
32
|
ToolCallFailed: 'XYRA.CLI.TOOL_CALL_FAILED',
|
|
33
|
+
ChatRequestFailed: 'XYRA.CLI.CHAT_REQUEST_FAILED',
|
|
31
34
|
InvalidArguments: 'XYRA.CLI.INVALID_ARGUMENTS',
|
|
32
35
|
ConfirmationRequired: 'XYRA.CLI.CONFIRMATION_REQUIRED',
|
|
33
36
|
AmbiguousAlias: 'XYRA.CLI.AMBIGUOUS_ALIAS',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CliError.js","sourceRoot":"","sources":["../../src/errors/CliError.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,MAAa,QAAS,SAAQ,KAAK;IACxB,IAAI,CAAS;IACb,IAAI,CAAU;
|
|
1
|
+
{"version":3,"file":"CliError.js","sourceRoot":"","sources":["../../src/errors/CliError.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,MAAa,QAAS,SAAQ,KAAK;IACxB,IAAI,CAAS;IACb,IAAI,CAAU;IACd,UAAU,CAAU;IAE7B,YAAY,IAAY,EAAE,OAAe,EAAE,IAAa,EAAE,UAAmB;QAC3E,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;CACF;AAZD,4BAYC;AAEY,QAAA,aAAa,GAAG;IAC3B,aAAa,EAAE,yBAAyB;IACxC,mBAAmB,EAAE,gCAAgC;IACrD,gBAAgB,EAAE,4BAA4B;IAC9C,kBAAkB,EAAE,+BAA+B;IACnD,kBAAkB,EAAE,+BAA+B;IACnD,qBAAqB,EAAE,kCAAkC;IACzD,mBAAmB,EAAE,gCAAgC;IACrD,iBAAiB,EAAE,6BAA6B;IAChD,gBAAgB,EAAE,6BAA6B;IAC/C,cAAc,EAAE,2BAA2B;IAC3C,iBAAiB,EAAE,8BAA8B;IACjD,gBAAgB,EAAE,4BAA4B;IAC9C,oBAAoB,EAAE,gCAAgC;IACtD,cAAc,EAAE,0BAA0B;CAClC,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LocalEvaluationSession = void 0;
|
|
4
|
+
exports.createLocalEvaluationSession = createLocalEvaluationSession;
|
|
5
|
+
const configStore_1 = require("../config/configStore");
|
|
6
|
+
const tokenStore_1 = require("../auth/tokenStore");
|
|
7
|
+
const session_1 = require("../auth/session");
|
|
8
|
+
const oauthClient_1 = require("../auth/oauthClient");
|
|
9
|
+
const session_2 = require("../commands/session");
|
|
10
|
+
const mcpContext_1 = require("../commands/mcpContext");
|
|
11
|
+
const runtimeChatClient_1 = require("../chat/runtimeChatClient");
|
|
12
|
+
/** Local mismatch detection only. The destination service owns authorization. */
|
|
13
|
+
class LocalEvaluationSession {
|
|
14
|
+
sessionName;
|
|
15
|
+
expected;
|
|
16
|
+
environment;
|
|
17
|
+
pinnedIdentity;
|
|
18
|
+
constructor(config, sessionName, expected = {}) {
|
|
19
|
+
this.sessionName = sessionName;
|
|
20
|
+
this.expected = expected;
|
|
21
|
+
this.environment = { ...config.getActiveEnvironment() };
|
|
22
|
+
(0, session_1.accountKey)(this.environment, sessionName);
|
|
23
|
+
}
|
|
24
|
+
projectIdentity(token) {
|
|
25
|
+
const summary = (0, session_2.buildWhoamiSummary)(this.environment, token, (0, oauthClient_1.decodeJwtClaims)(token.accessToken), 'local-evaluation', this.sessionName);
|
|
26
|
+
if (!summary.subject || !summary.tenantId)
|
|
27
|
+
throw new Error('XYRA.CERTIFICATION.IDENTITY_INCOMPLETE');
|
|
28
|
+
const identity = { subject: summary.subject, subjectType: summary.subjectType, tenantId: summary.tenantId };
|
|
29
|
+
const expected = this.pinnedIdentity ?? this.expected;
|
|
30
|
+
if ((expected.subject && expected.subject !== identity.subject)
|
|
31
|
+
|| (expected.tenantId && expected.tenantId !== identity.tenantId)
|
|
32
|
+
|| (this.pinnedIdentity && this.pinnedIdentity.subjectType !== identity.subjectType)) {
|
|
33
|
+
throw new Error('XYRA.CERTIFICATION.IDENTITY_CHANGED');
|
|
34
|
+
}
|
|
35
|
+
this.pinnedIdentity ??= identity;
|
|
36
|
+
return identity;
|
|
37
|
+
}
|
|
38
|
+
async loadToken() {
|
|
39
|
+
const token = await (0, session_1.getValidToken)(this.environment, await (0, tokenStore_1.createTokenStore)(), this.sessionName);
|
|
40
|
+
this.projectIdentity(token);
|
|
41
|
+
return token;
|
|
42
|
+
}
|
|
43
|
+
async readIdentity() {
|
|
44
|
+
return this.projectIdentity(await this.loadToken());
|
|
45
|
+
}
|
|
46
|
+
async withMcpClient(writer, action) {
|
|
47
|
+
const config = { getActiveEnvironment: () => this.environment };
|
|
48
|
+
return (0, mcpContext_1.withMcpClient)(config, writer, action, {
|
|
49
|
+
sessionName: this.sessionName,
|
|
50
|
+
validateToken: token => { this.projectIdentity(token); },
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
async withRuntimeClient(action) {
|
|
54
|
+
const token = await this.loadToken();
|
|
55
|
+
return action(new runtimeChatClient_1.XyraRuntimeChatClient(this.environment, token.accessToken));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.LocalEvaluationSession = LocalEvaluationSession;
|
|
59
|
+
function createLocalEvaluationSession(sessionName, expected) {
|
|
60
|
+
return new LocalEvaluationSession(new configStore_1.ConfigStore(), sessionName, expected);
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=localSession.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localSession.js","sourceRoot":"","sources":["../../src/evaluation/localSession.ts"],"names":[],"mappings":";;;AAsEA,oEAEC;AAxED,uDAAoD;AAEpD,mDAAwE;AACxE,6CAA4D;AAC5D,qDAAsD;AACtD,iDAAyD;AACzD,uDAAuD;AAGvD,iEAAkE;AAYlE,iFAAiF;AACjF,MAAa,sBAAsB;IAIS;IACvB;IAJF,WAAW,CAAkB;IACtC,cAAc,CAA2B;IAEjD,YAAY,MAAmB,EAAW,WAAoB,EAC3C,WAA4C,EAAE;QADvB,gBAAW,GAAX,WAAW,CAAS;QAC3C,aAAQ,GAAR,QAAQ,CAAsC;QAC/D,IAAI,CAAC,WAAW,GAAG,EAAE,GAAG,MAAM,CAAC,oBAAoB,EAAE,EAAE,CAAC;QACxD,IAAA,oBAAU,EAAC,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;IAC5C,CAAC;IAEO,eAAe,CAAC,KAAkB;QACxC,MAAM,OAAO,GAAG,IAAA,4BAAkB,EAAC,IAAI,CAAC,WAAW,EAAE,KAAK,EAAE,IAAA,6BAAe,EAAC,KAAK,CAAC,WAAW,CAAC,EAAE,kBAAkB,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QACtI,IAAI,CAAC,OAAO,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ;YAAE,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;QACrG,MAAM,QAAQ,GAAG,EAAE,OAA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W;YAC7B,aAAa,EAAE,KAAK,CAAC,EAAE,GAAG,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;SACzD,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAI,MAAqD;QAC9E,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC;QACrC,OAAO,MAAM,CAAC,IAAI,yCAAqB,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC;IAChF,CAAC;CACF;AA9CD,wDA8CC;AAED,SAAgB,4BAA4B,CAAC,WAAoB,EAAE,QAA0C;IAC3G,OAAO,IAAI,sBAAsB,CAAC,IAAI,yBAAW,EAAE,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC;AAC9E,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -12,6 +12,7 @@ const env_1 = require("./commands/env");
|
|
|
12
12
|
const mcp_1 = require("./commands/mcp");
|
|
13
13
|
const tools_1 = require("./commands/tools");
|
|
14
14
|
const docs_1 = require("./commands/docs");
|
|
15
|
+
const chat_1 = require("./commands/chat");
|
|
15
16
|
const generatedCommandRegistry_1 = require("./commands/generatedCommandRegistry");
|
|
16
17
|
const version_1 = require("./version");
|
|
17
18
|
const latency_1 = require("./diagnostics/latency");
|
|
@@ -19,8 +20,8 @@ const latency_1 = require("./diagnostics/latency");
|
|
|
19
20
|
* Apply an optional `--env <name>` override before a command runs, without
|
|
20
21
|
* persisting it (transient selection for this invocation).
|
|
21
22
|
*/
|
|
22
|
-
function configFor(envOverride) {
|
|
23
|
-
return new configStore_1.ConfigStore(undefined, envOverride);
|
|
23
|
+
function configFor(envOverride, purpose, target, session) {
|
|
24
|
+
return new configStore_1.ConfigStore(undefined, envOverride, purpose, target, session);
|
|
24
25
|
}
|
|
25
26
|
/** Wrap an async command so failures render cleanly and set a non-zero exit code. */
|
|
26
27
|
function run(writer, action) {
|
|
@@ -49,6 +50,9 @@ function buildProgram(baseWriter = console_1.defaultWriter) {
|
|
|
49
50
|
.description('Xyra headless MCP command-line client (delegated OAuth).')
|
|
50
51
|
.version(version_1.CLI_VERSION, '-v, --version')
|
|
51
52
|
.option('--env <name>', 'Environment to target for this command (overrides the active one).')
|
|
53
|
+
.option('--access-purpose <purpose>', 'Select runtime or administration using its separately registered OAuth client.')
|
|
54
|
+
.option('--administration-target <json>', 'Closed global, configuration-owner or customer target for administrative discovery and execution.')
|
|
55
|
+
.option('--session <name>', 'Use an explicitly named credential for this purpose and environment.')
|
|
52
56
|
.option('--timings', 'Print local end-to-end latency phases to stderr.')
|
|
53
57
|
.option('--timings-json', 'Print local latency diagnostics as JSON to stderr.');
|
|
54
58
|
program.hook('preAction', (_thisCommand, actionCommand) => {
|
|
@@ -56,13 +60,14 @@ function buildProgram(baseWriter = console_1.defaultWriter) {
|
|
|
56
60
|
(0, latency_1.configureLatencyDiagnostics)({ timings: options.timings, timingsJson: options.timingsJson });
|
|
57
61
|
});
|
|
58
62
|
const globalEnv = () => program.opts().env;
|
|
63
|
+
const selectedConfig = () => configFor(globalEnv(), program.opts().accessPurpose, program.opts().administrationTarget, program.opts().session);
|
|
59
64
|
// ---- env ----
|
|
60
65
|
const env = program.command('env').description('Manage connection environments.');
|
|
61
66
|
env
|
|
62
67
|
.command('list')
|
|
63
68
|
.description('List available environments.')
|
|
64
69
|
.option('--json', 'Emit JSON.')
|
|
65
|
-
.action((opts) => run(writer, () => (0, env_1.runEnvList)(
|
|
70
|
+
.action((opts) => run(writer, () => (0, env_1.runEnvList)(selectedConfig(), writer, opts)));
|
|
66
71
|
env
|
|
67
72
|
.command('use <name>')
|
|
68
73
|
.description('Set the active environment.')
|
|
@@ -71,35 +76,65 @@ function buildProgram(baseWriter = console_1.defaultWriter) {
|
|
|
71
76
|
.command('show')
|
|
72
77
|
.description('Show the active environment profile.')
|
|
73
78
|
.option('--json', 'Emit JSON.')
|
|
74
|
-
.action((opts) => run(writer, () => (0, env_1.runEnvShow)(
|
|
79
|
+
.action((opts) => run(writer, () => (0, env_1.runEnvShow)(selectedConfig(), writer, opts)));
|
|
75
80
|
// ---- login / logout / whoami ----
|
|
76
81
|
program
|
|
77
82
|
.command('login')
|
|
78
83
|
.description('Sign in via delegated OAuth (Authorization Code + PKCE).')
|
|
79
84
|
.option('--no-browser', 'Print the authorization URL instead of opening a browser.')
|
|
80
85
|
.option('--no-open', 'Alias for --no-browser (az/gh convention).')
|
|
81
|
-
.
|
|
86
|
+
.option('--session <name>', 'Store this login separately for an explicitly selected identity.')
|
|
87
|
+
.action((opts) => run(writer, () => (0, login_1.runLogin)(selectedConfig(), writer, { noBrowser: !opts.browser || !opts.open, session: opts.session })));
|
|
82
88
|
program
|
|
83
89
|
.command('logout')
|
|
84
90
|
.description('Remove the stored token for the active environment.')
|
|
85
|
-
.
|
|
91
|
+
.option('--session <name>', 'Remove only this named login.')
|
|
92
|
+
.action((opts) => run(writer, () => (0, session_1.runLogout)(selectedConfig(), writer, opts)));
|
|
86
93
|
program
|
|
87
94
|
.command('whoami')
|
|
88
95
|
.description('Show the current identity, login scopes, and token status (never prints the token).')
|
|
89
96
|
.option('--json', 'Emit JSON.')
|
|
90
|
-
.
|
|
97
|
+
.option('--session <name>', 'Inspect this named login.')
|
|
98
|
+
.action((opts) => run(writer, () => (0, session_1.runWhoami)(selectedConfig(), writer, opts)));
|
|
99
|
+
// ---- chat ----
|
|
100
|
+
const chat = program.command('chat').description('Use the Xyra in-app chat runtime from the CLI.');
|
|
101
|
+
chat
|
|
102
|
+
.command('start')
|
|
103
|
+
.description('Create a new Xyra chat conversation.')
|
|
104
|
+
.option('--title <title>', 'Optional conversation title.')
|
|
105
|
+
.option('--json', 'Emit JSON.')
|
|
106
|
+
.action((opts) => run(writer, () => (0, chat_1.runChatStart)(selectedConfig(), writer, opts)));
|
|
107
|
+
chat
|
|
108
|
+
.command('send <message...>')
|
|
109
|
+
.description('Send a message through the Xyra in-app chat runtime.')
|
|
110
|
+
.option('--conversation <id>', 'Existing conversation id.')
|
|
111
|
+
.option('--new', 'Create a conversation before sending.')
|
|
112
|
+
.option('--title <title>', 'Conversation title when --new is supplied.')
|
|
113
|
+
.option('--locale <locale>', 'Runtime locale: en, fr, or zh-Hans.', 'en')
|
|
114
|
+
.option('--json', 'Emit JSON.')
|
|
115
|
+
.action((message, opts) => run(writer, () => (0, chat_1.runChatSend)(selectedConfig(), writer, message, opts)));
|
|
116
|
+
chat
|
|
117
|
+
.command('attention <action>')
|
|
118
|
+
.description('Continue, inspect, or stop a turn that is waiting.')
|
|
119
|
+
.option('--conversation <id>', 'Conversation id.')
|
|
120
|
+
.option('--request <id>', 'Original client request id.')
|
|
121
|
+
.option('--turn <id>', 'Runtime turn id.')
|
|
122
|
+
.option('--epoch <epoch>', 'Attention epoch from the waiting status.')
|
|
123
|
+
.option('--locale <locale>', 'Runtime locale: en, fr, or zh-Hans.', 'en')
|
|
124
|
+
.option('--json', 'Emit JSON.')
|
|
125
|
+
.action((action, opts) => run(writer, () => (0, chat_1.runChatAttention)(selectedConfig(), writer, action, opts)));
|
|
91
126
|
// ---- mcp ----
|
|
92
127
|
const mcp = program.command('mcp').description('Low-level MCP operations.');
|
|
93
128
|
mcp
|
|
94
129
|
.command('metadata')
|
|
95
130
|
.description('Show the public OAuth protected-resource metadata (no login required).')
|
|
96
131
|
.option('--json', 'Emit JSON.')
|
|
97
|
-
.action((opts) => run(writer, () => (0, mcp_1.runMcpMetadata)(
|
|
132
|
+
.action((opts) => run(writer, () => (0, mcp_1.runMcpMetadata)(selectedConfig(), writer, opts)));
|
|
98
133
|
mcp
|
|
99
134
|
.command('initialize')
|
|
100
135
|
.description('Perform the MCP initialize handshake.')
|
|
101
136
|
.option('--json', 'Emit JSON.')
|
|
102
|
-
.action((opts) => run(writer, () => (0, mcp_1.runMcpInitialize)(
|
|
137
|
+
.action((opts) => run(writer, () => (0, mcp_1.runMcpInitialize)(selectedConfig(), writer, opts)));
|
|
103
138
|
// ---- tools ----
|
|
104
139
|
const tools = program.command('tools').description('Discover and invoke Xyra tools.');
|
|
105
140
|
tools
|
|
@@ -109,16 +144,16 @@ function buildProgram(baseWriter = console_1.defaultWriter) {
|
|
|
109
144
|
.option('--domain <id>', 'Filter by domain id.')
|
|
110
145
|
.option('--task <key>', 'Filter by task key.')
|
|
111
146
|
.option('--limit <n>', 'Cap the number of tools returned.')
|
|
112
|
-
.action((opts) => run(writer, () => (0, tools_1.runToolsList)(
|
|
147
|
+
.action((opts) => run(writer, () => (0, tools_1.runToolsList)(selectedConfig(), writer, opts)));
|
|
113
148
|
tools
|
|
114
149
|
.command('describe <toolKey>')
|
|
115
150
|
.description('Show a tool description and input schema.')
|
|
116
151
|
.option('--json', 'Emit JSON.')
|
|
117
|
-
.action((toolKey, opts) => run(writer, () => (0, tools_1.runToolsDescribe)(
|
|
152
|
+
.action((toolKey, opts) => run(writer, () => (0, tools_1.runToolsDescribe)(selectedConfig(), writer, toolKey, opts)));
|
|
118
153
|
tools
|
|
119
154
|
.command('schema <toolKey>')
|
|
120
155
|
.description('Print the JSON input schema for a tool.')
|
|
121
|
-
.action((toolKey) => run(writer, () => (0, tools_1.runToolsSchema)(
|
|
156
|
+
.action((toolKey) => run(writer, () => (0, tools_1.runToolsSchema)(selectedConfig(), writer, toolKey)));
|
|
122
157
|
tools
|
|
123
158
|
.command('call <toolKey>')
|
|
124
159
|
.description('Invoke a tool. Provide args with repeated --arg key=value and/or --input JSON.')
|
|
@@ -129,7 +164,7 @@ function buildProgram(baseWriter = console_1.defaultWriter) {
|
|
|
129
164
|
.option('--raw', 'Emit the raw JSON-RPC envelope.')
|
|
130
165
|
.option('--yes', 'Skip the local confirmation prompt for non-read tools (server confirmations are never auto-approved).')
|
|
131
166
|
.option('--confirmation-request-id <id>', 'Resume an already approved confirmation request.')
|
|
132
|
-
.action((toolKey, opts) => run(writer, () => (0, tools_1.runToolsCall)(
|
|
167
|
+
.action((toolKey, opts) => run(writer, () => (0, tools_1.runToolsCall)(selectedConfig(), writer, toolKey, {
|
|
133
168
|
arg: opts.arg,
|
|
134
169
|
input: opts.input,
|
|
135
170
|
inputFile: opts.inputFile,
|
|
@@ -139,25 +174,25 @@ function buildProgram(baseWriter = console_1.defaultWriter) {
|
|
|
139
174
|
confirmationRequestId: opts.confirmationRequestId,
|
|
140
175
|
})));
|
|
141
176
|
const approvals = program.command('approvals').description('Inspect and decide Xyra tool confirmations.');
|
|
142
|
-
approvals.command('list').option('--json', 'Emit JSON.').option('--all', 'Include all tenant requests when authorized.').action((opts) => run(writer, () => (0, tools_1.runApprovalsList)(
|
|
143
|
-
approvals.command('show <id>').option('--json', 'Emit JSON.').action((id, opts) => run(writer, () => (0, tools_1.runApprovalDecision)(
|
|
144
|
-
approvals.command('approve <id>').option('--json', 'Emit JSON.').action((id, opts) => run(writer, () => (0, tools_1.runApprovalDecision)(
|
|
145
|
-
approvals.command('reject <id>').option('--reason <text>', 'Reason for rejection.').option('--json', 'Emit JSON.').action((id, opts) => run(writer, () => (0, tools_1.runApprovalDecision)(
|
|
146
|
-
approvals.command('cancel <id>').option('--json', 'Emit JSON.').action((id, opts) => run(writer, () => (0, tools_1.runApprovalDecision)(
|
|
177
|
+
approvals.command('list').option('--json', 'Emit JSON.').option('--all', 'Include all tenant requests when authorized.').action((opts) => run(writer, () => (0, tools_1.runApprovalsList)(selectedConfig(), writer, { json: opts.json, includeAll: opts.all })));
|
|
178
|
+
approvals.command('show <id>').option('--json', 'Emit JSON.').action((id, opts) => run(writer, () => (0, tools_1.runApprovalDecision)(selectedConfig(), writer, 'show', id, opts)));
|
|
179
|
+
approvals.command('approve <id>').option('--json', 'Emit JSON.').action((id, opts) => run(writer, () => (0, tools_1.runApprovalDecision)(selectedConfig(), writer, 'approve', id, opts)));
|
|
180
|
+
approvals.command('reject <id>').option('--reason <text>', 'Reason for rejection.').option('--json', 'Emit JSON.').action((id, opts) => run(writer, () => (0, tools_1.runApprovalDecision)(selectedConfig(), writer, 'reject', id, opts)));
|
|
181
|
+
approvals.command('cancel <id>').option('--json', 'Emit JSON.').action((id, opts) => run(writer, () => (0, tools_1.runApprovalDecision)(selectedConfig(), writer, 'cancel', id, opts)));
|
|
147
182
|
tools
|
|
148
183
|
.command('export')
|
|
149
184
|
.description('Export the visible tool catalog as agent-readable documentation.')
|
|
150
185
|
.option('--format <fmt>', "Output format: 'markdown' or 'json'.", 'markdown')
|
|
151
186
|
.option('--output <path>', 'Write to this file instead of stdout.')
|
|
152
187
|
.option('--domain <id>', 'Filter by domain id.')
|
|
153
|
-
.action((opts) => run(writer, () => (0, docs_1.runToolsExport)(
|
|
188
|
+
.action((opts) => run(writer, () => (0, docs_1.runToolsExport)(selectedConfig(), writer, { format: opts.format, output: opts.output, domain: opts.domain })));
|
|
154
189
|
// ---- docs ----
|
|
155
190
|
const docs = program.command('docs').description('Generate agent-facing documentation.');
|
|
156
191
|
docs
|
|
157
192
|
.command('generate')
|
|
158
193
|
.description('Write the markdown tool catalog to a file.')
|
|
159
194
|
.option('--output <path>', 'Destination file path.', './xyra-tools.md')
|
|
160
|
-
.action((opts) => run(writer, () => (0, docs_1.runDocsGenerate)(
|
|
195
|
+
.action((opts) => run(writer, () => (0, docs_1.runDocsGenerate)(selectedConfig(), writer, { output: opts.output })));
|
|
161
196
|
return program;
|
|
162
197
|
}
|
|
163
198
|
/* istanbul ignore next -- CLI bootstrap */
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAiDA,oCA6KC;AA7ND,yCAAoC;AACpC,8CAA+D;AAC/D,sDAAmD;AACnD,kEAAyD;AACzD,4CAA4C;AAC5C,gDAA0D;AAC1D,wCAAmE;AACnE,wCAAkE;AAClE,4CAAuI;AACvI,0CAAkE;AAClE,0CAA8E;AAC9E,kFAAiF;AACjF,uCAAwC;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,OAAO,CAAC,IAAI,EAAE,uBAAa,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;QACtF,uBAAa,CAAC,GAAG,CAAC,IAAA,+BAAW,EAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC;QAC5C,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/mcp/confirmation.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.READ_SIDE_EFFECT = void 0;
|
|
4
4
|
exports.classifyToolConfirmation = classifyToolConfirmation;
|
|
5
5
|
exports.extractServerConfirmationChallenge = extractServerConfirmationChallenge;
|
|
6
6
|
const xyraToolDescriptor_1 = require("../metadata/xyraToolDescriptor");
|
|
@@ -14,8 +14,6 @@ const xyraToolDescriptor_1 = require("../metadata/xyraToolDescriptor");
|
|
|
14
14
|
* Canonical vocabulary: libs/xyra-types/src/api-catalog.ts.
|
|
15
15
|
*/
|
|
16
16
|
exports.READ_SIDE_EFFECT = 'read';
|
|
17
|
-
/** Canonical server code raised when a tool demands server-side confirmation. */
|
|
18
|
-
exports.SERVER_CONFIRMATION_CODE = 'XYRA.OPERATION.CONFIRMATION_REQUIRED';
|
|
19
17
|
/**
|
|
20
18
|
* Decide whether the CLI must confirm locally before calling a tool.
|
|
21
19
|
* Fail safe: only a declared 'read' side effect skips confirmation; a tool
|
|
@@ -32,25 +30,24 @@ function asRecord(value) {
|
|
|
32
30
|
}
|
|
33
31
|
/**
|
|
34
32
|
* Detect a server-issued confirmation challenge in a tools/call result.
|
|
35
|
-
* Ground truth:
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* carries { code, message, details }. Detection is deliberately defensive —
|
|
39
|
-
* it matches either the canonical code or a typed confirmation object,
|
|
40
|
-
* so a challenge is still recognized if the server changes one of the two.
|
|
33
|
+
* Ground truth: the MCP V2 envelope reports status=control_required and carries
|
|
34
|
+
* a typed human-confirmation control. It is not an error and is never inferred
|
|
35
|
+
* from prose or an error code.
|
|
41
36
|
*/
|
|
42
37
|
function extractServerConfirmationChallenge(result) {
|
|
43
|
-
const
|
|
44
|
-
if (
|
|
38
|
+
const envelope = asRecord(result.structuredContent);
|
|
39
|
+
if (envelope?.schemaVersion !== 2 || envelope.status !== 'control_required')
|
|
45
40
|
return undefined;
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
41
|
+
const control = asRecord(envelope.control);
|
|
42
|
+
if (control?.type !== 'human_confirmation')
|
|
43
|
+
return undefined;
|
|
44
|
+
const confirmation = asRecord(control.challenge);
|
|
45
|
+
if (!confirmation)
|
|
50
46
|
return undefined;
|
|
51
47
|
return {
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
message: typeof confirmation.approvalPrompt === 'string'
|
|
49
|
+
? confirmation.approvalPrompt
|
|
50
|
+
: undefined,
|
|
54
51
|
confirmation,
|
|
55
52
|
};
|
|
56
53
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"confirmation.js","sourceRoot":"","sources":["../../src/mcp/confirmation.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"confirmation.js","sourceRoot":"","sources":["../../src/mcp/confirmation.ts"],"names":[],"mappings":";;;AA0BA,4DAKC;AAkBD,gFAaC;AA7DD,uEAAyE;AAEzE;;;;;;;;GAQG;AAEU,QAAA,gBAAgB,GAAG,MAAM,CAAC;AAQvC;;;;GAIG;AACH,SAAgB,wBAAwB,CAAC,IAA4B;IACnE,MAAM,UAAU,GAAG,IAAA,4CAAuB,EAAC,IAAI,CAAC,CAAC;IACjD,MAAM,UAAU,GAAG,UAAU,EAAE,UAAU,CAAC;IAC1C,MAAM,YAAY,GAAG,UAAU,EAAE,YAAY,CAAC;IAC9C,OAAO,EAAE,UAAU,EAAE,YAAY,EAA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