forkit-connect 0.1.32 → 0.1.34

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.
@@ -137,9 +137,25 @@ function listBoundBindings(state) {
137
137
  if (!Array.isArray(state.model_bindings)) {
138
138
  return [];
139
139
  }
140
+ const detectedModelKeys = new Set(state.detected_models.map((item) => `${item.model}#${item.digest}`));
141
+ const scoreBinding = (binding) => {
142
+ let score = 0;
143
+ if (detectedModelKeys.has(binding.modelKey))
144
+ score += 4;
145
+ if (binding.runtimeGaid)
146
+ score += 2;
147
+ if (binding.runtimeSignalKeyPresent)
148
+ score += 1;
149
+ return score;
150
+ };
140
151
  return state.model_bindings
141
152
  .filter((item) => item.status === 'bound' && typeof item.gaid === 'string' && item.gaid.trim())
142
- .sort((left, right) => String(right.updatedAt || '').localeCompare(String(left.updatedAt || '')))
153
+ .sort((left, right) => {
154
+ const scoreDelta = scoreBinding(right) - scoreBinding(left);
155
+ if (scoreDelta !== 0)
156
+ return scoreDelta;
157
+ return String(right.updatedAt || '').localeCompare(String(left.updatedAt || ''));
158
+ })
143
159
  .map((binding) => ({
144
160
  binding,
145
161
  detectedModel: state.detected_models.find((item) => `${item.model}#${item.digest}` === binding.modelKey),
@@ -2833,7 +2833,26 @@ class ConnectV1Service {
2833
2833
  };
2834
2834
  }
2835
2835
  getPrimaryBoundBinding(state) {
2836
- return state.model_bindings.find((binding) => binding.status === 'bound' && typeof binding.gaid === 'string' && binding.gaid.trim());
2836
+ const detectedModelKeys = new Set(state.detected_models.map((item) => `${item.model}#${item.digest}`));
2837
+ const scoreBinding = (binding) => {
2838
+ let score = 0;
2839
+ if (detectedModelKeys.has(binding.modelKey))
2840
+ score += 4;
2841
+ if (binding.runtimeGaid)
2842
+ score += 2;
2843
+ if (binding.runtimeSignalKeyPresent)
2844
+ score += 1;
2845
+ return score;
2846
+ };
2847
+ return state.model_bindings
2848
+ .filter((binding) => binding.status === 'bound' && typeof binding.gaid === 'string' && binding.gaid.trim())
2849
+ .sort((left, right) => {
2850
+ const scoreDelta = scoreBinding(right) - scoreBinding(left);
2851
+ if (scoreDelta !== 0)
2852
+ return scoreDelta;
2853
+ return String(right.updatedAt || '').localeCompare(String(left.updatedAt || ''));
2854
+ })
2855
+ .at(0);
2837
2856
  }
2838
2857
  setRuntimeSignalApiKeyForGaid(gaid, apiKey) {
2839
2858
  if (!gaid || !apiKey)
@@ -3241,7 +3260,8 @@ class ConnectV1Service {
3241
3260
  const { workspaceId, projectId } = this.resolveRuntimeRunScope(state, gaid);
3242
3261
  const runtimeMetadata = isRecord(input.metadata) ? input.metadata : {};
3243
3262
  const steps = Array.isArray(input.steps) ? input.steps.filter((step) => isRecord(step)) : [];
3244
- return this.getApiClient(state).pushRuntimeRunLog({
3263
+ const client = this.getApiClientWithSessionToken(apiKey);
3264
+ return client.pushRuntimeRunLog({
3245
3265
  gaid,
3246
3266
  apiKey,
3247
3267
  schemaVersion: 'runtime.run.v1',
@@ -7112,7 +7132,7 @@ class ConnectV1Service {
7112
7132
  return;
7113
7133
  }
7114
7134
  try {
7115
- const result = await this.getApiClient(currentState).pushRuntimeSignalEvent(this.buildC2RuntimeSignalPayload(event, apiKey, runtimeScope));
7135
+ const result = await this.getApiClientWithSessionToken(apiKey).pushRuntimeSignalEvent(this.buildC2RuntimeSignalPayload(event, apiKey, runtimeScope));
7116
7136
  if (!result.ok) {
7117
7137
  // 429 rate-limit — halt the current flush cycle and respect Retry-After.
7118
7138
  if (result.status === 429) {
@@ -8832,7 +8852,7 @@ class ConnectV1Service {
8832
8852
  ...item.payload,
8833
8853
  apiKey: resolvedRuntimeSignalApiKey,
8834
8854
  };
8835
- const result = await api.pushRuntimeSignalEvent(this.withRuntimeBindingPayload(payloadWithRuntimeKey, runtimeScope));
8855
+ const result = await this.getApiClientWithSessionToken(resolvedRuntimeSignalApiKey).pushRuntimeSignalEvent(this.withRuntimeBindingPayload(payloadWithRuntimeKey, runtimeScope));
8836
8856
  if (!result.ok) {
8837
8857
  const metadataValue = item.payload?.metadata;
8838
8858
  const metadata = metadataValue && typeof metadataValue === 'object' && !Array.isArray(metadataValue)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "forkit-connect",
3
- "version": "0.1.32",
3
+ "version": "0.1.34",
4
4
  "description": "Forkit Connect Local Engine - The Global AI Governance Fabric",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",