maka-agent 0.2.0-dev.12.20260901 → 0.2.0-dev.14.20260902
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/THIRD_PARTY_NOTICES.txt +2 -2
- package/dist/acp/maka-acp-agent.js +6 -3
- package/dist/acp/session-registry.js +307 -0
- package/dist/acp/stdio-server.js +20 -1
- package/dist/cli-core.js +15 -2
- package/dist/pi-transcript.js +1 -1
- package/dist/pi-tui-layout.js +1 -1
- package/dist/pi-tui-mcp-status.js +1 -1
- package/dist/pi-tui-runner.js +1 -1
- package/dist/runtime-host-access-command.js +37 -4
- package/dist/runtime-host-capability-provider-command.js +16 -2
- package/dist/runtime-host-cli-context.js +73 -3
- package/dist/runtime-host-cli.js +37 -6
- package/dist/runtime-host-run-command.js +3 -1
- package/dist/runtime-host-update-command.js +59 -31
- package/dist/tui-copy-catalog.js +4 -2
- package/native/runtime-host-peer/prebuilds/darwin-arm64/maka_runtime_host_peer.node +0 -0
- package/native/runtime-host-peer/prebuilds/linux-arm64/maka_runtime_host_peer.node +0 -0
- package/native/runtime-host-peer/prebuilds/linux-x64/maka_runtime_host_peer.node +0 -0
- package/native/runtime-host-peer/prebuilds/win32-x64/maka_runtime_host_peer.node +0 -0
- package/node_modules/@maka/core/dist/attachments.js +12 -0
- package/node_modules/@maka/core/dist/connection-error-copy.js +17 -34
- package/node_modules/@maka/core/dist/events.js +0 -13
- package/node_modules/@maka/core/dist/maka-wordmark.js +23 -0
- package/node_modules/@maka/core/dist/model-catalog.js +22 -1
- package/node_modules/@maka/core/dist/runtime-event.js +1 -0
- package/node_modules/@maka/core/dist/runtime-policy/connection-catalog-codec.js +50 -1
- package/node_modules/@maka/core/dist/runtime-policy/credential-vault-codec.js +9 -1
- package/node_modules/@maka/core/dist/runtime-policy/model-catalog-entry-codec.js +10 -1
- package/node_modules/@maka/core/dist/runtime-policy/policy-codec.js +75 -0
- package/node_modules/@maka/core/dist/runtime-policy.js +4 -2
- package/node_modules/@maka/core/dist/session.js +1 -0
- package/node_modules/@maka/core/dist/settings.js +10 -2
- package/node_modules/@maka/core/dist/usage-record-schema.js +11 -1
- package/node_modules/@maka/core/package.json +2 -1
- package/node_modules/@maka/mcp/dist/index.js +1 -0
- package/node_modules/@maka/runtime/dist/ai-sdk-backend.js +52 -80
- package/node_modules/@maka/runtime/dist/ai-sdk-compaction.js +178 -140
- package/node_modules/@maka/runtime/dist/archive-read-tool.js +26 -5
- package/node_modules/@maka/runtime/dist/builtin-tools.js +27 -2
- package/node_modules/@maka/runtime/dist/context-budget-policy.js +0 -12
- package/node_modules/@maka/runtime/dist/conversation-copy.js +66 -43
- package/node_modules/@maka/runtime/dist/durable-tool-result-projection.js +31 -0
- package/node_modules/@maka/runtime/dist/history-compact-error.js +10 -2
- package/node_modules/@maka/runtime/dist/history-compact-input-fit.js +7 -1
- package/node_modules/@maka/runtime/dist/history-compaction.js +13 -22
- package/node_modules/@maka/runtime/dist/model-history.js +41 -16
- package/node_modules/@maka/runtime/dist/provider-image-overflow-recovery.js +12 -31
- package/node_modules/@maka/runtime/dist/runtime-event-backfill.js +3 -0
- package/node_modules/@maka/runtime/dist/runtime-event-read-model.js +13 -2
- package/node_modules/@maka/runtime/dist/session-event-runtime-mapper.js +3 -6
- package/node_modules/@maka/runtime/dist/shell-tools.js +77 -1
- package/node_modules/@maka/runtime/dist/tool-availability.js +74 -5
- package/node_modules/@maka/runtime/dist/tool-result-archive-resource.js +333 -52
- package/node_modules/@maka/runtime/dist/tool-result-archive-transition.js +34 -3
- package/node_modules/@maka/runtime/dist/tool-runtime.js +12 -0
- package/node_modules/@maka/runtime-host/dist/adapter/session-projector.js +0 -3
- package/node_modules/@maka/runtime-host/dist/client/catalog-reader.js +40 -13
- package/node_modules/@maka/runtime-host/dist/client/connection.js +50 -31
- package/node_modules/@maka/runtime-host/dist/client/host-profile.js +48 -4
- package/node_modules/@maka/runtime-host/dist/client/index.js +2 -2
- package/node_modules/@maka/runtime-host/dist/client/owner-connection-code.js +32 -1
- package/node_modules/@maka/runtime-host/dist/client/peer-client.js +22 -4
- package/node_modules/@maka/runtime-host/dist/operator/access-management-frame.js +10 -1
- package/node_modules/@maka/runtime-host/dist/peer-mesh/node.js +56 -12
- package/node_modules/@maka/runtime-host/dist/peer-mesh/owner.js +3 -0
- package/node_modules/@maka/runtime-host/dist/protocol/configuration.js +55 -9
- package/node_modules/@maka/runtime-host/dist/protocol/host-status.js +37 -0
- package/node_modules/@maka/runtime-host/dist/protocol/index.js +17 -1
- package/node_modules/@maka/runtime-host/dist/protocol/network-proxy.js +1 -7
- package/node_modules/@maka/runtime-host/dist/protocol/operations.js +2 -0
- package/node_modules/@maka/runtime-host/dist/protocol/runtime-policy.js +48 -1
- package/node_modules/@maka/runtime-host/dist/protocol/session-collaboration.js +4 -2
- package/node_modules/@maka/runtime-host/dist/protocol/turn.js +2 -12
- package/node_modules/@maka/runtime-host/dist/server/access-authority.js +2 -1
- package/node_modules/@maka/runtime-host/dist/server/agent-graph-execution-coordinator.js +1 -2
- package/node_modules/@maka/runtime-host/dist/server/canonical-turn-snapshot.js +0 -9
- package/node_modules/@maka/runtime-host/dist/server/configuration-coordinator.js +20 -1
- package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +46 -24
- package/node_modules/@maka/runtime-host/dist/server/execution-service.js +4 -1
- package/node_modules/@maka/runtime-host/dist/server/host-kernel.js +15 -0
- package/node_modules/@maka/runtime-host/dist/server/listener-set.js +8 -4
- package/node_modules/@maka/runtime-host/dist/server/network-proxy-coordinator.js +0 -1
- package/node_modules/@maka/runtime-host/dist/server/peer-listener.js +3 -0
- package/node_modules/@maka/runtime-host/dist/server/runtime-policy-coordinator.js +28 -1
- package/node_modules/@maka/runtime-host/dist/server/session-retirement-coordinator.js +3 -3
- package/node_modules/@maka/runtime-host/dist/server/session-revision-coordinator.js +35 -3
- package/node_modules/@maka/runtime-host/dist/server/session-sidecar-purge.js +16 -0
- package/node_modules/@maka/storage/dist/runtime-policy/coordinator.js +189 -6
- package/node_modules/@maka/storage/dist/runtime-policy-stores.js +4 -1
- package/node_modules/@maka/storage/dist/settings-store.js +16 -25
- package/node_modules/fast-uri/index.js +215 -47
- package/node_modules/fast-uri/lib/schemes.js +9 -4
- package/node_modules/fast-uri/lib/utils.js +396 -92
- package/node_modules/fast-uri/package.json +1 -1
- package/node_modules/qs/.github/THREAT_MODEL.md +3 -3
- package/node_modules/qs/CHANGELOG.md +15 -0
- package/node_modules/qs/README.md +19 -1
- package/node_modules/qs/dist/qs.js +21 -21
- package/node_modules/qs/eslint.config.mjs +1 -1
- package/node_modules/qs/lib/parse.js +3 -4
- package/node_modules/qs/lib/stringify.js +23 -8
- package/node_modules/qs/lib/utils.js +10 -3
- package/node_modules/qs/package.json +4 -4
- package/package.json +1 -1
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
* under the License.
|
|
18
18
|
*/
|
|
19
19
|
import { randomUUID } from 'node:crypto';
|
|
20
|
-
import {
|
|
20
|
+
import { isDeepStrictEqual } from 'node:util';
|
|
21
|
+
import { CONNECTION_CATALOG_MAX_CONNECTIONS, decodeConnectionModelId, connectionCredentialTarget, decodeConnectionCredentialTarget, decodeConnectionSlug, decodeProviderType, decodeRuntimePolicyEntityId, decodeCredentialLocator, normalizeDeleteCredentialInput, normalizeRemoveCatalogConnectionInput, normalizeRequestHeaderUpdates, normalizeRequestHeaders, normalizeSetCredentialInput, parseRequestHeaders, serializeRequestHeaders, RequestCustomizationValidationError, normalizeCredentialSecret, normalizeCatalogConnectionBaseUrl, normalizeNetworkProxyUpdate, networkProxyCredentialTarget, } from '@maka/core/runtime-policy';
|
|
21
22
|
import { applyModelFactOverridesToConnection, applyModelFactOverridesToCatalogSnapshot, } from '@maka/core/model-facts';
|
|
22
23
|
import { deriveProviderAuthContract } from '@maka/core/provider-auth';
|
|
23
24
|
import { isRetiredProvider } from '@maka/core/provider-registry';
|
|
@@ -26,7 +27,7 @@ import { deepFreeze, nextRevision } from './codec.js';
|
|
|
26
27
|
import { catalogSnapshot, connectionBasis, ConnectionCatalogDocumentOwner, connectionTestModelBasis, findConnection, sameConnectionTestModelBasis, } from './connection-catalog-document.js';
|
|
27
28
|
import { credentialMaterial, credentialBasis, credentialStatus, CredentialVaultDocumentOwner, findCredential, sameCredentialBasis, vaultSnapshot, } from './credential-vault-document.js';
|
|
28
29
|
import { cleanupRuntimePolicyDocumentTemps } from './document-io.js';
|
|
29
|
-
import { codecError, commitOutcomeUnknown, decodeConnectionInput, decodeCredentialInput, RuntimePolicyStoreError, } from './errors.js';
|
|
30
|
+
import { codecError, commitOutcomeUnknown, decodeConnectionInput, decodeCredentialInput, decodePolicyInput, RuntimePolicyStoreError, } from './errors.js';
|
|
30
31
|
import { connectionCredentialLocator, connectionRequestHeadersLocator, } from './operations.js';
|
|
31
32
|
import { clearConnectionOnboardingIntent, prepareConnectionOnboardingIntent, prepareInteractiveOAuthEnrollmentIntent, readConnectionOnboardingIntent, writeConnectionOnboardingIntent, } from './onboarding-transaction.js';
|
|
32
33
|
import { findInteractiveOAuthLoginReceipt, readInteractiveOAuthLoginReceipts, sameInteractiveOAuthLoginTarget, upsertInteractiveOAuthLoginReceipt, } from './oauth-login-receipt-document.js';
|
|
@@ -100,6 +101,62 @@ export class RuntimePolicyCoordinator {
|
|
|
100
101
|
}
|
|
101
102
|
});
|
|
102
103
|
}
|
|
104
|
+
updateNetworkProxy(rawInput) {
|
|
105
|
+
return this.inLane(async (root) => {
|
|
106
|
+
const input = decodePolicyInput(() => normalizeNetworkProxyUpdate(rawInput));
|
|
107
|
+
const policy = await this.policy.read(root);
|
|
108
|
+
const preparedPolicy = this.policy.prepareMutation(policy, {
|
|
109
|
+
expectedRevision: input.expectedPolicyRevision,
|
|
110
|
+
operation: { kind: 'set_network_proxy', value: input.networkProxy },
|
|
111
|
+
});
|
|
112
|
+
if (preparedPolicy.kind !== 'ready')
|
|
113
|
+
return preparedPolicy;
|
|
114
|
+
if (input.credential.kind === 'replace' &&
|
|
115
|
+
input.credential.expectedTarget &&
|
|
116
|
+
!isDeepStrictEqual(networkProxyCredentialTarget(policy.policy.networkProxy), input.credential.expectedTarget)) {
|
|
117
|
+
return deepFreeze({
|
|
118
|
+
kind: 'proxy_target_mismatch',
|
|
119
|
+
expected: input.credential.expectedTarget,
|
|
120
|
+
actual: networkProxyCredentialTarget(policy.policy.networkProxy),
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
const vault = await this.vault.read(root);
|
|
124
|
+
const existing = findCredential(vault, networkProxyCredentialLocator());
|
|
125
|
+
if (!matchesCredentialExpectation(existing, input.expectedCredential)) {
|
|
126
|
+
return deepFreeze({
|
|
127
|
+
kind: 'credential_stale',
|
|
128
|
+
expected: input.expectedCredential,
|
|
129
|
+
actual: existing ? credentialBasis(existing) : null,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
// Preflight every document before publishing either side of the compound update.
|
|
133
|
+
if (input.credential.kind === 'replace' && existing?.secret !== input.credential.secret) {
|
|
134
|
+
const prepared = this.vault.prepareSet(vault, {
|
|
135
|
+
locator: networkProxyCredentialLocator(),
|
|
136
|
+
expected: existing
|
|
137
|
+
? { credentialId: existing.credentialId, revision: existing.revision }
|
|
138
|
+
: null,
|
|
139
|
+
secret: input.credential.secret,
|
|
140
|
+
});
|
|
141
|
+
if (prepared.kind !== 'ready') {
|
|
142
|
+
if (prepared.kind === 'credential_stale')
|
|
143
|
+
return prepared;
|
|
144
|
+
throw codecError('invalid_credential_input', 'Network proxy credential is invalid');
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
else if (input.credential.kind === 'delete' && existing) {
|
|
148
|
+
const prepared = this.vault.prepareDelete(vault, {
|
|
149
|
+
expected: credentialBasis(existing),
|
|
150
|
+
});
|
|
151
|
+
if (prepared.kind !== 'ready') {
|
|
152
|
+
if (prepared.kind === 'credential_stale')
|
|
153
|
+
return prepared;
|
|
154
|
+
throw codecError('invalid_credential_input', 'Network proxy credential is invalid');
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return this.applyNetworkProxyUpdate(root, input);
|
|
158
|
+
});
|
|
159
|
+
}
|
|
103
160
|
createConnection(input) {
|
|
104
161
|
return this.inLane(async (root) => this.projectCatalogMutation(root, await this.catalog.create(root, input)));
|
|
105
162
|
}
|
|
@@ -164,6 +221,17 @@ export class RuntimePolicyCoordinator {
|
|
|
164
221
|
if (!connection) {
|
|
165
222
|
return deepFreeze({ kind: 'connection_not_found' });
|
|
166
223
|
}
|
|
224
|
+
if (input.expectedConnection &&
|
|
225
|
+
!isDeepStrictEqual(connectionCredentialTarget(connection), input.expectedConnection)) {
|
|
226
|
+
return deepFreeze({
|
|
227
|
+
kind: 'connection_stale',
|
|
228
|
+
expected: {
|
|
229
|
+
connectionId: input.expectedConnection.connectionId,
|
|
230
|
+
revision: input.expectedConnection.revision,
|
|
231
|
+
},
|
|
232
|
+
actual: connectionBasis(connection),
|
|
233
|
+
});
|
|
234
|
+
}
|
|
167
235
|
assertConnectionIsWritable(connection);
|
|
168
236
|
const required = connectionCredentialLocator(connection.connectionId, PROVIDER_REGISTRY[connection.providerType].authKind);
|
|
169
237
|
if (locator.kind !== 'request_headers' && (!required || required.kind !== locator.kind)) {
|
|
@@ -435,16 +503,48 @@ export class RuntimePolicyCoordinator {
|
|
|
435
503
|
});
|
|
436
504
|
});
|
|
437
505
|
}
|
|
438
|
-
exportCredentialMaterial(rawLocator) {
|
|
506
|
+
exportCredentialMaterial(rawLocator, rawExpectedConnection) {
|
|
439
507
|
return this.inLane(async (root) => {
|
|
440
508
|
const locator = decodeCredentialInput(() => decodeCredentialLocator(rawLocator));
|
|
509
|
+
const expectedConnection = rawExpectedConnection
|
|
510
|
+
? decodeConnectionInput(() => decodeConnectionCredentialTarget(rawExpectedConnection))
|
|
511
|
+
: undefined;
|
|
512
|
+
if (expectedConnection && locator.scope !== 'connection') {
|
|
513
|
+
throw codecError('invalid_credential_input', 'Only connection credentials accept a connection target basis');
|
|
514
|
+
}
|
|
441
515
|
if (locator.scope === 'connection') {
|
|
442
516
|
const catalog = await this.catalog.read(root);
|
|
443
|
-
|
|
444
|
-
|
|
517
|
+
const connection = findConnection(catalog, locator);
|
|
518
|
+
if (expectedConnection &&
|
|
519
|
+
(!connection ||
|
|
520
|
+
!isDeepStrictEqual(connectionCredentialTarget(connection), expectedConnection))) {
|
|
521
|
+
return deepFreeze({
|
|
522
|
+
kind: 'connection_stale',
|
|
523
|
+
expected: {
|
|
524
|
+
connectionId: expectedConnection.connectionId,
|
|
525
|
+
revision: expectedConnection.revision,
|
|
526
|
+
},
|
|
527
|
+
actual: connection ? connectionBasis(connection) : null,
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
if (!this.validateConnectionCredentialLocator(catalog, locator)) {
|
|
531
|
+
return expectedConnection
|
|
532
|
+
? deepFreeze({ kind: 'exported', material: null })
|
|
533
|
+
: null;
|
|
534
|
+
}
|
|
445
535
|
}
|
|
446
536
|
const credential = findCredential(await this.vault.read(root), locator);
|
|
447
|
-
|
|
537
|
+
const material = credential
|
|
538
|
+
? {
|
|
539
|
+
...credentialMaterial(credential),
|
|
540
|
+
...(locator.scope === 'network_proxy'
|
|
541
|
+
? {
|
|
542
|
+
proxyTarget: networkProxyCredentialTarget((await this.policy.read(root)).policy.networkProxy),
|
|
543
|
+
}
|
|
544
|
+
: {}),
|
|
545
|
+
}
|
|
546
|
+
: null;
|
|
547
|
+
return expectedConnection ? deepFreeze({ kind: 'exported', material }) : material;
|
|
448
548
|
});
|
|
449
549
|
}
|
|
450
550
|
getConnectionRequestHeaders(rawConnectionId) {
|
|
@@ -1187,6 +1287,86 @@ export class RuntimePolicyCoordinator {
|
|
|
1187
1287
|
throw commitOutcomeUnknown('Connection onboarding recovery did not converge', error);
|
|
1188
1288
|
}
|
|
1189
1289
|
}
|
|
1290
|
+
async applyNetworkProxyUpdate(root, input) {
|
|
1291
|
+
const policy = await this.policy.read(root);
|
|
1292
|
+
const vault = await this.vault.read(root);
|
|
1293
|
+
const locator = networkProxyCredentialLocator();
|
|
1294
|
+
const existing = findCredential(vault, locator);
|
|
1295
|
+
const credentialChanged = input.credential.kind === 'replace'
|
|
1296
|
+
? existing?.secret !== input.credential.secret
|
|
1297
|
+
: input.credential.kind === 'delete' && existing !== undefined;
|
|
1298
|
+
const proxyChanged = !isDeepStrictEqual(policy.policy.networkProxy, input.networkProxy);
|
|
1299
|
+
const effectiveProxyChanged = !sameEffectiveProxyConfiguration(effectiveProxyConfigurationBasis(policy.policy.networkProxy), effectiveProxyConfigurationBasis(input.networkProxy));
|
|
1300
|
+
const cleared = credentialChanged || effectiveProxyChanged
|
|
1301
|
+
? await this.catalog.clearAllConnectionLastTests(root, await this.catalog.read(root))
|
|
1302
|
+
: false;
|
|
1303
|
+
let durableChange = cleared;
|
|
1304
|
+
let snapshot = policySnapshot(policy);
|
|
1305
|
+
try {
|
|
1306
|
+
const commitCredential = async () => {
|
|
1307
|
+
if (input.credential.kind === 'replace' && credentialChanged) {
|
|
1308
|
+
const prepared = this.vault.prepareSet(vault, {
|
|
1309
|
+
locator,
|
|
1310
|
+
expected: existing
|
|
1311
|
+
? { credentialId: existing.credentialId, revision: existing.revision }
|
|
1312
|
+
: null,
|
|
1313
|
+
secret: input.credential.secret,
|
|
1314
|
+
});
|
|
1315
|
+
if (prepared.kind !== 'ready') {
|
|
1316
|
+
throw codecError('invalid_document', 'Network proxy credential update became stale');
|
|
1317
|
+
}
|
|
1318
|
+
await this.vault.commitSet(root, prepared);
|
|
1319
|
+
durableChange = true;
|
|
1320
|
+
}
|
|
1321
|
+
else if (input.credential.kind === 'delete' && existing) {
|
|
1322
|
+
const prepared = this.vault.prepareDelete(vault, {
|
|
1323
|
+
expected: credentialBasis(existing),
|
|
1324
|
+
});
|
|
1325
|
+
if (prepared.kind !== 'ready') {
|
|
1326
|
+
throw codecError('invalid_document', 'Network proxy credential deletion became stale');
|
|
1327
|
+
}
|
|
1328
|
+
await this.vault.commitDelete(root, prepared);
|
|
1329
|
+
durableChange = true;
|
|
1330
|
+
}
|
|
1331
|
+
};
|
|
1332
|
+
const commitPolicy = async () => {
|
|
1333
|
+
if (!proxyChanged)
|
|
1334
|
+
return;
|
|
1335
|
+
const prepared = this.policy.prepareMutation(policy, {
|
|
1336
|
+
expectedRevision: policy.revision,
|
|
1337
|
+
operation: { kind: 'set_network_proxy', value: input.networkProxy },
|
|
1338
|
+
});
|
|
1339
|
+
if (prepared.kind !== 'ready') {
|
|
1340
|
+
throw codecError('invalid_document', 'Network proxy policy update became stale');
|
|
1341
|
+
}
|
|
1342
|
+
snapshot = (await this.policy.commitMutation(root, prepared)).snapshot;
|
|
1343
|
+
durableChange = true;
|
|
1344
|
+
};
|
|
1345
|
+
// Never leave an enabled policy pointing at an absent credential: publish a
|
|
1346
|
+
// replacement before enabling its use, and retire credential use before deletion.
|
|
1347
|
+
if (input.credential.kind === 'delete' &&
|
|
1348
|
+
!requiresNetworkProxyCredential(input.networkProxy)) {
|
|
1349
|
+
await commitPolicy();
|
|
1350
|
+
await commitCredential();
|
|
1351
|
+
}
|
|
1352
|
+
else {
|
|
1353
|
+
await commitCredential();
|
|
1354
|
+
await commitPolicy();
|
|
1355
|
+
}
|
|
1356
|
+
}
|
|
1357
|
+
catch (error) {
|
|
1358
|
+
if (durableChange && !isCommitOutcomeUnknown(error)) {
|
|
1359
|
+
throw commitOutcomeUnknown('Network proxy update committed only some effects', error);
|
|
1360
|
+
}
|
|
1361
|
+
throw error;
|
|
1362
|
+
}
|
|
1363
|
+
const finalVault = await this.vault.read(root);
|
|
1364
|
+
return deepFreeze({
|
|
1365
|
+
kind: 'committed',
|
|
1366
|
+
snapshot,
|
|
1367
|
+
credentialStatus: credentialStatus(finalVault, locator),
|
|
1368
|
+
});
|
|
1369
|
+
}
|
|
1190
1370
|
async applyInteractiveOAuthEnrollment(root, intent) {
|
|
1191
1371
|
const existingReceipt = findInteractiveOAuthLoginReceipt(await readInteractiveOAuthLoginReceipts(root), intent.attemptId);
|
|
1192
1372
|
const intendedIdentity = interactiveOAuthConnectionIdentity(intent.connectionAfter);
|
|
@@ -1361,6 +1541,9 @@ function hideStaleModelFactsVerification(projected, persisted, document, owner)
|
|
|
1361
1541
|
}),
|
|
1362
1542
|
};
|
|
1363
1543
|
}
|
|
1544
|
+
function matchesCredentialExpectation(actual, expected) {
|
|
1545
|
+
return expected === null ? actual === undefined : sameCredentialBasis(actual, expected);
|
|
1546
|
+
}
|
|
1364
1547
|
function isCommitOutcomeUnknown(error) {
|
|
1365
1548
|
return error instanceof RuntimePolicyStoreError && error.code === 'commit_outcome_unknown';
|
|
1366
1549
|
}
|
|
@@ -106,7 +106,10 @@ function createWriterFacade(coordinator) {
|
|
|
106
106
|
delete: (input) => coordinator.deleteCredential(input),
|
|
107
107
|
},
|
|
108
108
|
operations: {
|
|
109
|
-
|
|
109
|
+
updateNetworkProxy: (input) => coordinator.updateNetworkProxy(input),
|
|
110
|
+
exportCredentialMaterial: ((locator, expectedConnection) => expectedConnection
|
|
111
|
+
? coordinator.exportCredentialMaterial(locator, expectedConnection)
|
|
112
|
+
: coordinator.exportCredentialMaterial(locator)),
|
|
110
113
|
getConnectionRequestHeaders: (connectionId) => coordinator.getConnectionRequestHeaders(connectionId),
|
|
111
114
|
replaceConnectionRequestHeaders: (connectionId, updates) => coordinator.replaceConnectionRequestHeaders(connectionId, updates),
|
|
112
115
|
resolveExecutionConnection: (ref) => coordinator.resolveExecutionConnection(ref),
|
|
@@ -24,11 +24,9 @@ export function createSettingsStore(workspaceRoot) {
|
|
|
24
24
|
return new FileSettingsStore(workspaceRoot);
|
|
25
25
|
}
|
|
26
26
|
class FileSettingsStore {
|
|
27
|
-
workspaceRoot;
|
|
28
27
|
settingsPath;
|
|
29
28
|
queue = Promise.resolve();
|
|
30
29
|
constructor(workspaceRoot) {
|
|
31
|
-
this.workspaceRoot = workspaceRoot;
|
|
32
30
|
this.settingsPath = join(workspaceRoot, 'settings.json');
|
|
33
31
|
}
|
|
34
32
|
async get() {
|
|
@@ -43,7 +41,12 @@ class FileSettingsStore {
|
|
|
43
41
|
async readOrCreate() {
|
|
44
42
|
try {
|
|
45
43
|
const text = await readFile(this.settingsPath, 'utf8');
|
|
46
|
-
|
|
44
|
+
const persisted = JSON.parse(text);
|
|
45
|
+
const settings = normalizeSettings(persisted);
|
|
46
|
+
if (hasLegacyProxyCredentialFields(persisted)) {
|
|
47
|
+
await this.write(settings);
|
|
48
|
+
}
|
|
49
|
+
return settings;
|
|
47
50
|
}
|
|
48
51
|
catch (error) {
|
|
49
52
|
if (error.code !== 'ENOENT')
|
|
@@ -129,28 +132,6 @@ class FileSettingsStore {
|
|
|
129
132
|
throw new Error('Failed to clear onboarding milestone');
|
|
130
133
|
return result;
|
|
131
134
|
}
|
|
132
|
-
async testNetworkProxy() {
|
|
133
|
-
const started = Date.now();
|
|
134
|
-
const settings = await this.get();
|
|
135
|
-
const proxy = settings.network.proxy;
|
|
136
|
-
if (!proxy.enabled) {
|
|
137
|
-
return { ok: true, message: '代理未启用,当前会直接连接。', latencyMs: Date.now() - started };
|
|
138
|
-
}
|
|
139
|
-
if (!proxy.host.trim())
|
|
140
|
-
return { ok: false, message: '代理服务器地址不能为空' };
|
|
141
|
-
if (!Number.isInteger(proxy.port) || proxy.port <= 0 || proxy.port > 65535) {
|
|
142
|
-
return { ok: false, message: '代理端口必须在 1-65535 之间' };
|
|
143
|
-
}
|
|
144
|
-
if (proxy.authEnabled && (!proxy.username.trim() || !proxy.password)) {
|
|
145
|
-
return { ok: false, message: '启用代理认证后需要用户名和密码' };
|
|
146
|
-
}
|
|
147
|
-
return {
|
|
148
|
-
ok: true,
|
|
149
|
-
message: `代理配置有效:${proxy.protocol}://${proxy.host}:${proxy.port}`,
|
|
150
|
-
latencyMs: Date.now() - started,
|
|
151
|
-
details: { bypassList: proxy.bypassList, autoBypassDomains: proxy.autoBypassDomains },
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
135
|
async write(settings) {
|
|
155
136
|
await mkdir(dirname(this.settingsPath), { recursive: true });
|
|
156
137
|
const tempPath = `${this.settingsPath}.${process.pid}.${Date.now()}.tmp`;
|
|
@@ -163,3 +144,13 @@ class FileSettingsStore {
|
|
|
163
144
|
return next;
|
|
164
145
|
}
|
|
165
146
|
}
|
|
147
|
+
function hasLegacyProxyCredentialFields(value) {
|
|
148
|
+
if (!isRecord(value) || !isRecord(value.network) || !isRecord(value.network.proxy)) {
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
const proxy = value.network.proxy;
|
|
152
|
+
return ['password', 'passwordConfigured', 'credential'].some((key) => Object.prototype.hasOwnProperty.call(proxy, key));
|
|
153
|
+
}
|
|
154
|
+
function isRecord(value) {
|
|
155
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
156
|
+
}
|