maka-agent 0.2.0-dev.11.20260831 → 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/LICENSE +2 -2
- package/RUNTIME_HOST_PEER_DEPENDENCIES.rust.tsv +70 -0
- package/RUNTIME_HOST_PEER_THIRD_PARTY_NOTICES.txt +1839 -140
- 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 +40 -3
- package/dist/mcp-capability-provider.js +1 -1
- package/dist/onboarding-catalog.js +3 -5
- package/dist/pi-transcript.js +21 -17
- package/dist/pi-tui-layout.js +4 -2
- package/dist/pi-tui-mcp-status.js +44 -130
- package/dist/pi-tui-pickers.js +11 -5
- package/dist/pi-tui-runner.js +133 -102
- 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 +187 -10
- package/dist/runtime-host-lifecycle-transaction.js +5 -2
- package/dist/runtime-host-managed-lifecycle-manager.js +1 -0
- package/dist/runtime-host-onboarding.js +12 -16
- package/dist/runtime-host-peer-management-command.js +16 -4
- package/dist/runtime-host-plugin-command.js +101 -0
- package/dist/runtime-host-run-command.js +8 -2
- package/dist/runtime-host-service-management-command.js +2 -1
- package/dist/runtime-host-setup-command.js +1 -0
- package/dist/runtime-host-task-readiness.js +2 -3
- package/dist/runtime-host-tui-command.js +1 -1
- package/dist/runtime-host-tui-context.js +18 -5
- package/dist/runtime-host-update-command.js +71 -35
- package/dist/runtime-host-update-discovery.js +1 -0
- package/dist/tui-clipboard.js +86 -0
- package/dist/tui-copy-catalog.js +248 -0
- package/dist/tui-copy-command.js +103 -0
- 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 +92 -1
- package/node_modules/@maka/core/dist/bounded-response.js +71 -0
- package/node_modules/@maka/core/dist/chat-model-choice.js +8 -33
- package/node_modules/@maka/core/dist/client-capability-grant.js +149 -0
- package/node_modules/@maka/core/dist/connection-error-copy.js +17 -34
- package/node_modules/@maka/core/dist/connection-readiness.js +3 -31
- package/node_modules/@maka/core/dist/deep-research.js +1 -20
- package/node_modules/@maka/core/dist/events.js +22 -14
- package/node_modules/@maka/core/dist/foreign-session.js +2 -2
- package/node_modules/@maka/core/dist/interaction.js +49 -2
- package/node_modules/@maka/core/dist/llm-connections.js +74 -82
- package/node_modules/@maka/core/dist/maka-wordmark.js +23 -0
- package/node_modules/@maka/core/dist/model-catalog.js +242 -315
- package/node_modules/@maka/core/dist/model-facts.js +13 -19
- package/node_modules/@maka/core/dist/model-metadata.generated.js +1907 -1872
- package/node_modules/@maka/core/dist/model-metadata.js +184 -199
- package/node_modules/@maka/core/dist/model-thinking.js +1 -1
- package/node_modules/@maka/core/dist/models-dev-projection.js +302 -0
- package/node_modules/@maka/core/dist/models-dev-refresh.js +55 -0
- package/node_modules/@maka/core/dist/onboarding.js +2 -1
- package/node_modules/@maka/core/dist/provider-auth.js +47 -291
- package/node_modules/@maka/core/dist/provider-registry.js +68 -357
- package/node_modules/@maka/core/dist/runtime-event.js +5 -0
- package/node_modules/@maka/core/dist/runtime-policy/connection-catalog-codec.js +83 -18
- 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 +84 -0
- package/node_modules/@maka/core/dist/runtime-policy/policy-codec.js +75 -0
- package/node_modules/@maka/core/dist/runtime-policy.js +5 -2
- package/node_modules/@maka/core/dist/session-send-projection.js +2 -1
- package/node_modules/@maka/core/dist/session-start-mode.js +42 -0
- package/node_modules/@maka/core/dist/session.js +120 -5
- package/node_modules/@maka/core/dist/settings.js +10 -2
- package/node_modules/@maka/core/dist/slash-command-catalog.js +1 -0
- package/node_modules/@maka/core/dist/task-submission-readiness.js +2 -1
- package/node_modules/@maka/core/dist/usage-record-schema.js +11 -1
- package/node_modules/@maka/core/dist/workhub-creation-intent.js +896 -0
- package/node_modules/@maka/core/package.json +8 -2
- package/node_modules/@maka/mcp/dist/index.js +1 -0
- package/node_modules/@maka/runtime/dist/agent-run.js +7 -0
- package/node_modules/@maka/runtime/dist/ai-sdk-backend.js +55 -82
- 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/image-file.js +5 -20
- package/node_modules/@maka/runtime/dist/local-web-fetch.js +2 -43
- package/node_modules/@maka/runtime/dist/mcp-tools.js +28 -0
- package/node_modules/@maka/runtime/dist/model-fetcher.js +15 -8
- package/node_modules/@maka/runtime/dist/model-history.js +59 -17
- package/node_modules/@maka/runtime/dist/model-runtime.js +2 -2
- package/node_modules/@maka/runtime/dist/plugin-composition-loader.js +173 -20
- package/node_modules/@maka/runtime/dist/plugin-runtime.js +219 -0
- package/node_modules/@maka/runtime/dist/provider-image-overflow-recovery.js +12 -31
- package/node_modules/@maka/runtime/dist/quiescent-session-snapshot.js +78 -0
- package/node_modules/@maka/runtime/dist/runtime-event-backfill.js +6 -0
- package/node_modules/@maka/runtime/dist/runtime-event-read-model.js +14 -2
- package/node_modules/@maka/runtime/dist/session-event-runtime-mapper.js +11 -10
- package/node_modules/@maka/runtime/dist/shell-tools.js +77 -1
- package/node_modules/@maka/runtime/dist/telemetry/model-pricing.generated.js +93 -83
- package/node_modules/@maka/runtime/dist/test-connection.js +6 -6
- 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 +62 -6
- package/node_modules/@maka/runtime/dist/workers/filesystem-worker.js +39 -16
- package/node_modules/@maka/runtime/package.json +1 -0
- package/node_modules/@maka/runtime-host/dist/adapter/session-projector.js +10 -3
- package/node_modules/@maka/runtime-host/dist/client/catalog-reader.js +59 -18
- package/node_modules/@maka/runtime-host/dist/client/client-capability-channel.js +3 -2
- package/node_modules/@maka/runtime-host/dist/client/connection.js +72 -31
- package/node_modules/@maka/runtime-host/dist/client/host-profile.js +49 -4
- package/node_modules/@maka/runtime-host/dist/client/index.js +3 -2
- package/node_modules/@maka/runtime-host/dist/client/oauth-presentation.js +1 -1
- 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 +26 -4
- package/node_modules/@maka/runtime-host/dist/client/reconnecting-connection.js +8 -0
- package/node_modules/@maka/runtime-host/dist/operator/access-management-frame.js +10 -1
- package/node_modules/@maka/runtime-host/dist/operator/index.js +2 -1
- package/node_modules/@maka/runtime-host/dist/operator/managed-deployment.js +2 -0
- package/node_modules/@maka/runtime-host/dist/operator/peer-management-frame.js +2 -0
- package/node_modules/@maka/runtime-host/dist/operator/service-management-frame.js +2 -0
- package/node_modules/@maka/runtime-host/dist/peer-mesh/node.js +56 -12
- package/node_modules/@maka/runtime-host/dist/peer-mesh/owner.js +4 -0
- package/node_modules/@maka/runtime-host/dist/protocol/client-capability.js +22 -1
- package/node_modules/@maka/runtime-host/dist/protocol/configuration.js +55 -9
- package/node_modules/@maka/{storage/dist/task-ledger-store-internal.js → runtime-host/dist/protocol/connection-catalog-change.js} +7 -13
- package/node_modules/@maka/runtime-host/dist/protocol/host-status.js +37 -0
- package/node_modules/@maka/runtime-host/dist/protocol/index.js +49 -1
- package/node_modules/@maka/runtime-host/dist/protocol/network-proxy.js +1 -7
- package/node_modules/@maka/runtime-host/dist/protocol/operations.js +5 -1
- package/node_modules/@maka/runtime-host/dist/protocol/plugin-platform.js +512 -0
- package/node_modules/@maka/runtime-host/dist/protocol/runtime-policy.js +72 -61
- package/node_modules/@maka/runtime-host/dist/protocol/session-catalog.js +1 -1
- package/node_modules/@maka/runtime-host/dist/protocol/session-collaboration.js +4 -2
- package/node_modules/@maka/runtime-host/dist/protocol/turn.js +5 -12
- package/node_modules/@maka/runtime-host/dist/protocol/workhub-coordination.js +92 -4
- package/node_modules/@maka/runtime-host/dist/server/access-authority.js +17 -14
- package/node_modules/@maka/runtime-host/dist/server/access-credential-metadata.js +4 -2
- package/node_modules/@maka/runtime-host/dist/server/access-credential-store.js +119 -47
- package/node_modules/@maka/runtime-host/dist/server/agent-graph-execution-coordinator.js +1 -2
- package/node_modules/@maka/runtime-host/dist/server/bootstrap-runtime-policy.js +10 -4
- package/node_modules/@maka/runtime-host/dist/server/canonical-turn-snapshot.js +0 -9
- package/node_modules/@maka/runtime-host/dist/server/client-capability-coordinator.js +192 -18
- package/node_modules/@maka/runtime-host/dist/server/client-capability-invocation-broker.js +122 -48
- package/node_modules/@maka/runtime-host/dist/server/client-capability-provider-id.js +31 -0
- package/node_modules/@maka/runtime-host/dist/server/configuration-coordinator.js +20 -1
- package/node_modules/@maka/runtime-host/dist/server/connection-effect-coordinator.js +5 -5
- package/node_modules/@maka/runtime-host/dist/server/connection-session.js +1 -0
- package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +163 -28
- package/node_modules/@maka/runtime-host/dist/server/execution-model-authority.js +2 -2
- package/node_modules/@maka/runtime-host/dist/server/execution-service.js +4 -1
- package/node_modules/@maka/runtime-host/dist/server/extension-bundle.js +249 -0
- package/node_modules/@maka/runtime-host/dist/server/extension-package-manifest.js +262 -0
- package/node_modules/@maka/runtime-host/dist/server/host-change-feed.js +11 -0
- package/node_modules/@maka/runtime-host/dist/server/host-kernel.js +15 -0
- package/node_modules/@maka/runtime-host/dist/server/index.js +5 -0
- package/node_modules/@maka/runtime-host/dist/server/interaction-coordinator.js +181 -13
- package/node_modules/@maka/runtime-host/dist/server/interaction-projection.js +6 -0
- package/node_modules/@maka/runtime-host/dist/server/listener-set.js +8 -4
- package/node_modules/@maka/runtime-host/dist/server/message-coordinator.js +88 -22
- package/node_modules/@maka/runtime-host/dist/server/model-metadata-refresh.js +96 -0
- package/node_modules/@maka/runtime-host/dist/server/network-proxy-coordinator.js +0 -1
- package/node_modules/@maka/runtime-host/dist/server/operation-dispatcher.js +43 -118
- package/node_modules/@maka/runtime-host/dist/server/peer-listener.js +3 -0
- package/node_modules/@maka/runtime-host/dist/server/plugin-composition-patch.js +58 -0
- package/node_modules/@maka/runtime-host/dist/server/plugin-composition-store.js +141 -0
- package/node_modules/@maka/runtime-host/dist/server/plugin-package-loader.js +130 -0
- package/node_modules/@maka/runtime-host/dist/server/plugin-package-store.js +528 -0
- package/node_modules/@maka/runtime-host/dist/server/plugin-platform-coordinator.js +249 -0
- package/node_modules/@maka/runtime-host/dist/server/plugin-platform.js +1130 -0
- package/node_modules/@maka/runtime-host/dist/server/root-admission-owner.js +4 -0
- package/node_modules/@maka/runtime-host/dist/server/root-turn-coordinator.js +24 -5
- package/node_modules/@maka/runtime-host/dist/server/runtime-policy-coordinator.js +57 -5
- package/node_modules/@maka/runtime-host/dist/server/session-catalog-coordinator.js +2 -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/runtime-host/dist/server/session-transcript-pager.js +10 -2
- package/node_modules/@maka/runtime-host/dist/server/web-fetch-tool.js +1 -1
- package/node_modules/@maka/runtime-host/dist/server/workhub-coordination-action-gate.js +276 -3
- package/node_modules/@maka/runtime-host/dist/server/workhub-coordination-coordinator.js +101 -1
- package/node_modules/@maka/runtime-host/dist/transport/peer-native.js +1 -0
- package/node_modules/@maka/runtime-host/dist/webrtc-stun-policy.js +114 -0
- package/node_modules/@maka/runtime-host/package.json +2 -0
- package/node_modules/@maka/storage/dist/agent-run-store.js +4 -0
- package/node_modules/@maka/storage/dist/artifact-store.js +7 -23
- package/node_modules/@maka/storage/dist/conversation-operational-state.js +3 -0
- package/node_modules/@maka/storage/dist/execution-stores.js +3 -0
- package/node_modules/@maka/storage/dist/interaction-store-public.js +1 -1
- package/node_modules/@maka/storage/dist/interaction-store.js +173 -0
- package/node_modules/@maka/storage/dist/production-session-snapshot.js +761 -0
- package/node_modules/@maka/storage/dist/quiescent-session-snapshot.js +1 -1
- package/node_modules/@maka/storage/dist/runtime-policy/connection-catalog-document.js +19 -22
- package/node_modules/@maka/storage/dist/runtime-policy/coordinator.js +205 -42
- package/node_modules/@maka/storage/dist/runtime-policy/onboarding-transaction.js +2 -2
- package/node_modules/@maka/storage/dist/runtime-policy-stores.js +5 -2
- package/node_modules/@maka/storage/dist/session-message-projection.js +1 -1
- package/node_modules/@maka/storage/dist/session-store.js +32 -6
- package/node_modules/@maka/storage/dist/session-todo-store.js +6 -68
- package/node_modules/@maka/storage/dist/settings-store.js +16 -25
- package/node_modules/@maka/storage/dist/sqlite-core-execution-schema.js +19 -0
- package/node_modules/@maka/storage/dist/sqlite-session-metadata-schema.js +10 -1
- package/node_modules/@maka/storage/dist/sqlite-session-metadata-store.js +73 -3
- package/node_modules/@maka/storage/dist/sqlite-workflow-schema.js +2 -10
- package/node_modules/@maka/storage/package.json +2 -0
- 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
- package/node_modules/@maka/core/dist/task-ledger.js +0 -669
- package/node_modules/@maka/storage/dist/task-ledger-authority.js +0 -121
- package/node_modules/@maka/storage/dist/task-ledger-store.js +0 -663
|
@@ -457,7 +457,7 @@ function decodeWorkspaceEntry(entry) {
|
|
|
457
457
|
}
|
|
458
458
|
const bundlePath = `workspace/${entry.relativePath}${entry.kind === 'directory' ? '/' : ''}`;
|
|
459
459
|
if (!isSessionBundleUstarPathV1(bundlePath)) {
|
|
460
|
-
return { kind: 'reject', category: '
|
|
460
|
+
return { kind: 'reject', category: 'unsupported_portable_path' };
|
|
461
461
|
}
|
|
462
462
|
return { kind: 'valid', segments, basename: segments.at(-1) };
|
|
463
463
|
}
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
import { randomUUID } from 'node:crypto';
|
|
20
20
|
import { isDeepStrictEqual } from 'node:util';
|
|
21
21
|
import { CONNECTION_CATALOG_MAX_CONNECTIONS, decodeCanonicalConnectionCatalogEntry, decodeConnectionSlug, decodeConnectionTarget, decodeConnectionTestSummary, decodeProviderType, decodeRuntimePolicyEntityId, normalizeConnectionCatalogEntryUpdateForProvider, normalizeConnectionModelDiscoveryResult, normalizeCreateCatalogConnectionInput, normalizeRemoveCatalogConnectionInput, normalizeSetDefaultConnectionTargetInput, normalizeUpdateCatalogConnectionInput, } from '@maka/core/runtime-policy';
|
|
22
|
-
import {
|
|
22
|
+
import { PROVIDER_REGISTRY, reconcileConnectionAfterModelFetch } from '@maka/core/llm-connections';
|
|
23
23
|
import { modelIdAliasesForProvider } from '@maka/core/model-metadata';
|
|
24
24
|
import { isRetiredProvider } from '@maka/core/provider-registry';
|
|
25
25
|
import { pruneRelayModelProfiles } from '@maka/core/model-thinking';
|
|
@@ -111,17 +111,19 @@ export class ConnectionCatalogDocumentOwner {
|
|
|
111
111
|
if (current.connections.length >= CONNECTION_CATALOG_MAX_CONNECTIONS) {
|
|
112
112
|
throw codecError('invalid_connection_input', `Connection catalog cannot exceed ${CONNECTION_CATALOG_MAX_CONNECTIONS} entries`);
|
|
113
113
|
}
|
|
114
|
-
const fallbackModels = fallbackInventory(input.connection.providerType);
|
|
115
114
|
const next = this.nextDocument(current, [
|
|
116
115
|
...current.connections,
|
|
117
116
|
{
|
|
118
117
|
...input.connection,
|
|
119
118
|
connectionId: randomUUID(),
|
|
120
119
|
revision: 1,
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
120
|
+
// A provider with no model-list endpoint ships its inventory in the
|
|
121
|
+
// registry, and the resolver prepends it to whatever the connection
|
|
122
|
+
// stores. Copying it in here as well persisted a build-time constant
|
|
123
|
+
// as if it were connection state: a second authority for the same
|
|
124
|
+
// fact, frozen at the moment the row was written, that a build
|
|
125
|
+
// shipping a new model could no longer correct.
|
|
126
|
+
models: [],
|
|
125
127
|
},
|
|
126
128
|
]);
|
|
127
129
|
await this.write(root, next);
|
|
@@ -246,9 +248,12 @@ export class ConnectionCatalogDocumentOwner {
|
|
|
246
248
|
if (!previous || (!isLegacySeed && !hasRetiredModels)) {
|
|
247
249
|
return committed(current);
|
|
248
250
|
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
251
|
+
// A legacy seed's stored inventory was the registry's shipped list copied
|
|
252
|
+
// in at write time. Clearing it is the migration: the resolver prepends
|
|
253
|
+
// that list from the current build, so the row stops carrying a stale
|
|
254
|
+
// second copy of it. Any other row keeps its own inventory, minus the
|
|
255
|
+
// retired ids.
|
|
256
|
+
const models = isLegacySeed ? [] : previous.models.filter((model) => !retired.has(model.id));
|
|
252
257
|
const { lastTest: _lastTest, modelSource: _modelSource, modelsFetchedAt: _modelsFetchedAt, ...retained } = previous;
|
|
253
258
|
const migratedEnabledModelIds = isLegacySeed
|
|
254
259
|
? [...input.enabledModelIds]
|
|
@@ -259,12 +264,10 @@ export class ConnectionCatalogDocumentOwner {
|
|
|
259
264
|
...retained,
|
|
260
265
|
revision: nextRevision(previous.revision),
|
|
261
266
|
enabledModelIds: migratedEnabledModelIds,
|
|
262
|
-
models
|
|
263
|
-
...(isLegacySeed
|
|
264
|
-
? {
|
|
265
|
-
: previous.modelSource
|
|
266
|
-
? {}
|
|
267
|
-
: { modelSource: previous.modelSource, modelsFetchedAt: previous.modelsFetchedAt }),
|
|
267
|
+
models,
|
|
268
|
+
...(isLegacySeed || previous.modelSource === undefined
|
|
269
|
+
? {}
|
|
270
|
+
: { modelSource: previous.modelSource, modelsFetchedAt: previous.modelsFetchedAt }),
|
|
268
271
|
...(relayModelProfiles === undefined ? {} : { relayModelProfiles }),
|
|
269
272
|
};
|
|
270
273
|
const target = current.defaultTarget;
|
|
@@ -355,7 +358,7 @@ export class ConnectionCatalogDocumentOwner {
|
|
|
355
358
|
const connectionId = decodeConnectionInput(() => decodeRuntimePolicyEntityId(rawConnectionId));
|
|
356
359
|
const slug = decodeConnectionInput(() => decodeConnectionSlug(rawSlug));
|
|
357
360
|
const providerType = decodeConnectionInput(() => decodeProviderType(rawProviderType));
|
|
358
|
-
const definition =
|
|
361
|
+
const definition = PROVIDER_REGISTRY[providerType];
|
|
359
362
|
// Identity first: the intent's connectionId names the connection being
|
|
360
363
|
// edited, whatever slug it lives under — a relay created in Desktop under
|
|
361
364
|
// a custom slug is updated in place, never duplicated at the canonical
|
|
@@ -589,12 +592,6 @@ export class ConnectionCatalogDocumentOwner {
|
|
|
589
592
|
}
|
|
590
593
|
}
|
|
591
594
|
}
|
|
592
|
-
function fallbackInventory(providerType) {
|
|
593
|
-
const provider = PROVIDER_DEFAULTS[providerType];
|
|
594
|
-
return provider.modelDiscovery.kind === 'fallback'
|
|
595
|
-
? provider.fallbackModels.map((id) => ({ id }))
|
|
596
|
-
: [];
|
|
597
|
-
}
|
|
598
595
|
export function catalogSnapshot(document) {
|
|
599
596
|
return deepFreeze({
|
|
600
597
|
revision: document.revision,
|
|
@@ -17,16 +17,17 @@
|
|
|
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';
|
|
24
|
-
import { deriveConnectionSlug, deriveInteractiveOAuthConnectionSlug, effectiveBaseUrl,
|
|
25
|
+
import { deriveConnectionSlug, deriveInteractiveOAuthConnectionSlug, effectiveBaseUrl, PROVIDER_REGISTRY, providerFallbackModelIds, providerAuthRequiresSecret, providerAuthSupportsApiKey, } from '@maka/core/llm-connections';
|
|
25
26
|
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,8 +221,19 @@ 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
|
-
const required = connectionCredentialLocator(connection.connectionId,
|
|
236
|
+
const required = connectionCredentialLocator(connection.connectionId, PROVIDER_REGISTRY[connection.providerType].authKind);
|
|
169
237
|
if (locator.kind !== 'request_headers' && (!required || required.kind !== locator.kind)) {
|
|
170
238
|
throw codecError('invalid_credential_input', 'Connection credential kind does not match the provider auth contract');
|
|
171
239
|
}
|
|
@@ -212,7 +280,7 @@ export class RuntimePolicyCoordinator {
|
|
|
212
280
|
// reaches it today (execution resolution refuses first), which is
|
|
213
281
|
// exactly why it would have stayed open.
|
|
214
282
|
assertConnectionIsWritable(connection);
|
|
215
|
-
if (
|
|
283
|
+
if (PROVIDER_REGISTRY[connection.providerType].authKind !== 'oauth_token') {
|
|
216
284
|
throw codecError('invalid_credential_input', 'OAuth refresh credential does not match the provider auth contract');
|
|
217
285
|
}
|
|
218
286
|
const prepared = this.vault.prepareSet(await this.vault.read(root), input);
|
|
@@ -255,32 +323,21 @@ export class RuntimePolicyCoordinator {
|
|
|
255
323
|
if (!existing)
|
|
256
324
|
return deepFreeze({ kind: 'connection_not_found' });
|
|
257
325
|
if (!isInteractiveOAuthLoginProvider(existing.providerType)) {
|
|
258
|
-
return deepFreeze({
|
|
259
|
-
kind: 'provider_action_unavailable',
|
|
260
|
-
availability: 'hidden',
|
|
261
|
-
});
|
|
326
|
+
return deepFreeze({ kind: 'provider_action_unavailable' });
|
|
262
327
|
}
|
|
263
328
|
connectionBefore = structuredClone(existing);
|
|
264
329
|
connectionAfter = reenabledInteractiveOAuthConnection(existing);
|
|
265
330
|
}
|
|
266
331
|
const connection = connectionBefore ?? connectionAfter;
|
|
267
332
|
if (!isInteractiveOAuthLoginProvider(connection.providerType)) {
|
|
268
|
-
return deepFreeze({
|
|
269
|
-
kind: 'provider_action_unavailable',
|
|
270
|
-
availability: 'hidden',
|
|
271
|
-
});
|
|
333
|
+
return deepFreeze({ kind: 'provider_action_unavailable' });
|
|
272
334
|
}
|
|
273
335
|
const contract = deriveProviderAuthContract({
|
|
274
336
|
providerType: connection.providerType,
|
|
275
|
-
enabled: true,
|
|
276
337
|
hasSecret: false,
|
|
277
|
-
lastTestStatus: connection.lastTest?.status,
|
|
278
338
|
});
|
|
279
|
-
if (contract.actionAvailability.start_oauth
|
|
280
|
-
return deepFreeze({
|
|
281
|
-
kind: 'provider_action_unavailable',
|
|
282
|
-
availability: contract.actionAvailability.start_oauth,
|
|
283
|
-
});
|
|
339
|
+
if (!contract.actionAvailability.start_oauth) {
|
|
340
|
+
return deepFreeze({ kind: 'provider_action_unavailable' });
|
|
284
341
|
}
|
|
285
342
|
const prepared = await this.prepareConnectionMaterial(root, connection, false);
|
|
286
343
|
if (prepared.kind !== 'ready')
|
|
@@ -435,13 +492,7 @@ export class RuntimePolicyCoordinator {
|
|
|
435
492
|
if (isRetiredProvider(connection.providerType)) {
|
|
436
493
|
return deepFreeze({ kind: 'provider_retired' });
|
|
437
494
|
}
|
|
438
|
-
const
|
|
439
|
-
providerType: connection.providerType,
|
|
440
|
-
enabled: true,
|
|
441
|
-
hasSecret: true,
|
|
442
|
-
lastTestStatus: connection.lastTest?.status,
|
|
443
|
-
});
|
|
444
|
-
const prepared = await this.prepareConnectionMaterial(root, connection, contract.requiresSecret);
|
|
495
|
+
const prepared = await this.prepareConnectionMaterial(root, connection, providerAuthRequiresSecret(connection.providerType));
|
|
445
496
|
if (prepared.kind !== 'ready')
|
|
446
497
|
return prepared;
|
|
447
498
|
return deepFreeze({
|
|
@@ -452,16 +503,48 @@ export class RuntimePolicyCoordinator {
|
|
|
452
503
|
});
|
|
453
504
|
});
|
|
454
505
|
}
|
|
455
|
-
exportCredentialMaterial(rawLocator) {
|
|
506
|
+
exportCredentialMaterial(rawLocator, rawExpectedConnection) {
|
|
456
507
|
return this.inLane(async (root) => {
|
|
457
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
|
+
}
|
|
458
515
|
if (locator.scope === 'connection') {
|
|
459
516
|
const catalog = await this.catalog.read(root);
|
|
460
|
-
|
|
461
|
-
|
|
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
|
+
}
|
|
462
535
|
}
|
|
463
536
|
const credential = findCredential(await this.vault.read(root), locator);
|
|
464
|
-
|
|
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;
|
|
465
548
|
});
|
|
466
549
|
}
|
|
467
550
|
getConnectionRequestHeaders(rawConnectionId) {
|
|
@@ -641,7 +724,7 @@ export class RuntimePolicyCoordinator {
|
|
|
641
724
|
});
|
|
642
725
|
});
|
|
643
726
|
}
|
|
644
|
-
|
|
727
|
+
resolveHostOutboundExecution() {
|
|
645
728
|
return this.inLane(async (root) => {
|
|
646
729
|
const policy = (await this.policy.read(root)).policy;
|
|
647
730
|
if (policy.privacy.incognitoActive) {
|
|
@@ -759,7 +842,7 @@ export class RuntimePolicyCoordinator {
|
|
|
759
842
|
let storedSecret = null;
|
|
760
843
|
let requestHeadersCredential = null;
|
|
761
844
|
let requestHeadersSecret = null;
|
|
762
|
-
const locator = connectionCredentialLocator(target.candidate.connectionId,
|
|
845
|
+
const locator = connectionCredentialLocator(target.candidate.connectionId, PROVIDER_REGISTRY[providerType].authKind);
|
|
763
846
|
if (locator) {
|
|
764
847
|
credential = credentialStatus(vault, locator);
|
|
765
848
|
if (existing) {
|
|
@@ -1000,18 +1083,15 @@ export class RuntimePolicyCoordinator {
|
|
|
1000
1083
|
return deepFreeze({ kind: 'connection_disabled' });
|
|
1001
1084
|
const contract = deriveProviderAuthContract({
|
|
1002
1085
|
providerType: connection.providerType,
|
|
1003
|
-
enabled: true,
|
|
1004
1086
|
hasSecret: true,
|
|
1005
|
-
lastTestStatus: connection.lastTest?.status,
|
|
1006
1087
|
});
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
return deepFreeze({ kind: 'provider_action_unavailable', availability });
|
|
1088
|
+
if (!contract.actionAvailability[action]) {
|
|
1089
|
+
return deepFreeze({ kind: 'provider_action_unavailable' });
|
|
1010
1090
|
}
|
|
1011
1091
|
return this.prepareConnectionMaterial(root, connection, contract.requiresSecret);
|
|
1012
1092
|
}
|
|
1013
1093
|
async prepareConnectionMaterial(root, connection, requiresConnectionSecret) {
|
|
1014
|
-
const authKind =
|
|
1094
|
+
const authKind = PROVIDER_REGISTRY[connection.providerType].authKind;
|
|
1015
1095
|
const locator = connectionCredentialLocator(connection.connectionId, authKind);
|
|
1016
1096
|
const policy = await this.policy.read(root);
|
|
1017
1097
|
const networkProxy = structuredClone(policy.policy.networkProxy);
|
|
@@ -1075,7 +1155,7 @@ export class RuntimePolicyCoordinator {
|
|
|
1075
1155
|
return false;
|
|
1076
1156
|
if (locator.kind === 'request_headers')
|
|
1077
1157
|
return true;
|
|
1078
|
-
const required = connectionCredentialLocator(connection.connectionId,
|
|
1158
|
+
const required = connectionCredentialLocator(connection.connectionId, PROVIDER_REGISTRY[connection.providerType].authKind);
|
|
1079
1159
|
if (!required || required.kind !== locator.kind) {
|
|
1080
1160
|
throw codecError('invalid_credential_input', 'Connection credential kind does not match the provider auth contract');
|
|
1081
1161
|
}
|
|
@@ -1207,6 +1287,86 @@ export class RuntimePolicyCoordinator {
|
|
|
1207
1287
|
throw commitOutcomeUnknown('Connection onboarding recovery did not converge', error);
|
|
1208
1288
|
}
|
|
1209
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
|
+
}
|
|
1210
1370
|
async applyInteractiveOAuthEnrollment(root, intent) {
|
|
1211
1371
|
const existingReceipt = findInteractiveOAuthLoginReceipt(await readInteractiveOAuthLoginReceipts(root), intent.attemptId);
|
|
1212
1372
|
const intendedIdentity = interactiveOAuthConnectionIdentity(intent.connectionAfter);
|
|
@@ -1381,6 +1541,9 @@ function hideStaleModelFactsVerification(projected, persisted, document, owner)
|
|
|
1381
1541
|
}),
|
|
1382
1542
|
};
|
|
1383
1543
|
}
|
|
1544
|
+
function matchesCredentialExpectation(actual, expected) {
|
|
1545
|
+
return expected === null ? actual === undefined : sameCredentialBasis(actual, expected);
|
|
1546
|
+
}
|
|
1384
1547
|
function isCommitOutcomeUnknown(error) {
|
|
1385
1548
|
return error instanceof RuntimePolicyStoreError && error.code === 'commit_outcome_unknown';
|
|
1386
1549
|
}
|
|
@@ -1557,7 +1720,7 @@ function normalizeInteractiveOAuthLoginInput(input) {
|
|
|
1557
1720
|
throw codecError('invalid_connection_input', 'Unknown interactive OAuth login target');
|
|
1558
1721
|
}
|
|
1559
1722
|
function newInteractiveOAuthConnection(connectionId, slug, providerType) {
|
|
1560
|
-
const defaults =
|
|
1723
|
+
const defaults = PROVIDER_REGISTRY[providerType];
|
|
1561
1724
|
return {
|
|
1562
1725
|
connectionId,
|
|
1563
1726
|
revision: 1,
|
|
@@ -1565,7 +1728,7 @@ function newInteractiveOAuthConnection(connectionId, slug, providerType) {
|
|
|
1565
1728
|
name: defaults.label,
|
|
1566
1729
|
providerType,
|
|
1567
1730
|
enabled: true,
|
|
1568
|
-
enabledModelIds:
|
|
1731
|
+
enabledModelIds: providerFallbackModelIds(defaults),
|
|
1569
1732
|
models: [],
|
|
1570
1733
|
};
|
|
1571
1734
|
}
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
import { unlink } from 'node:fs/promises';
|
|
20
20
|
import { join } from 'node:path';
|
|
21
21
|
import { decodeProviderType, decodeCanonicalConnectionCatalogEntry, decodeCredentialVersionBasis, decodeConnectionSlug, decodeRuntimePolicyEntityId, normalizeCatalogConnectionBaseUrl, normalizeConnectionCatalogEntryUpdateForProvider, normalizeConnectionModelDiscoveryResult, normalizeCredentialSecret, } from '@maka/core/runtime-policy';
|
|
22
|
-
import { deriveConnectionSlug,
|
|
22
|
+
import { deriveConnectionSlug, PROVIDER_REGISTRY, providerAuthSupportsApiKey, } from '@maka/core/llm-connections';
|
|
23
23
|
import { syncDirectory } from '../stable-storage.js';
|
|
24
24
|
import { record } from './codec.js';
|
|
25
25
|
import { codecError, commitOutcomeUnknown, decodeConnectionInput, decodeCredentialInput, decodePersistedDomain, ioFailed, } from './errors.js';
|
|
@@ -34,7 +34,7 @@ export function prepareConnectionOnboardingIntent(input, source = 'input') {
|
|
|
34
34
|
if (!providerAuthSupportsApiKey(providerType)) {
|
|
35
35
|
throw codecError(source === 'persisted' ? 'invalid_document' : 'invalid_connection_input', 'Onboarding requires an API-key provider');
|
|
36
36
|
}
|
|
37
|
-
const definition =
|
|
37
|
+
const definition = PROVIDER_REGISTRY[providerType];
|
|
38
38
|
const discovery = decode(() => normalizeConnectionModelDiscoveryResult(input.discovery));
|
|
39
39
|
// Non-empty is the requirement; `source` is write provenance, not a
|
|
40
40
|
// quality bar. A provider without a model-list endpoint runs discovery by
|
|
@@ -106,12 +106,15 @@ 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),
|
|
113
116
|
resolveWebSearchExecution: (input) => coordinator.resolveWebSearchExecution(input),
|
|
114
|
-
|
|
117
|
+
resolveHostOutboundExecution: () => coordinator.resolveHostOutboundExecution(),
|
|
115
118
|
resolveNetworkProxyExecution: (input) => coordinator.resolveNetworkProxyExecution(input),
|
|
116
119
|
compareAndSetOAuthCredential: (input) => coordinator.compareAndSetOAuthCredential(input),
|
|
117
120
|
importConnectionCredential: (input) => coordinator.importConnectionCredential(input),
|
|
@@ -58,7 +58,7 @@ export function lastMessagePreviewForMessages(messages) {
|
|
|
58
58
|
return truncatePreview(text);
|
|
59
59
|
}
|
|
60
60
|
if (message.type === 'workhub_coordination') {
|
|
61
|
-
const text = normalizePreviewText(message.userText);
|
|
61
|
+
const text = 'userText' in message ? normalizePreviewText(message.userText) : '';
|
|
62
62
|
if (text)
|
|
63
63
|
return truncatePreview(text);
|
|
64
64
|
}
|
|
@@ -178,6 +178,7 @@ class SqliteSessionStore {
|
|
|
178
178
|
assignment: request.assignment,
|
|
179
179
|
admission: request.admission,
|
|
180
180
|
projection: projectSessionCatalogMessages([request.assignment]),
|
|
181
|
+
...(request.supersession ? { supersession: request.supersession } : {}),
|
|
181
182
|
...(create
|
|
182
183
|
? {
|
|
183
184
|
create: {
|
|
@@ -195,21 +196,43 @@ class SqliteSessionStore {
|
|
|
195
196
|
return result;
|
|
196
197
|
}
|
|
197
198
|
async readWorkHubAssignment(actionId) {
|
|
199
|
+
const message = await this.readWorkHubCoordinationMessage(`wha_${workHubIdentitySuffix(actionId)}`);
|
|
200
|
+
return message?.type === 'workhub_coordination' && message.kind === 'delegation_assigned'
|
|
201
|
+
? message
|
|
202
|
+
: undefined;
|
|
203
|
+
}
|
|
204
|
+
async readWorkHubReplacement(delegationId) {
|
|
205
|
+
const message = await this.readWorkHubCoordinationMessage(`whp_${workHubIdentitySuffix(delegationId)}`);
|
|
206
|
+
return message?.type === 'workhub_coordination' &&
|
|
207
|
+
message.kind === 'delegation_replacement_requested'
|
|
208
|
+
? message
|
|
209
|
+
: undefined;
|
|
210
|
+
}
|
|
211
|
+
async readWorkHubReplacementAbort(delegationId) {
|
|
212
|
+
const message = await this.readWorkHubCoordinationMessage(`whb_${workHubIdentitySuffix(delegationId)}`);
|
|
213
|
+
return message?.type === 'workhub_coordination' &&
|
|
214
|
+
message.kind === 'delegation_replacement_aborted'
|
|
215
|
+
? message
|
|
216
|
+
: undefined;
|
|
217
|
+
}
|
|
218
|
+
async readWorkHubSupersession(delegationId) {
|
|
219
|
+
const message = await this.readWorkHubCoordinationMessage(`whx_${workHubIdentitySuffix(delegationId)}`);
|
|
220
|
+
return message?.type === 'workhub_coordination' && message.kind === 'delegation_superseded'
|
|
221
|
+
? message
|
|
222
|
+
: undefined;
|
|
223
|
+
}
|
|
224
|
+
async readWorkHubCoordinationMessage(messageId) {
|
|
198
225
|
await this.ensureReady();
|
|
199
|
-
const suffix = createHash('sha256').update(actionId, 'utf8').digest('hex').slice(0, 48);
|
|
200
226
|
const throughSequence = await this.metadata.readTranscriptHighWater(WORKHUB_COORDINATION_SESSION_ID);
|
|
201
227
|
if (throughSequence === null)
|
|
202
228
|
return undefined;
|
|
203
229
|
const messages = await this.metadata.readTranscriptMessages(WORKHUB_COORDINATION_SESSION_ID, {
|
|
204
|
-
messageIds: [
|
|
230
|
+
messageIds: [messageId],
|
|
205
231
|
throughSequence,
|
|
206
232
|
maxMessages: 1,
|
|
207
233
|
maxBytes: 768 * 1024,
|
|
208
234
|
});
|
|
209
|
-
|
|
210
|
-
return message?.type === 'workhub_coordination' && message.kind === 'delegation_assigned'
|
|
211
|
-
? message
|
|
212
|
-
: undefined;
|
|
235
|
+
return messages[0];
|
|
213
236
|
}
|
|
214
237
|
async discardStableConversationCopy(sessionId, requestFingerprint) {
|
|
215
238
|
await this.ensureReady();
|
|
@@ -570,6 +593,9 @@ class SqliteSessionStore {
|
|
|
570
593
|
await this.ensureReady();
|
|
571
594
|
}
|
|
572
595
|
}
|
|
596
|
+
function workHubIdentitySuffix(value) {
|
|
597
|
+
return createHash('sha256').update(value, 'utf8').digest('hex').slice(0, 48);
|
|
598
|
+
}
|
|
573
599
|
/**
|
|
574
600
|
* The reserved identity and the reserved role are one fact, and the invariant
|
|
575
601
|
* belongs to every creator that builds a header — subagents and Agent Graph
|