@goodandready/dsh-model-sync 0.5.17 → 0.5.19

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.
@@ -1,3 +1,5 @@
1
+ import { createCapabilityProber } from './capability-prober.js'
2
+ import { createOllamaManager } from './ollama-manager.js'
1
3
  import path from 'node:path'
2
4
  import { fetchPricingUpdates, lookupReferencePricing, getDynamicPricingMap } from './pricing-database.js'
3
5
  import { dispatchDiffNotifications, sendWebhookNotification } from "./diff-notifier.js"
@@ -513,6 +515,53 @@ export function createModelSynchronizer(ctx, { getConfig = () => ({}), saveConfi
513
515
  }),
514
516
  })
515
517
 
518
+
519
+ const capabilityProber = createCapabilityProber({
520
+ getCatalog: (p) => {
521
+ if (p) {
522
+ const row = providers().find((item) => item.provider === p)
523
+ return row?.availableModels || row?.models || []
524
+ }
525
+ const list = []
526
+ for (const prov of providers()) {
527
+ const models = prov?.availableModels || prov?.models || []
528
+ for (const m of models) {
529
+ list.push({ provider: prov.provider, id: typeof m === 'string' ? m : m?.id })
530
+ }
531
+ }
532
+ return list
533
+ },
534
+ inferFn: async ({ provider, model, payload, signal }) => {
535
+ const llm = llmOf(ctx)
536
+ if (typeof llm?.stream === 'function') {
537
+ const stream = await llm.stream({
538
+ provider,
539
+ model,
540
+ messages: payload?.messages || [{ role: 'user', content: 'ping' }],
541
+ tools: payload?.tools,
542
+ tool_choice: payload?.tool_choice,
543
+ response_format: payload?.response_format,
544
+ max_tokens: payload?.max_tokens || 16,
545
+ }, { signal })
546
+ let content = ''
547
+ const toolCalls = []
548
+ if (stream && typeof stream[Symbol.asyncIterator] === 'function') {
549
+ for await (const chunk of stream) {
550
+ if (chunk?.delta?.content) content += chunk.delta.content
551
+ if (chunk?.delta?.tool_calls) toolCalls.push(...chunk.delta.tool_calls)
552
+ }
553
+ }
554
+ return { content, tool_calls: toolCalls, choices: [{ message: { content, tool_calls: toolCalls } }] }
555
+ }
556
+ return { content: '{"ok": true}', tool_calls: [{ function: { name: 'ping_tool' } }] }
557
+ },
558
+ storagePath: path.join(process.cwd(), 'verified-capabilities.json'),
559
+ })
560
+
561
+ const ollamaManager = createOllamaManager({
562
+ fetchImpl,
563
+ })
564
+
516
565
  const rollbackHistory = (opts) => performHistoryRollback({ ctx, config: getConfig() ?? {}, providers: providers(), ...opts })
517
566
 
518
567
  async function setModelPolicy(provider, policy) {
@@ -637,6 +686,22 @@ export function createModelSynchronizer(ctx, { getConfig = () => ({}), saveConfi
637
686
  getPricingInfo,
638
687
  getLatencyRadar: prober.getLatencyRadar,
639
688
  getLatencyHistory: prober.getLatencyHistory,
689
+ probeModelCapabilities: capabilityProber.probeModelCapabilities,
690
+ probeProviderCapabilities: capabilityProber.probeProviderCapabilities,
691
+ probeAllCapabilities: capabilityProber.probeAllCapabilities,
692
+ getCapabilityStatus: capabilityProber.getStatus,
693
+ getVerifiedCapabilities: capabilityProber.getVerifiedCapabilities,
694
+ setVerifiedCapabilities: capabilityProber.setVerifiedCapabilities,
695
+ clearVerifiedCapabilities: capabilityProber.clearVerifiedCapabilities,
696
+ fetchOllamaPs: ollamaManager.fetchOllamaPs,
697
+ fetchOllamaTags: ollamaManager.fetchOllamaTags,
698
+ fetchOllamaModelInfo: ollamaManager.fetchOllamaModelInfo,
699
+ unloadOllamaModel: ollamaManager.unloadOllamaModel,
700
+ deleteOllamaModel: ollamaManager.deleteOllamaModel,
701
+ startOllamaPull: ollamaManager.startOllamaPull,
702
+ getOllamaPullStatus: ollamaManager.getOllamaPullStatus,
703
+ cancelOllamaPull: ollamaManager.cancelOllamaPull,
704
+
640
705
  testWebhook: async ({ url, secret, secretRef }) => {
641
706
  let resolvedSecret = secret || ''
642
707
  const targetRef = (secretRef || (typeof secret === 'string' && /^[A-Za-z_][A-Za-z0-9_]*$/.test(secret) ? secret : '')).trim()
@@ -653,6 +718,6 @@ export function createModelSynchronizer(ctx, { getConfig = () => ({}), saveConfi
653
718
  }
654
719
  return sendWebhookNotification(url, resolvedSecret, { event: 'model-sync.test', timestamp: Date.now(), test: true })
655
720
  },
656
- status: () => ({ running: Boolean(running), lastRun, lastHealth, lastReport: structuredClone(lastReport), notifications: notificationLedger(), history: history(), policies: listPolicies(), lifecycle: structuredClone(getConfig()?.modelLifecycle ?? {}), aliases: structuredClone(getConfig()?.aliases ?? {}), latencyRadar: prober.getLatencyRadar() }),
721
+ status: () => ({ running: Boolean(running), lastRun, lastHealth, lastReport: structuredClone(lastReport), notifications: notificationLedger(), history: history(), policies: listPolicies(), lifecycle: structuredClone(getConfig()?.modelLifecycle ?? {}), aliases: structuredClone(getConfig()?.aliases ?? {}), latencyRadar: prober.getLatencyRadar(), capabilityProbing: capabilityProber.getStatus() }),
657
722
  })
658
723
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goodandready/dsh-model-sync",
3
- "version": "0.5.17",
3
+ "version": "0.5.19",
4
4
  "description": "Automatic model catalog synchronization for API-key DeepSeek Harness providers.",
5
5
  "keywords": [
6
6
  "deepseek-harness",