modelrig 0.11.0 → 0.12.0
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/CHANGELOG.md +82 -0
- package/dist/adapters/anthropic.d.ts +4 -4
- package/dist/adapters/anthropic.d.ts.map +1 -1
- package/dist/adapters/anthropic.js +8 -1
- package/dist/adapters/deepseek.d.ts +2 -4
- package/dist/adapters/deepseek.d.ts.map +1 -1
- package/dist/adapters/deepseek.js +9 -5
- package/dist/adapters/gemini.d.ts +4 -1
- package/dist/adapters/gemini.d.ts.map +1 -1
- package/dist/adapters/gemini.js +16 -1
- package/dist/adapters/grok.d.ts +2 -4
- package/dist/adapters/grok.d.ts.map +1 -1
- package/dist/adapters/grok.js +8 -4
- package/dist/adapters/history-mapping.d.ts +126 -0
- package/dist/adapters/history-mapping.d.ts.map +1 -0
- package/dist/adapters/history-mapping.js +230 -0
- package/dist/adapters/openai-compat.d.ts +2 -4
- package/dist/adapters/openai-compat.d.ts.map +1 -1
- package/dist/adapters/openai-compat.js +9 -5
- package/dist/adapters/openai.d.ts +2 -4
- package/dist/adapters/openai.d.ts.map +1 -1
- package/dist/adapters/openai.js +8 -4
- package/dist/adapters/responses-api.d.ts.map +1 -1
- package/dist/adapters/responses-api.js +9 -4
- package/dist/artifacts/artifact.d.ts.map +1 -1
- package/dist/artifacts/artifact.js +79 -0
- package/dist/artifacts/conversation.d.ts +128 -0
- package/dist/artifacts/conversation.d.ts.map +1 -0
- package/dist/artifacts/conversation.js +172 -0
- package/dist/artifacts/index.d.ts +1 -1
- package/dist/artifacts/index.d.ts.map +1 -1
- package/dist/artifacts/media.d.ts +46 -0
- package/dist/artifacts/media.d.ts.map +1 -0
- package/dist/artifacts/media.js +88 -0
- package/dist/artifacts/run-context.d.ts +61 -2
- package/dist/artifacts/run-context.d.ts.map +1 -1
- package/dist/artifacts/run-context.js +183 -12
- package/dist/artifacts/scrub.d.ts +3 -0
- package/dist/artifacts/scrub.d.ts.map +1 -1
- package/dist/bakeoff/engine.d.ts.map +1 -1
- package/dist/bakeoff/engine.js +34 -7
- package/dist/bakeoff/eval-cases.d.ts +5 -0
- package/dist/bakeoff/eval-cases.d.ts.map +1 -1
- package/dist/bakeoff/eval-cases.js +10 -1
- package/dist/bakeoff/replay.d.ts +15 -0
- package/dist/bakeoff/replay.d.ts.map +1 -1
- package/dist/bakeoff/replay.js +19 -1
- package/dist/bakeoff/report.d.ts.map +1 -1
- package/dist/bakeoff/report.js +9 -2
- package/dist/bakeoff/turn-replay.d.ts +93 -0
- package/dist/bakeoff/turn-replay.d.ts.map +1 -0
- package/dist/bakeoff/turn-replay.js +150 -0
- package/dist/bakeoff/types.d.ts +12 -0
- package/dist/bakeoff/types.d.ts.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +1 -0
- package/dist/config.d.ts +18 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +23 -3
- package/dist/doctor-preflight.d.ts.map +1 -1
- package/dist/doctor-preflight.js +6 -1
- package/dist/feedback/grade.d.ts +7 -2
- package/dist/feedback/grade.d.ts.map +1 -1
- package/dist/feedback/grade.js +14 -0
- package/dist/feedback/outcome.d.ts +103 -0
- package/dist/feedback/outcome.d.ts.map +1 -0
- package/dist/feedback/outcome.js +175 -0
- package/dist/gateway/history-bridge.d.ts +32 -0
- package/dist/gateway/history-bridge.d.ts.map +1 -0
- package/dist/gateway/history-bridge.js +64 -0
- package/dist/gateway/serve-client.d.ts.map +1 -1
- package/dist/gateway/serve-client.js +6 -0
- package/dist/index.d.ts +44 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +110 -9
- package/dist/init/init-cli.d.ts.map +1 -1
- package/dist/init/init-cli.js +21 -4
- package/dist/init/observe-cli.js +1 -1
- package/dist/init/observe.d.ts +7 -1
- package/dist/init/observe.d.ts.map +1 -1
- package/dist/init/observe.js +74 -22
- package/dist/init/starter.d.ts +36 -0
- package/dist/init/starter.d.ts.map +1 -0
- package/dist/init/starter.js +85 -0
- package/dist/registry/build.d.ts +4 -0
- package/dist/registry/build.d.ts.map +1 -1
- package/dist/registry/generation-models.d.ts +68 -0
- package/dist/registry/generation-models.d.ts.map +1 -0
- package/dist/registry/generation-models.js +168 -0
- package/dist/registry/model-kind.d.ts +34 -0
- package/dist/registry/model-kind.d.ts.map +1 -0
- package/dist/registry/model-kind.js +40 -0
- package/dist/registry/pricing-shape.d.ts +29 -1
- package/dist/registry/pricing-shape.d.ts.map +1 -1
- package/dist/registry/pricing-shape.js +9 -0
- package/dist/registry/pricing.d.ts +26 -0
- package/dist/registry/pricing.d.ts.map +1 -1
- package/dist/registry/pricing.js +29 -0
- package/dist/registry/rows.d.ts.map +1 -1
- package/dist/registry/rows.js +3 -1
- package/dist/registry/unit-pricing.d.ts +32 -0
- package/dist/registry/unit-pricing.d.ts.map +1 -0
- package/dist/registry/unit-pricing.js +62 -0
- package/dist/routes/input-loader.d.ts +38 -0
- package/dist/routes/input-loader.d.ts.map +1 -0
- package/dist/routes/input-loader.js +80 -0
- package/dist/routes/loader.d.ts.map +1 -1
- package/dist/routes/loader.js +3 -0
- package/dist/routes/resolved-bundle.d.ts +2 -0
- package/dist/routes/resolved-bundle.d.ts.map +1 -1
- package/dist/routes/resolved-bundle.js +3 -0
- package/dist/run/cost.d.ts +28 -0
- package/dist/run/cost.d.ts.map +1 -1
- package/dist/run/cost.js +74 -0
- package/dist/run/dispatch.d.ts +4 -1
- package/dist/run/dispatch.d.ts.map +1 -1
- package/dist/run/dispatch.js +3 -0
- package/dist/run/limits.d.ts +88 -0
- package/dist/run/limits.d.ts.map +1 -0
- package/dist/run/limits.js +155 -0
- package/dist/run/messages.d.ts +199 -0
- package/dist/run/messages.d.ts.map +1 -0
- package/dist/run/messages.js +430 -0
- package/dist/run/raw-finalize.d.ts +5 -2
- package/dist/run/raw-finalize.d.ts.map +1 -1
- package/dist/run/raw-finalize.js +8 -5
- package/dist/run/raw-request.d.ts.map +1 -1
- package/dist/run/raw-request.js +2 -1
- package/dist/run/raw.d.ts +10 -4
- package/dist/run/raw.d.ts.map +1 -1
- package/dist/run/raw.js +11 -3
- package/dist/run/rawonly.d.ts +29 -5
- package/dist/run/rawonly.d.ts.map +1 -1
- package/dist/run/rawonly.js +54 -19
- package/dist/run/record-attempt.d.ts.map +1 -1
- package/dist/run/record-attempt.js +16 -6
- package/dist/run/record-call.d.ts +13 -2
- package/dist/run/record-call.d.ts.map +1 -1
- package/dist/run/record-call.js +50 -7
- package/dist/run/run.d.ts.map +1 -1
- package/dist/run/run.js +12 -8
- package/dist/telemetry/attempt-meta.d.ts +49 -1
- package/dist/telemetry/attempt-meta.d.ts.map +1 -1
- package/dist/telemetry/attempt-meta.js +45 -1
- package/dist/telemetry/exporter.d.ts.map +1 -1
- package/dist/telemetry/exporter.js +2 -1
- package/dist/telemetry/grade-mappers.d.ts +1 -1
- package/dist/telemetry/grade-mappers.d.ts.map +1 -1
- package/dist/telemetry/grade-mappers.js +7 -1
- package/dist/telemetry/grade-task.d.ts +49 -0
- package/dist/telemetry/grade-task.d.ts.map +1 -0
- package/dist/telemetry/grade-task.js +85 -0
- package/dist/telemetry/grades-sql.d.ts +16 -1
- package/dist/telemetry/grades-sql.d.ts.map +1 -1
- package/dist/telemetry/grades-sql.js +64 -4
- package/dist/telemetry/ingest-protocol.d.ts +24 -1
- package/dist/telemetry/ingest-protocol.d.ts.map +1 -1
- package/dist/telemetry/ingest-protocol.js +72 -43
- package/dist/telemetry/otel-content.d.ts +31 -0
- package/dist/telemetry/otel-content.d.ts.map +1 -0
- package/dist/telemetry/otel-content.js +106 -0
- package/dist/telemetry/otel-hierarchy.d.ts +57 -0
- package/dist/telemetry/otel-hierarchy.d.ts.map +1 -0
- package/dist/telemetry/otel-hierarchy.js +155 -0
- package/dist/telemetry/otel-normalize.d.ts +15 -1
- package/dist/telemetry/otel-normalize.d.ts.map +1 -1
- package/dist/telemetry/otel-normalize.js +24 -39
- package/dist/telemetry/sinks.d.ts +4 -1
- package/dist/telemetry/sinks.d.ts.map +1 -1
- package/dist/telemetry/sinks.js +53 -34
- package/dist/telemetry/store-migrations.d.ts.map +1 -1
- package/dist/telemetry/store-migrations.js +8 -0
- package/dist/telemetry/store.d.ts +9 -0
- package/dist/telemetry/store.d.ts.map +1 -1
- package/dist/telemetry/store.js +10 -0
- package/dist/telemetry/uniform-rows.d.ts +43 -0
- package/dist/telemetry/uniform-rows.d.ts.map +1 -0
- package/dist/telemetry/uniform-rows.js +139 -0
- package/dist/types/failures-teaching.d.ts.map +1 -1
- package/dist/types/failures-teaching.js +11 -0
- package/dist/types/failures.d.ts +1 -1
- package/dist/types/failures.d.ts.map +1 -1
- package/dist/types/failures.js +2 -0
- package/dist/types/provider.d.ts +12 -0
- package/dist/types/provider.d.ts.map +1 -1
- package/dist/types/route.d.ts +13 -0
- package/dist/types/route.d.ts.map +1 -1
- package/dist/types/telemetry.d.ts +14 -1
- package/dist/types/telemetry.d.ts.map +1 -1
- package/docs/agent-skill/SKILL.md +122 -12
- package/docs/how-it-fits.md +4 -4
- package/docs/instrumentation.md +148 -44
- package/docs/llms.txt +143 -13
- package/docs/mcp-oracle.md +15 -4
- package/docs/quickstart.md +129 -16
- package/package.json +4 -2
- package/registry/registry.json +456 -0
- package/templates/creative-approval.json +81 -0
- package/templates/support-conversation.json +82 -0
package/dist/index.js
CHANGED
|
@@ -24,12 +24,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
24
24
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
25
25
|
};
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.
|
|
28
|
-
exports.
|
|
29
|
-
exports.
|
|
30
|
-
exports.
|
|
31
|
-
exports.
|
|
32
|
-
exports.computeOdometer = exports.createSwapsClient = exports.executeSwap = exports.trialVariantName = exports.buildDeclareTrialChange = exports.buildRestoreYaml = exports.buildSwapChange = exports.runTelemetryQuery = exports.RESERVED_DIMENSION_NAMES = exports.METRIC_COLUMNS = exports.DIMENSION_COLUMNS = exports.sinceIsoFor = exports.savedQueryById = exports.SAVED_QUERIES = void 0;
|
|
27
|
+
exports.looksLikeApiKey = exports.hashApiKeySecret = exports.API_KEY_SECRET_BYTES = exports.API_KEY_SCOPES = exports.API_KEY_PREFIX = exports.resolveArtifactsConfig = exports.createToolRegistry = exports.SlotResolutionError = exports.assemblePrompt = exports.createEmbeddedPrompts = exports.createPromptResolver = exports.parseServedPrompt = exports.createPromptCache = exports.createApiPromptFetcher = exports.promptTemplateSha = exports.normalizeManifest = exports.parseAuthoringDoc = exports.assertValidManifest = exports.validateManifest = exports.resolveOtlpConfig = exports.parseOtlpHeaders = exports.decodeOtlpProtobufTraces = exports.looksLikeLogsPayload = exports.normalizeOtlpTraces = exports.startOtlpEmitterIfConfigured = exports.createOtlpEmitter = exports.TRACEPARENT_TAG = exports.parseTraceparent = exports.buildExportTraceRequest = exports.inferenceToSpan = exports.SEMCONV_VERSION = exports.SinkSendError = exports.createDirectSink = exports.createApiSink = exports.createTelemetryExporter = exports.RESERVED_TAG_KEYS = exports.resolvePipelineSha = exports.reservedTagNearMisses = exports.renderRequestForHash = exports.sanitizeMetaForWire = exports.isMetaSafeString = exports.summarizeAttemptMeta = exports.DEFAULT_INGEST_URL = exports.INGEST_PROTOCOL_VERSION_V1 = exports.INGEST_PROTOCOL_VERSION = exports.INGEST_PATH = exports.foreignOrgGrades = exports.stepTaskRegistration = exports.stampBatch = exports.loadConfigFromEnv = void 0;
|
|
28
|
+
exports.PROVIDER_IDS = exports.RAW_ONLY_FIX_HINT = exports.rawOnlyRouteFailure = exports.requireRoutesDir = exports.MAX_REGISTERED_STEPS_PER_BATCH = exports.TASK_NAME_RULE = exports.TASK_NAME_PATTERN = exports.isValidTaskName = exports.registrableStepTasks = exports.stepTaskOf = exports.gradeTaskOf = exports.RECORDED_TOOLTIP = exports.RECORDED_BADGE = exports.EXTERNAL_LANE = exports.RAW_LANE = exports.callLaneOf = exports.isRoutedLane = exports.runRawStream = exports.runRaw = exports.resolveCallConfigForRun = exports.hashUnitKey = exports.armName = exports.drawArm = exports.narrowExperiment = exports.pinFromResolved = exports.parseCallConfig = exports.narrowCallConfigPin = exports.getCallConfig = exports.createCallConfigResolver = exports.createApiCallConfigFetcher = exports.applyCallConfig = exports.assertMirrorSafe = exports.hashResolvedBundle = exports.resolveRouteBundle = exports.bundleFromResolved = exports.runStream = exports.evalCaseCaptureStore = exports.selectEvalCaseCaptures = exports.runBakeoffFromEvalCases = exports.extractEvidenceQuotes = exports.groundednessScore = exports.resolveDeterministicQuality = exports.fieldAccuracy = exports.exactMatch = exports.KEY_SHAPED_PREFIXES = exports.containsKeyShapedString = exports.scrubSecrets = exports.hasScope = exports.parseScopes = exports.redactApiKey = void 0;
|
|
29
|
+
exports.PROVIDER_SIGNATURES = exports.readObjectLiteral = exports.findCallSitesInText = exports.scanRepoForCallSites = exports.capabilitiesFor = exports.routeNameFor = exports.buildMigrationMarkdown = exports.runInit = exports.renderConfigErrorForTerminal = exports.describeConfigFailure = exports.teachConfigError = exports.classifyConfigProblem = exports.CONFIG_TEACHING = exports.mergeLoadedRoutes = exports.loadRoutesWithExtra = exports.loadRoutes = exports.RouteConfigError = exports.renderFailureForTerminal = exports.teach = exports.FAILURE_TEACHING = exports.isRigFailure = exports.RigFailureError = exports.extractCitations = exports.createTavilySearchProvider = exports.sampleQuality = exports.pairedRegret = exports.wilson95 = exports.aggregateVariantMetrics = exports.OUTPUT_MAX_BYTES = exports.retentionExpiry = exports.truncateOutput = exports.selectArmsToKeep = exports.buildBakeoffSamples = exports.createBakeoffSamplesClient = exports.deriveSwapDirection = exports.bakeoffEvidence = exports.computeProposal = exports.mirrorBakeoff = exports.runBakeoff = exports.replayVariant = exports.openTelemetryStore = exports.openCaptureStore = exports.SSE_DONE = exports.MODELRIG_REQUEST_HEADERS = exports.MODELRIG_HEADERS = exports.GATEWAY_PROTOCOL_VERSION = exports.MODELS_PATH = exports.CHAT_COMPLETIONS_PATH = exports.classifyLane = exports.ALL_CAPABILITY_FLAGS = void 0;
|
|
30
|
+
exports.callNotesFor = exports.evaluateChallengerEligibility = exports.requirementPredicates = exports.PREDICATE_GLOSS = exports.ALL_CAPABILITY_PREDICATES = exports.explainEmptySelection = exports.hasCapability = exports.selectModels = exports.parseCapabilityQuery = exports.capabilityFactsFromEntry = exports.loadRegistryFacts = exports.fingerprintSchema = exports.loadManifest = exports.SNAPSHOT_BASIS = exports.describePricingV2 = exports.tierRates = exports.synthesizeFromFlat = exports.seededCachePolicyProviders = exports.getCachePolicy = exports.DEFAULT_CACHE_HYSTERESIS = exports.classifyCacheVerdict = exports.effectiveInputRate = exports.estimateCostUsd = exports.getPricingV2 = exports.getPricing = exports.resolveCandidates = exports.OPENAI_COMPAT_HOSTS = exports.shapeFireworksModelId = exports.classifyCompatFailure = exports.buildOpenAICompatParams = exports.createOpenAICompatAdapter = exports.createGrokAdapter = exports.createAnthropicAdapter = exports.createDeepSeekAdapter = exports.createOpenAIAdapter = exports.destinationSupported = exports.servedDestinations = exports.DEFAULT_DESTINATION = exports.DESTINATIONS = exports.GEMINI_THINKING_CAPABLE_MODELS = exports.createGeminiAdapter = exports.PROVIDER_KEY_ENV = exports.serveabilityWarnings = exports.checkServeability = exports.writeRouteDraft = exports.buildRouteDraft = exports.splitModelKey = exports.seedCandidates = exports.loadRegistryRows = exports.signatureFor = void 0;
|
|
31
|
+
exports.writePriorsCells = exports.aggregatePairwiseFromTelemetry = exports.aggregatePriors = exports.DEFAULT_WATCH_MONTHLY_USD = exports.watchEnvelopeKey = exports.reserveWatchBudget = exports.WATCH_STATE_KEY = exports.createFileWatchStateStore = exports.createControlPlaneWatchStateStore = exports.createWatchStateStore = exports.saveWatchState = exports.loadWatchState = exports.computeWatchEvents = exports.buildPriceUniverse = exports.runWatchCycle = exports.DEFAULT_MONITOR_CONFIG = exports.createMonitorReads = exports.rollupConformRate = exports.evaluateConformDegradation = exports.runMonitorCycle = exports.assertTransition = exports.createProposalsClient = exports.MONITOR_SOURCE_PREFIX = exports.MONITOR_CYCLE_MARKER = exports.REGRET_MONITOR_MARGIN = exports.REGRET_MONITOR_MIN_N = exports.REGRET_MONITOR_BASELINE_DAYS = exports.REGRET_MONITOR_WINDOW_DAYS = exports.createRegretMonitorReads = exports.regretMonitorConfig = exports.cyclePointFromArtifact = exports.aggregateRegretBand = exports.evaluateRegretDrift = exports.runRegretMonitorCycle = exports.evaluateUpgradeOpportunities = exports.explainCacheContext = exports.PROPOSAL_TTL_DAYS = exports.regretBreachTriggerHash = exports.upgradeTriggerHash = exports.manualChallengerTriggerHash = exports.triggerHash = exports.evaluateEvents = exports.RUNG1_MIN_GRADES = exports.computeCoverage = exports.computeParity = exports.factsUnderCredential = exports.factsFor = exports.PROBE_FRESHNESS_SLO_DAYS = exports.stalenessSentence = exports.probeFreshness = void 0;
|
|
32
|
+
exports.turnNumberOf = exports.turnStepKey = exports.TURN_STEP_PREFIX = exports.toWireGrade = exports.OUTCOME_GRADER_PREFIX = exports.OUTCOME_NAME_PATTERN = exports.OutcomeValidationError = exports.uuidV5 = exports.outcomeGradeId = exports.deriveOutcomeScore = exports.outcomeGraderName = exports.outcomeSubject = exports.buildOutcomeGradeRow = exports.isSingleUserTurn = exports.chatSystemPrompt = exports.chatMessagesToHistory = exports.chatMessagesAsRouteHistory = exports.chatHistoryIsValid = exports.TurnReplayRefusedError = exports.turnReplayCase = exports.assertTurnReplayAllowed = exports.renderForCapture = exports.parseCaptureInput = exports.MESSAGES_CAPTURE_KIND = exports.MessagesInputError = exports.historyProblems = exports.canonicalizeHistory = exports.assertValidHistory = exports.computeOdometer = exports.createSwapsClient = exports.executeSwap = exports.trialVariantName = exports.buildDeclareTrialChange = exports.buildRestoreYaml = exports.buildSwapChange = exports.runTelemetryQuery = exports.RESERVED_DIMENSION_NAMES = exports.METRIC_COLUMNS = exports.DIMENSION_COLUMNS = exports.sinceIsoFor = exports.savedQueryById = exports.SAVED_QUERIES = exports.ANALYTICS_SCAN_CAP = exports.selectableColumnsAreMetaSafe = exports.planAnalyticsRead = exports.evaluateAnalyticsQuery = exports.describeAnalyticsSchema = exports.parseQuery = exports.QueryGrammarError = exports.compileQuery = void 0;
|
|
33
|
+
exports.UNSCREENED_MEDIA = exports.MEDIA_TYPE_PREFIXES = exports.MEDIA_MIME_ALLOWLIST = exports.isAllowedMediaType = exports.isMediaType = exports.CONTENT_OUTPUT_CHAIN = exports.CONTENT_INPUT_CHAIN = exports.extractGenerationContent = exports.numberTurns = exports.operationClassOf = exports.mergeGenerationEntries = exports.generationRegistryEntries = exports.buildGenerationLayer = exports.GENERATION_SNAPSHOT = exports.GENERATION_SOURCES = exports.nonRankableKeys = exports.isRankable = exports.kindOf = exports.isModelKind = exports.MODEL_KINDS = exports.getMapUnitRates = exports.estimateUnitCostUsd = exports.cleanUnits = exports.UNIT_KEYS = exports.runLimitRefusal = exports.enforceRunLimits = exports.limitFailureReason = exports.validateRunLimits = exports.toolCallSignature = exports.initialLimitState = exports.accumulateRunLimits = exports.checkRunLimits = exports.RunLimitExceeded = exports.LIMIT_FAILURE_REASONS = exports.RUN_TRIGGERS = exports.TurnCounter = exports.maxTurnOf = void 0;
|
|
33
34
|
exports.createRig = createRig;
|
|
34
35
|
const build_adapters_1 = require("./adapters/build-adapters");
|
|
35
36
|
const config_1 = require("./config");
|
|
@@ -56,6 +57,7 @@ const status_1 = require("./status");
|
|
|
56
57
|
const deprecations_1 = require("./deprecations");
|
|
57
58
|
const otlp_emitter_1 = require("./telemetry/otlp-emitter");
|
|
58
59
|
const grade_1 = require("./feedback/grade");
|
|
60
|
+
const outcome_1 = require("./feedback/outcome"); // ARC-α
|
|
59
61
|
const facts_1 = require("./registry/facts");
|
|
60
62
|
const engine_1 = require("./bakeoff/engine");
|
|
61
63
|
const replay_1 = require("./bakeoff/replay");
|
|
@@ -70,10 +72,11 @@ const DEFAULT_REPLAY_ENVELOPE_USD = 10;
|
|
|
70
72
|
function createRig(config) {
|
|
71
73
|
// CE-8 (R1): `routesDir: null` is a first-class runRaw-only rig — skip route
|
|
72
74
|
// loading, the manifest, and the serveability gate; route methods throw below.
|
|
73
|
-
const
|
|
75
|
+
const routesDir = (0, rawonly_1.effectiveRoutesDir)(config); // SURF-1: absent DEFAULT dir ⇒ warn + raw-only; explicit ⇒ load (throws if missing)
|
|
76
|
+
const routes = routesDir === null ? (0, rawonly_1.emptyRouteStore)() : (0, rawonly_1.loadRoutesOrReport)(config, routesDir);
|
|
74
77
|
// rig.yaml lives at the rig dir root, one level above routes/
|
|
75
78
|
// (modelrig/rig.yaml next to modelrig/routes/ — cost-dimensions-design §2a).
|
|
76
|
-
const manifest =
|
|
79
|
+
const manifest = routesDir === null ? null : (0, manifest_1.loadManifest)((0, node_path_1.dirname)(routesDir));
|
|
77
80
|
// Registry facts load BEFORE adapters: the A1 compat hosts take their
|
|
78
81
|
// capability profile from the registry, never from the dialect.
|
|
79
82
|
const registryFacts = (0, facts_1.loadRegistryFacts)(config.registryPath);
|
|
@@ -253,6 +256,8 @@ function createRig(config) {
|
|
|
253
256
|
},
|
|
254
257
|
recordCall: (input) => (0, record_call_1.recordCall)(rawDeps, input),
|
|
255
258
|
grade: gradeApi.grade,
|
|
259
|
+
outcome: (0, outcome_1.makeOutcomeApi)(telemetry).outcome, // ARC-α (ARC-3)
|
|
260
|
+
conversation: (id, opts) => artifactNamespace.run.conversation(id, opts), // ARC-α (ARC-1)
|
|
256
261
|
replay(route, opts) {
|
|
257
262
|
return (0, replay_1.replayVariant)(deps, captureStoreForReplay(), {
|
|
258
263
|
route,
|
|
@@ -328,7 +333,7 @@ function createRig(config) {
|
|
|
328
333
|
// CE-8 (R1): a runRaw-only rig (routesDir: null) has no routes — override
|
|
329
334
|
// every route-dependent surface to throw a teaching invariant_violation.
|
|
330
335
|
// Spread LAST so it wins over the real methods above; empty for a routed rig.
|
|
331
|
-
...(
|
|
336
|
+
...(routesDir === null ? (0, rawonly_1.rawOnlyRouteMethods)(config.routesDir === null ? "routesDir-null" : "absent-default") : {}),
|
|
332
337
|
};
|
|
333
338
|
}
|
|
334
339
|
var config_2 = require("./config");
|
|
@@ -340,6 +345,7 @@ Object.defineProperty(exports, "loadConfigFromEnv", { enumerable: true, get: fun
|
|
|
340
345
|
// prettier-ignore
|
|
341
346
|
var ingest_protocol_1 = require("./telemetry/ingest-protocol");
|
|
342
347
|
Object.defineProperty(exports, "stampBatch", { enumerable: true, get: function () { return ingest_protocol_1.stampBatch; } });
|
|
348
|
+
Object.defineProperty(exports, "stepTaskRegistration", { enumerable: true, get: function () { return ingest_protocol_1.stepTaskRegistration; } });
|
|
343
349
|
Object.defineProperty(exports, "foreignOrgGrades", { enumerable: true, get: function () { return ingest_protocol_1.foreignOrgGrades; } });
|
|
344
350
|
Object.defineProperty(exports, "INGEST_PATH", { enumerable: true, get: function () { return ingest_protocol_1.INGEST_PATH; } });
|
|
345
351
|
Object.defineProperty(exports, "INGEST_PROTOCOL_VERSION", { enumerable: true, get: function () { return ingest_protocol_1.INGEST_PROTOCOL_VERSION; } });
|
|
@@ -480,6 +486,14 @@ Object.defineProperty(exports, "RAW_LANE", { enumerable: true, get: function ()
|
|
|
480
486
|
Object.defineProperty(exports, "EXTERNAL_LANE", { enumerable: true, get: function () { return lanes_1.EXTERNAL_LANE; } });
|
|
481
487
|
Object.defineProperty(exports, "RECORDED_BADGE", { enumerable: true, get: function () { return lanes_1.RECORDED_BADGE; } });
|
|
482
488
|
Object.defineProperty(exports, "RECORDED_TOOLTIP", { enumerable: true, get: function () { return lanes_1.RECORDED_TOOLTIP; } });
|
|
489
|
+
var grade_task_1 = require("./telemetry/grade-task");
|
|
490
|
+
Object.defineProperty(exports, "gradeTaskOf", { enumerable: true, get: function () { return grade_task_1.gradeTaskOf; } });
|
|
491
|
+
Object.defineProperty(exports, "stepTaskOf", { enumerable: true, get: function () { return grade_task_1.stepTaskOf; } });
|
|
492
|
+
Object.defineProperty(exports, "registrableStepTasks", { enumerable: true, get: function () { return grade_task_1.registrableStepTasks; } });
|
|
493
|
+
Object.defineProperty(exports, "isValidTaskName", { enumerable: true, get: function () { return grade_task_1.isValidTaskName; } });
|
|
494
|
+
Object.defineProperty(exports, "TASK_NAME_PATTERN", { enumerable: true, get: function () { return grade_task_1.TASK_NAME_PATTERN; } });
|
|
495
|
+
Object.defineProperty(exports, "TASK_NAME_RULE", { enumerable: true, get: function () { return grade_task_1.TASK_NAME_RULE; } });
|
|
496
|
+
Object.defineProperty(exports, "MAX_REGISTERED_STEPS_PER_BATCH", { enumerable: true, get: function () { return grade_task_1.MAX_REGISTERED_STEPS_PER_BATCH; } });
|
|
483
497
|
// CE-8 runRaw-only (routesDir: null): the string-narrowing guard route-required
|
|
484
498
|
// consumers (server, oracle) use, plus the teaching failure it throws.
|
|
485
499
|
var rawonly_2 = require("./run/rawonly");
|
|
@@ -744,3 +758,90 @@ var swaps_client_1 = require("./savings/swaps-client");
|
|
|
744
758
|
Object.defineProperty(exports, "createSwapsClient", { enumerable: true, get: function () { return swaps_client_1.createSwapsClient; } });
|
|
745
759
|
var odometer_1 = require("./savings/odometer");
|
|
746
760
|
Object.defineProperty(exports, "computeOdometer", { enumerable: true, get: function () { return odometer_1.computeOdometer; } });
|
|
761
|
+
// ── ARC-β: messages-native lane (agent-archetypes spec §4) ──────────────────
|
|
762
|
+
// `rig.run(route, { input, messages })` on an `input: messages` route, and `runRaw({ ..., messages })`.
|
|
763
|
+
// The spec's `ChatMessage` is exported as `HistoryMessage` (`ChatMessage` is the gateway's OpenAI wire type).
|
|
764
|
+
var messages_1 = require("./run/messages");
|
|
765
|
+
Object.defineProperty(exports, "assertValidHistory", { enumerable: true, get: function () { return messages_1.assertValidHistory; } });
|
|
766
|
+
Object.defineProperty(exports, "canonicalizeHistory", { enumerable: true, get: function () { return messages_1.canonicalize; } });
|
|
767
|
+
Object.defineProperty(exports, "historyProblems", { enumerable: true, get: function () { return messages_1.historyProblems; } });
|
|
768
|
+
Object.defineProperty(exports, "MessagesInputError", { enumerable: true, get: function () { return messages_1.MessagesInputError; } });
|
|
769
|
+
Object.defineProperty(exports, "MESSAGES_CAPTURE_KIND", { enumerable: true, get: function () { return messages_1.MESSAGES_CAPTURE_KIND; } });
|
|
770
|
+
Object.defineProperty(exports, "parseCaptureInput", { enumerable: true, get: function () { return messages_1.parseCaptureInput; } });
|
|
771
|
+
Object.defineProperty(exports, "renderForCapture", { enumerable: true, get: function () { return messages_1.renderForCapture; } });
|
|
772
|
+
var turn_replay_1 = require("./bakeoff/turn-replay"); // turn replay (M15 guard)
|
|
773
|
+
Object.defineProperty(exports, "assertTurnReplayAllowed", { enumerable: true, get: function () { return turn_replay_1.assertTurnReplayAllowed; } });
|
|
774
|
+
Object.defineProperty(exports, "turnReplayCase", { enumerable: true, get: function () { return turn_replay_1.turnReplayCase; } });
|
|
775
|
+
Object.defineProperty(exports, "TurnReplayRefusedError", { enumerable: true, get: function () { return turn_replay_1.TurnReplayRefusedError; } });
|
|
776
|
+
var history_bridge_1 = require("./gateway/history-bridge"); // gateway pass-through
|
|
777
|
+
Object.defineProperty(exports, "chatHistoryIsValid", { enumerable: true, get: function () { return history_bridge_1.chatHistoryIsValid; } });
|
|
778
|
+
Object.defineProperty(exports, "chatMessagesAsRouteHistory", { enumerable: true, get: function () { return history_bridge_1.chatMessagesAsRouteHistory; } });
|
|
779
|
+
Object.defineProperty(exports, "chatMessagesToHistory", { enumerable: true, get: function () { return history_bridge_1.chatMessagesToHistory; } });
|
|
780
|
+
Object.defineProperty(exports, "chatSystemPrompt", { enumerable: true, get: function () { return history_bridge_1.chatSystemPrompt; } });
|
|
781
|
+
Object.defineProperty(exports, "isSingleUserTurn", { enumerable: true, get: function () { return history_bridge_1.isSingleUserTurn; } });
|
|
782
|
+
// ── ARC-α (agent archetypes: conversations, outcomes, run limits) — append-only block (roadmap §4). ──
|
|
783
|
+
var outcome_2 = require("./feedback/outcome");
|
|
784
|
+
Object.defineProperty(exports, "buildOutcomeGradeRow", { enumerable: true, get: function () { return outcome_2.buildOutcomeGradeRow; } });
|
|
785
|
+
Object.defineProperty(exports, "outcomeSubject", { enumerable: true, get: function () { return outcome_2.outcomeSubject; } });
|
|
786
|
+
Object.defineProperty(exports, "outcomeGraderName", { enumerable: true, get: function () { return outcome_2.outcomeGraderName; } });
|
|
787
|
+
Object.defineProperty(exports, "deriveOutcomeScore", { enumerable: true, get: function () { return outcome_2.deriveOutcomeScore; } });
|
|
788
|
+
Object.defineProperty(exports, "outcomeGradeId", { enumerable: true, get: function () { return outcome_2.outcomeGradeId; } });
|
|
789
|
+
Object.defineProperty(exports, "uuidV5", { enumerable: true, get: function () { return outcome_2.uuidV5; } });
|
|
790
|
+
Object.defineProperty(exports, "OutcomeValidationError", { enumerable: true, get: function () { return outcome_2.OutcomeValidationError; } });
|
|
791
|
+
Object.defineProperty(exports, "OUTCOME_NAME_PATTERN", { enumerable: true, get: function () { return outcome_2.OUTCOME_NAME_PATTERN; } });
|
|
792
|
+
Object.defineProperty(exports, "OUTCOME_GRADER_PREFIX", { enumerable: true, get: function () { return outcome_2.OUTCOME_GRADER_PREFIX; } });
|
|
793
|
+
var grade_mappers_1 = require("./telemetry/grade-mappers");
|
|
794
|
+
Object.defineProperty(exports, "toWireGrade", { enumerable: true, get: function () { return grade_mappers_1.toWireGrade; } });
|
|
795
|
+
var conversation_1 = require("./artifacts/conversation");
|
|
796
|
+
Object.defineProperty(exports, "TURN_STEP_PREFIX", { enumerable: true, get: function () { return conversation_1.TURN_STEP_PREFIX; } });
|
|
797
|
+
Object.defineProperty(exports, "turnStepKey", { enumerable: true, get: function () { return conversation_1.turnStepKey; } });
|
|
798
|
+
Object.defineProperty(exports, "turnNumberOf", { enumerable: true, get: function () { return conversation_1.turnNumberOf; } });
|
|
799
|
+
Object.defineProperty(exports, "maxTurnOf", { enumerable: true, get: function () { return conversation_1.maxTurnOf; } });
|
|
800
|
+
Object.defineProperty(exports, "TurnCounter", { enumerable: true, get: function () { return conversation_1.TurnCounter; } });
|
|
801
|
+
var attempt_meta_2 = require("./telemetry/attempt-meta");
|
|
802
|
+
Object.defineProperty(exports, "RUN_TRIGGERS", { enumerable: true, get: function () { return attempt_meta_2.RUN_TRIGGERS; } });
|
|
803
|
+
Object.defineProperty(exports, "LIMIT_FAILURE_REASONS", { enumerable: true, get: function () { return attempt_meta_2.LIMIT_FAILURE_REASONS; } });
|
|
804
|
+
var limits_1 = require("./run/limits");
|
|
805
|
+
Object.defineProperty(exports, "RunLimitExceeded", { enumerable: true, get: function () { return limits_1.RunLimitExceeded; } });
|
|
806
|
+
Object.defineProperty(exports, "checkRunLimits", { enumerable: true, get: function () { return limits_1.checkRunLimits; } });
|
|
807
|
+
Object.defineProperty(exports, "accumulateRunLimits", { enumerable: true, get: function () { return limits_1.accumulate; } });
|
|
808
|
+
Object.defineProperty(exports, "initialLimitState", { enumerable: true, get: function () { return limits_1.initialLimitState; } });
|
|
809
|
+
Object.defineProperty(exports, "toolCallSignature", { enumerable: true, get: function () { return limits_1.toolCallSignature; } });
|
|
810
|
+
Object.defineProperty(exports, "validateRunLimits", { enumerable: true, get: function () { return limits_1.validateRunLimits; } });
|
|
811
|
+
Object.defineProperty(exports, "limitFailureReason", { enumerable: true, get: function () { return limits_1.limitFailureReason; } });
|
|
812
|
+
var run_context_1 = require("./artifacts/run-context");
|
|
813
|
+
Object.defineProperty(exports, "enforceRunLimits", { enumerable: true, get: function () { return run_context_1.enforceRunLimits; } });
|
|
814
|
+
Object.defineProperty(exports, "runLimitRefusal", { enumerable: true, get: function () { return run_context_1.runLimitRefusal; } });
|
|
815
|
+
// ── ARC-γ (agent archetypes: generated media, OTLP-in v1) — append-only block (roadmap §4). ──
|
|
816
|
+
var attempt_meta_3 = require("./telemetry/attempt-meta");
|
|
817
|
+
Object.defineProperty(exports, "UNIT_KEYS", { enumerable: true, get: function () { return attempt_meta_3.UNIT_KEYS; } });
|
|
818
|
+
Object.defineProperty(exports, "cleanUnits", { enumerable: true, get: function () { return attempt_meta_3.cleanUnits; } });
|
|
819
|
+
var cost_1 = require("./run/cost");
|
|
820
|
+
Object.defineProperty(exports, "estimateUnitCostUsd", { enumerable: true, get: function () { return cost_1.estimateUnitCostUsd; } });
|
|
821
|
+
var pricing_2 = require("./registry/pricing");
|
|
822
|
+
Object.defineProperty(exports, "getMapUnitRates", { enumerable: true, get: function () { return pricing_2.getMapUnitRates; } });
|
|
823
|
+
var model_kind_1 = require("./registry/model-kind");
|
|
824
|
+
Object.defineProperty(exports, "MODEL_KINDS", { enumerable: true, get: function () { return model_kind_1.MODEL_KINDS; } });
|
|
825
|
+
Object.defineProperty(exports, "isModelKind", { enumerable: true, get: function () { return model_kind_1.isModelKind; } });
|
|
826
|
+
Object.defineProperty(exports, "kindOf", { enumerable: true, get: function () { return model_kind_1.kindOf; } });
|
|
827
|
+
Object.defineProperty(exports, "isRankable", { enumerable: true, get: function () { return model_kind_1.isRankable; } });
|
|
828
|
+
Object.defineProperty(exports, "nonRankableKeys", { enumerable: true, get: function () { return model_kind_1.nonRankableKeys; } });
|
|
829
|
+
var generation_models_1 = require("./registry/generation-models");
|
|
830
|
+
Object.defineProperty(exports, "GENERATION_SOURCES", { enumerable: true, get: function () { return generation_models_1.GENERATION_SOURCES; } });
|
|
831
|
+
Object.defineProperty(exports, "GENERATION_SNAPSHOT", { enumerable: true, get: function () { return generation_models_1.GENERATION_SNAPSHOT; } });
|
|
832
|
+
Object.defineProperty(exports, "buildGenerationLayer", { enumerable: true, get: function () { return generation_models_1.buildGenerationLayer; } });
|
|
833
|
+
Object.defineProperty(exports, "generationRegistryEntries", { enumerable: true, get: function () { return generation_models_1.generationRegistryEntries; } });
|
|
834
|
+
Object.defineProperty(exports, "mergeGenerationEntries", { enumerable: true, get: function () { return generation_models_1.mergeGenerationEntries; } });
|
|
835
|
+
var otel_hierarchy_1 = require("./telemetry/otel-hierarchy");
|
|
836
|
+
Object.defineProperty(exports, "operationClassOf", { enumerable: true, get: function () { return otel_hierarchy_1.operationClassOf; } });
|
|
837
|
+
Object.defineProperty(exports, "numberTurns", { enumerable: true, get: function () { return otel_hierarchy_1.numberTurns; } });
|
|
838
|
+
var otel_content_1 = require("./telemetry/otel-content");
|
|
839
|
+
Object.defineProperty(exports, "extractGenerationContent", { enumerable: true, get: function () { return otel_content_1.extractGenerationContent; } });
|
|
840
|
+
Object.defineProperty(exports, "CONTENT_INPUT_CHAIN", { enumerable: true, get: function () { return otel_content_1.CONTENT_INPUT_CHAIN; } });
|
|
841
|
+
Object.defineProperty(exports, "CONTENT_OUTPUT_CHAIN", { enumerable: true, get: function () { return otel_content_1.CONTENT_OUTPUT_CHAIN; } });
|
|
842
|
+
var media_1 = require("./artifacts/media");
|
|
843
|
+
Object.defineProperty(exports, "isMediaType", { enumerable: true, get: function () { return media_1.isMediaType; } });
|
|
844
|
+
Object.defineProperty(exports, "isAllowedMediaType", { enumerable: true, get: function () { return media_1.isAllowedMediaType; } });
|
|
845
|
+
Object.defineProperty(exports, "MEDIA_MIME_ALLOWLIST", { enumerable: true, get: function () { return media_1.MEDIA_MIME_ALLOWLIST; } });
|
|
846
|
+
Object.defineProperty(exports, "MEDIA_TYPE_PREFIXES", { enumerable: true, get: function () { return media_1.MEDIA_TYPE_PREFIXES; } });
|
|
847
|
+
Object.defineProperty(exports, "UNSCREENED_MEDIA", { enumerable: true, get: function () { return media_1.UNSCREENED_MEDIA; } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init-cli.d.ts","sourceRoot":"","sources":["../../src/init/init-cli.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AASH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"init-cli.d.ts","sourceRoot":"","sources":["../../src/init/init-cli.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AASH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAelD,wBAAgB,OAAO,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM,CA+FnD"}
|
package/dist/init/init-cli.js
CHANGED
|
@@ -15,13 +15,23 @@ const rawonly_1 = require("../run/rawonly");
|
|
|
15
15
|
const rows_1 = require("../registry/rows");
|
|
16
16
|
const observe_cli_1 = require("./observe-cli");
|
|
17
17
|
const run_1 = require("./run");
|
|
18
|
+
const starter_1 = require("./starter");
|
|
19
|
+
/** Write the starter route's schema + prompt (SURF-1, audit #2) and say so. */
|
|
20
|
+
function writeStarter(routesDir) {
|
|
21
|
+
const starter = (0, starter_1.writeStarterFiles)(routesDir, { existsSync: node_fs_1.existsSync, mkdirSync: node_fs_1.mkdirSync, writeFileSync: node_fs_1.writeFileSync }, { join: node_path_1.join, dirname: node_path_1.dirname });
|
|
22
|
+
if (starter.written.length > 0) {
|
|
23
|
+
console.log(`\nwrote the starter route's schema and prompt (${starter.written.join(", ")}), so the\n` +
|
|
24
|
+
"example.support_summarize route shown in the console and the docs validates as pasted.");
|
|
25
|
+
}
|
|
26
|
+
}
|
|
18
27
|
function cmdInit(flags) {
|
|
19
28
|
// `init --observe` is the observe-first (T0/T1) alias for `modelrig observe`.
|
|
20
29
|
if (flags.bare.has("observe"))
|
|
21
30
|
return (0, observe_cli_1.cmdObserve)(flags);
|
|
22
31
|
const root = (0, node_path_1.resolve)(flags.positional[0] ?? ".");
|
|
23
32
|
const config = (0, config_1.loadConfigFromEnv)();
|
|
24
|
-
const
|
|
33
|
+
const routesDir = (0, rawonly_1.requireRoutesDir)(config, "modelrig init");
|
|
34
|
+
const draftsDir = flags.named.get("out") ?? (0, node_path_1.join)(routesDir, "drafts");
|
|
25
35
|
const scope = (0, observe_cli_1.scopeFrom)(flags);
|
|
26
36
|
// Registry rows seed the challenger candidates. A missing/unbuilt registry
|
|
27
37
|
// is not fatal — drafts then carry the incumbent alone, and say so.
|
|
@@ -44,6 +54,9 @@ function cmdInit(flags) {
|
|
|
44
54
|
...(scope !== undefined ? { scope } : {}),
|
|
45
55
|
});
|
|
46
56
|
if (flags.bare.has("json")) {
|
|
57
|
+
const starter = flags.bare.has("dry-run")
|
|
58
|
+
? { written: [], skipped: [] }
|
|
59
|
+
: (0, starter_1.writeStarterFiles)(routesDir, { existsSync: node_fs_1.existsSync, mkdirSync: node_fs_1.mkdirSync, writeFileSync: node_fs_1.writeFileSync }, { join: node_path_1.join, dirname: node_path_1.dirname });
|
|
47
60
|
console.log(JSON.stringify({
|
|
48
61
|
sitesFound: result.sitesFound,
|
|
49
62
|
filesScanned: result.filesScanned,
|
|
@@ -56,17 +69,20 @@ function cmdInit(flags) {
|
|
|
56
69
|
model: d.site.model,
|
|
57
70
|
notes: d.site.notes,
|
|
58
71
|
})),
|
|
59
|
-
written: result.written,
|
|
60
|
-
skipped: result.skipped,
|
|
72
|
+
written: [...result.written, ...starter.written],
|
|
73
|
+
skipped: [...result.skipped, ...starter.skipped],
|
|
61
74
|
}, null, 2));
|
|
62
75
|
return 0;
|
|
63
76
|
}
|
|
64
77
|
console.log(`modelrig init — scanned ${result.filesScanned} file(s) under ${root}` +
|
|
65
78
|
(scope !== undefined ? ` (scoped to ${scope.join(", ")})` : "") +
|
|
66
79
|
`\nfound ${result.sitesFound} provider call site(s)`);
|
|
80
|
+
const dryRun = flags.bare.has("dry-run");
|
|
67
81
|
if (result.sitesFound === 0) {
|
|
68
82
|
console.log("\nNothing to draft. If you know there are model calls here, they may sit behind a helper\n" +
|
|
69
83
|
"that hides the SDK — point init at the file that actually calls the provider.");
|
|
84
|
+
if (!dryRun)
|
|
85
|
+
writeStarter(routesDir);
|
|
70
86
|
return 0;
|
|
71
87
|
}
|
|
72
88
|
for (const draft of result.drafts) {
|
|
@@ -76,10 +92,11 @@ function cmdInit(flags) {
|
|
|
76
92
|
if (result.filesSkipped.length > 0) {
|
|
77
93
|
console.log(`\n${result.filesSkipped.length} file(s) skipped (too large or unreadable).`);
|
|
78
94
|
}
|
|
79
|
-
if (
|
|
95
|
+
if (dryRun) {
|
|
80
96
|
console.log("\n--dry-run: nothing written.");
|
|
81
97
|
return 0;
|
|
82
98
|
}
|
|
99
|
+
writeStarter(routesDir);
|
|
83
100
|
console.log(`\nwrote ${result.written.length} file(s) to ${draftsDir}` +
|
|
84
101
|
(result.skipped.length > 0 ? ` (${result.skipped.length} left alone — already there)` : "") +
|
|
85
102
|
`\nread ${(0, node_path_1.join)(draftsDir, "MIGRATION.md")} next. Your source was not touched.`);
|
package/dist/init/observe-cli.js
CHANGED
|
@@ -69,6 +69,6 @@ function cmdObserve(flags) {
|
|
|
69
69
|
console.log(`\nwrote ${result.written.length} file(s) to ${outDir}` +
|
|
70
70
|
(result.skipped.length > 0 ? ` (${result.skipped.length} left alone — already there)` : "") +
|
|
71
71
|
`\nread ${(0, node_path_1.join)(outDir, "OBSERVE.md")} next — apply the wiring diffs one step at a time.` +
|
|
72
|
-
"\nObserve changes no behaviour; with no
|
|
72
|
+
"\nObserve changes no behaviour; with no MODELRIG_API_KEY set your pipeline is byte-for-byte the same.");
|
|
73
73
|
return 0;
|
|
74
74
|
}
|
package/dist/init/observe.d.ts
CHANGED
|
@@ -70,7 +70,13 @@ export interface ObserveDeps {
|
|
|
70
70
|
export declare function stepKeyFor(site: CallSite, used: Set<string>): string;
|
|
71
71
|
/** The generated seam. Self-contained and fresh (never resurrected from git
|
|
72
72
|
* history — that is the point of onboarding-test run-2). Mirrors the reference
|
|
73
|
-
* `recordStep` in instrumentation.md, plus a `withRun` boundary wrapper.
|
|
73
|
+
* `recordStep` in instrumentation.md, plus a `withRun` boundary wrapper.
|
|
74
|
+
*
|
|
75
|
+
* SURF-1 (audit #1, #6): the rig is built `routesDir: null` (observe needs no
|
|
76
|
+
* routes, and the default dir is absent in a fresh repo — the old seam crashed
|
|
77
|
+
* the customer's app on import), and `recordStep` reports the provider call
|
|
78
|
+
* through `rig.recordCall` so the step carries tokens and a cost and the call
|
|
79
|
+
* shows on /inferences. */
|
|
74
80
|
export declare function seamContent(): string;
|
|
75
81
|
export declare function buildObserveMarkdown(plans: readonly ObservePlan[], seamPath: string, result: {
|
|
76
82
|
sitesFound: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observe.d.ts","sourceRoot":"","sources":["../../src/init/observe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C;kFACkF;AAClF,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,gFAAgF;IAChF,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,wDAAwD;IACxD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,KAAK,EAAE,SAAS,WAAW,EAAE,CAAC;IACvC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;IACzC,6DAA6D;IAC7D,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,wDAAwD;IACxD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,uEAAuE;IACvE,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC;AAED,MAAM,WAAW,cAAe,SAAQ,aAAa;IACnD,0CAA0C;IAC1C,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,iFAAiF;IACjF,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,EAAE,cAAc,GAAG;QAC5B,UAAU,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC;QACnC,SAAS,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE;YAAE,SAAS,EAAE,OAAO,CAAA;SAAE,KAAK,IAAI,CAAC;QAC1D,aAAa,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;KAC1D,CAAC;IACF,QAAQ,CAAC,IAAI,EAAE;QACb,IAAI,EAAE,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,KAAK,MAAM,CAAC;QACrC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,MAAM,CAAC;QAC/C,OAAO,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;QAC/B,QAAQ,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;KAC/C,CAAC;CACH;
|
|
1
|
+
{"version":3,"file":"observe.d.ts","sourceRoot":"","sources":["../../src/init/observe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C;kFACkF;AAClF,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,gFAAgF;IAChF,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,wDAAwD;IACxD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,KAAK,EAAE,SAAS,WAAW,EAAE,CAAC;IACvC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;IACzC,6DAA6D;IAC7D,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,wDAAwD;IACxD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,uEAAuE;IACvE,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC;AAED,MAAM,WAAW,cAAe,SAAQ,aAAa;IACnD,0CAA0C;IAC1C,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,iFAAiF;IACjF,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,EAAE,cAAc,GAAG;QAC5B,UAAU,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC;QACnC,SAAS,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE;YAAE,SAAS,EAAE,OAAO,CAAA;SAAE,KAAK,IAAI,CAAC;QAC1D,aAAa,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;KAC1D,CAAC;IACF,QAAQ,CAAC,IAAI,EAAE;QACb,IAAI,EAAE,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,KAAK,MAAM,CAAC;QACrC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,MAAM,CAAC;QAC/C,OAAO,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;QAC/B,QAAQ,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;KAC/C,CAAC;CACH;AAUD;iFACiF;AACjF,wBAAgB,UAAU,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,MAAM,CAQpE;AAED;;;;;;;;2BAQ2B;AAC3B,wBAAgB,WAAW,IAAI,MAAM,CA6EpC;AA6DD,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,SAAS,WAAW,EAAE,EAC7B,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,EACrF,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,GACxB,MAAM,CA4HR;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,GAAE,cAAmB,GAAG,aAAa,CA6DzF"}
|
package/dist/init/observe.js
CHANGED
|
@@ -25,6 +25,10 @@ exports.seamContent = seamContent;
|
|
|
25
25
|
exports.buildObserveMarkdown = buildObserveMarkdown;
|
|
26
26
|
exports.runObserve = runObserve;
|
|
27
27
|
const finder_1 = require("./finder");
|
|
28
|
+
/** The `environment` expression the wiring diff proposes. Assembled so this
|
|
29
|
+
* source file never holds the literal env-read token (package invariant: only
|
|
30
|
+
* config.ts reads the environment). */
|
|
31
|
+
const ENV_EXPR = `${["process", "env", "NODE_ENV"].join(".")} ?? "development"`;
|
|
28
32
|
const normalize = (s) => s.replace(/[^A-Za-z0-9]+/g, "_").replace(/^_|_$/g, "").toLowerCase();
|
|
29
33
|
/** A stable step key from a call site: `<dir>_<file>_<line>`, deduped so two
|
|
30
34
|
* sites never collide. Deterministic, so a second run proposes the same keys. */
|
|
@@ -40,33 +44,43 @@ function stepKeyFor(site, used) {
|
|
|
40
44
|
}
|
|
41
45
|
/** The generated seam. Self-contained and fresh (never resurrected from git
|
|
42
46
|
* history — that is the point of onboarding-test run-2). Mirrors the reference
|
|
43
|
-
* `recordStep` in instrumentation.md, plus a `withRun` boundary wrapper.
|
|
47
|
+
* `recordStep` in instrumentation.md, plus a `withRun` boundary wrapper.
|
|
48
|
+
*
|
|
49
|
+
* SURF-1 (audit #1, #6): the rig is built `routesDir: null` (observe needs no
|
|
50
|
+
* routes, and the default dir is absent in a fresh repo — the old seam crashed
|
|
51
|
+
* the customer's app on import), and `recordStep` reports the provider call
|
|
52
|
+
* through `rig.recordCall` so the step carries tokens and a cost and the call
|
|
53
|
+
* shows on /inferences. */
|
|
44
54
|
function seamContent() {
|
|
45
55
|
return `/**
|
|
46
56
|
* ModelRig observe seam — generated by \`modelrig observe\`.
|
|
47
57
|
*
|
|
48
58
|
* This is YOURS to keep and edit; it is generated fresh (not copied from any
|
|
49
59
|
* deleted seam) so it always matches the current SDK. It records each pipeline
|
|
50
|
-
* run as a run -> step -> artifact chain you click through in the console
|
|
60
|
+
* run as a run -> step -> artifact chain you click through in the console, and
|
|
61
|
+
* each model call as a recorded inference with its tokens and cost.
|
|
51
62
|
*
|
|
52
|
-
* Observe-only: no routes move, no model calls are rerouted.
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
63
|
+
* Observe-only: no routes move, no model calls are rerouted. Your code keeps
|
|
64
|
+
* calling the provider with your own key; this file only REPORTS what happened.
|
|
65
|
+
* With no MODELRIG_API_KEY (or the org capture posture set to off) every call
|
|
66
|
+
* here is inert and your pipeline behaves byte-for-byte as before. Nothing here
|
|
67
|
+
* ever throws into your pipeline — a telemetry write that fails is logged and
|
|
56
68
|
* dropped (instrumentation.md, "Never throws into your pipeline").
|
|
57
69
|
*
|
|
58
70
|
* Docs: https://modelrig.dev/instrumentation.html
|
|
59
71
|
*/
|
|
60
72
|
|
|
61
|
-
import { createRig, loadConfigFromEnv, type Rig } from "modelrig";
|
|
73
|
+
import { createRig, loadConfigFromEnv, type RecordCallInput, type Rig } from "modelrig";
|
|
62
74
|
|
|
63
|
-
|
|
75
|
+
// routesDir: null — observe needs no route files, so the rig is raw-only and
|
|
76
|
+
// never looks for ./modelrig/routes (importing this file cannot throw).
|
|
77
|
+
const rig: Rig = createRig({ ...loadConfigFromEnv(), routesDir: null });
|
|
64
78
|
|
|
65
79
|
/** Open a run context around a whole pipeline, close it on success/failure.
|
|
66
80
|
* \`episodeKey\` is a grouping key (a natural choice: your per-run attempt id),
|
|
67
|
-
* not a unique id. Pass \`environment\` (e.g. your NODE_ENV)
|
|
68
|
-
* Use \`rig.artifacts.run.scope(...)\` instead for
|
|
69
|
-
* process. */
|
|
81
|
+
* not a unique id. Pass \`environment\` (e.g. your NODE_ENV) so the Env column
|
|
82
|
+
* on /runs is filled. Use \`rig.artifacts.run.scope(...)\` instead for
|
|
83
|
+
* concurrent runs in one process. */
|
|
70
84
|
export async function withRun<T>(
|
|
71
85
|
opts: { pipeline: string; episodeKey: string; environment?: string },
|
|
72
86
|
body: () => Promise<T>,
|
|
@@ -86,14 +100,20 @@ export async function withRun<T>(
|
|
|
86
100
|
}
|
|
87
101
|
}
|
|
88
102
|
|
|
89
|
-
/**
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
|
|
103
|
+
/** The provider call your code made, as the provider reported it. Recorded with
|
|
104
|
+
* \`rig.recordCall\` so the step carries tokens and a cost ("recorded ·
|
|
105
|
+
* unverified": ModelRig did not dispatch it). */
|
|
106
|
+
export type StepCall = Omit<RecordCallInput, "stepKey">;
|
|
107
|
+
|
|
108
|
+
/** Record one step: report the provider call (tokens → cost on /runs and
|
|
109
|
+
* /inferences), save prompt + raw + parsed, link lineage, flag conformance.
|
|
110
|
+
* Leave \`call\` out only when you have no usage numbers; the step then shows
|
|
111
|
+
* "—" for its cost ("cost n/a" with Developer details on). */
|
|
93
112
|
export function recordStep(
|
|
94
113
|
stepKey: string,
|
|
95
|
-
work: { prompt: string; rawText: string; json: unknown; conforms: boolean },
|
|
114
|
+
work: { prompt: string; rawText: string; json: unknown; conforms: boolean; call?: StepCall },
|
|
96
115
|
): void {
|
|
116
|
+
if (work.call !== undefined) rig.recordCall({ ...work.call, stepKey });
|
|
97
117
|
const p = rig.artifacts.artifact.save(work.prompt, { name: \`\${stepKey}.prompt\`, type: "prompt", stepKey });
|
|
98
118
|
const raw = rig.artifacts.artifact.save(work.rawText, { name: \`\${stepKey}.raw\`, type: "raw_response", stepKey });
|
|
99
119
|
const parsed = rig.artifacts.artifact.save(work.json, { name: \`\${stepKey}.output\`, type: "step_output", task: stepKey, stepKey });
|
|
@@ -101,6 +121,12 @@ export function recordStep(
|
|
|
101
121
|
if (raw && parsed) rig.artifacts.artifact.link(parsed, raw, "derived_from");
|
|
102
122
|
if (parsed) rig.grade({ kind: "artifact", id: parsed.id }, { score: work.conforms ? 1 : 0, kind: "deterministic", grader: "schema-check" });
|
|
103
123
|
}
|
|
124
|
+
|
|
125
|
+
/** Flush and close the rig. Await it once at shutdown (a one-shot script that
|
|
126
|
+
* exits without it can lose the last batch). */
|
|
127
|
+
export function closeRig(): Promise<void> {
|
|
128
|
+
return rig.close();
|
|
129
|
+
}
|
|
104
130
|
`;
|
|
105
131
|
}
|
|
106
132
|
/** The import specifier a source file uses to reach the seam. Best-effort
|
|
@@ -110,12 +136,36 @@ function importSpecifier(fromFile, seamPath, path) {
|
|
|
110
136
|
const rel = path.relative(path.dirname(fromFile), noExt);
|
|
111
137
|
return rel.startsWith(".") ? rel : `./${rel}`;
|
|
112
138
|
}
|
|
113
|
-
|
|
139
|
+
/** How the customer's provider response reports usage, per provider family —
|
|
140
|
+
* the expressions the wiring diff proposes for `call.usage` (the human/agent
|
|
141
|
+
* adjusts the variable name). Unknown providers get a placeholder. */
|
|
142
|
+
const USAGE_EXPR = {
|
|
143
|
+
openai: { tokensIn: "res.usage?.prompt_tokens ?? 0", tokensOut: "res.usage?.completion_tokens ?? 0" },
|
|
144
|
+
deepseek: { tokensIn: "res.usage?.prompt_tokens ?? 0", tokensOut: "res.usage?.completion_tokens ?? 0" },
|
|
145
|
+
grok: { tokensIn: "res.usage?.prompt_tokens ?? 0", tokensOut: "res.usage?.completion_tokens ?? 0" },
|
|
146
|
+
deepinfra: { tokensIn: "res.usage?.prompt_tokens ?? 0", tokensOut: "res.usage?.completion_tokens ?? 0" },
|
|
147
|
+
fireworks: { tokensIn: "res.usage?.prompt_tokens ?? 0", tokensOut: "res.usage?.completion_tokens ?? 0" },
|
|
148
|
+
anthropic: { tokensIn: "res.usage.input_tokens", tokensOut: "res.usage.output_tokens" },
|
|
149
|
+
// Gemini bills thinking tokens as output: candidates + thoughts (SURF-1 QA).
|
|
150
|
+
gemini: {
|
|
151
|
+
tokensIn: "res.usageMetadata?.promptTokenCount ?? 0",
|
|
152
|
+
tokensOut: "(res.usageMetadata?.candidatesTokenCount ?? 0) + (res.usageMetadata?.thoughtsTokenCount ?? 0)",
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
function recordStepSnippet(site, stepKey) {
|
|
156
|
+
const usage = USAGE_EXPR[site.provider] ?? { tokensIn: "/* input tokens */ 0", tokensOut: "/* output tokens */ 0" };
|
|
157
|
+
const model = site.model !== null ? JSON.stringify(site.model) : site.modelExpression ?? '"<model id>"';
|
|
114
158
|
return (`recordStep(${JSON.stringify(stepKey)}, {\n` +
|
|
115
159
|
` prompt, // the assembled prompt string\n` +
|
|
116
160
|
` rawText, // the model's raw text, pre-parse\n` +
|
|
117
161
|
` json: parsed, // your parsed/validated output\n` +
|
|
118
162
|
` conforms, // did it satisfy your schema?\n` +
|
|
163
|
+
` call: { // what the provider reported → tokens + cost (rig.recordCall)\n` +
|
|
164
|
+
` provider: ${JSON.stringify(site.provider)},\n` +
|
|
165
|
+
` model: ${model},\n` +
|
|
166
|
+
` usage: { tokensIn: ${usage.tokensIn}, tokensOut: ${usage.tokensOut} },\n` +
|
|
167
|
+
` latencyMs, // Date.now() after the call minus before it\n` +
|
|
168
|
+
` },\n` +
|
|
119
169
|
`});`);
|
|
120
170
|
}
|
|
121
171
|
/** The run boundary is most likely the shallowest detected file (the entry
|
|
@@ -139,7 +189,7 @@ function buildObserveMarkdown(plans, seamPath, result, path) {
|
|
|
139
189
|
"**Nothing in your source has changed.** `modelrig observe` generated one seam helper",
|
|
140
190
|
`(\`${seamPath}\`) and this plan. Observe is **not migration**: no routes were drafted, no`,
|
|
141
191
|
"model calls rerouted. Applying the wiring below records each run as a run → step →",
|
|
142
|
-
"artifact chain you click through in the console — and with
|
|
192
|
+
"artifact chain you click through in the console — and with no key set, your pipeline",
|
|
143
193
|
"behaves **byte-for-byte** as before.",
|
|
144
194
|
"",
|
|
145
195
|
`Detected **${result.sitesFound} model call site(s)** across ${result.filesScanned} scanned file(s);`,
|
|
@@ -154,9 +204,11 @@ function buildObserveMarkdown(plans, seamPath, result, path) {
|
|
|
154
204
|
"",
|
|
155
205
|
"```bash",
|
|
156
206
|
"export MODELRIG_API_KEY=<key> # mint at https://app.modelrig.ai (/keys)",
|
|
157
|
-
"# export MODELRIG_ARTIFACT_STEPS=step_a,step_b # optional: instrument a subset",
|
|
158
207
|
"```",
|
|
159
208
|
"",
|
|
209
|
+
"The seam builds its rig with `routesDir: null`: observe needs no route files, so importing",
|
|
210
|
+
"it never looks for `./modelrig/routes`.",
|
|
211
|
+
"",
|
|
160
212
|
"> **Human handoff (one step, once).** Seeing these runs **in the console** needs a free",
|
|
161
213
|
"> account + an API key minted at <https://app.modelrig.ai> (`/keys`) — a console login a",
|
|
162
214
|
"> coding agent cannot perform. Set `MODELRIG_API_KEY=<key>` once a human provides it; the",
|
|
@@ -174,7 +226,7 @@ function buildObserveMarkdown(plans, seamPath, result, path) {
|
|
|
174
226
|
lines.push("## 2. Open a run context around the pipeline", "", boundary === null
|
|
175
227
|
? "Wrap your pipeline's entry point in `withRun(...)` from the seam helper:"
|
|
176
228
|
: `Your pipeline entry looks like \`${boundary}\` (the shallowest detected call site — a` +
|
|
177
|
-
" heuristic; move this if your real entry is elsewhere). Wrap it in `withRun(...)`:", "", "```diff", `+ import { withRun } from "${boundaryImport}";`, "", "- export async function runPipeline(input) {", "- /* ... your steps ... */", "- }", "+ export async function runPipeline(input) {", "+ return withRun(",
|
|
229
|
+
" heuristic; move this if your real entry is elsewhere). Wrap it in `withRun(...)`:", "", "```diff", `+ import { withRun } from "${boundaryImport}";`, "", "- export async function runPipeline(input) {", "- /* ... your steps ... */", "- }", "+ export async function runPipeline(input) {", "+ return withRun(", `+ { pipeline: "my-pipeline", episodeKey: input.attemptId, environment: ${ENV_EXPR} },`, "+ async () => {", "+ /* ... your steps ... */", "+ },", "+ );", "+ }", "```", "", "## 3. Record each step's work products", "", "Each detected model call is one step. After the call parses its output, add a `recordStep`", "(the diffs below quote the call line so you can find it). Its `call` field reports what the", "provider returned through `rig.recordCall`, so the step carries tokens and a cost and the call", "shows on /inferences as \"Reported by your code\" (\"recorded · unverified\" with Developer details on).", "Time the call (`const t0 = Date.now()` before,", "`const latencyMs = Date.now() - t0` after) and rename `res` to your response variable:", "");
|
|
178
230
|
// Group the per-site wiring diffs by file so each file gets one import line.
|
|
179
231
|
const byFile = new Map();
|
|
180
232
|
for (const plan of plans) {
|
|
@@ -190,7 +242,7 @@ function buildObserveMarkdown(plans, seamPath, result, path) {
|
|
|
190
242
|
}
|
|
191
243
|
lines.push("```", "");
|
|
192
244
|
}
|
|
193
|
-
lines.push("## 4. See it", "", "Run your pipeline once, then open the console: **Runs** lists the run, `/runs/[id]` renders", "the semantic chain (artifacts grouped by step, with hashes and evaluation badges), and", "`/artifacts/[id]` shows one artifact's lineage.
|
|
245
|
+
lines.push("## 4. See it", "", "Run your pipeline once, then open the console: **Runs** lists the run, `/runs/[id]` renders", "the semantic chain (artifacts grouped by step, with hashes and evaluation badges), and", "`/artifacts/[id]` shows one artifact's lineage, and **Inferences** lists each recorded call", "with its cost. A step you wired without `call` shows **—** for its cost (**cost n/a** with", "Developer details on): ModelRig has no usage", "numbers for it. In a script that exits, `await closeRig()` once at the end so the last batch", "ships. Calls your code makes outside `recordStep` stay invisible: https://modelrig.dev/not-captured.html", "", "## When you are ready to migrate (later, optional)", "", "Observe answers *what is my pipeline doing?* When you want to *change what serves a step*,", "that is route extraction (T2) — a separate, behaviour-affecting move behind its own review:", "`modelrig init --scope <this pipeline>`. Observe first is the safer order.", "");
|
|
194
246
|
return `${lines.join("\n")}\n`;
|
|
195
247
|
}
|
|
196
248
|
function runObserve(deps, options = {}) {
|
|
@@ -198,7 +250,7 @@ function runObserve(deps, options = {}) {
|
|
|
198
250
|
const used = new Set();
|
|
199
251
|
const plans = scan.sites.map((site) => {
|
|
200
252
|
const stepKey = stepKeyFor(site, used);
|
|
201
|
-
return { site, stepKey, snippet: recordStepSnippet(stepKey) };
|
|
253
|
+
return { site, stepKey, snippet: recordStepSnippet(site, stepKey) };
|
|
202
254
|
});
|
|
203
255
|
const seamPath = deps.path.join(deps.outDir, "record-step.ts");
|
|
204
256
|
// Import specifiers and prose are computed root-relative — call sites come
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The starter route's companion files (SURF-1, audit #2). Every on-ramp shows
|
|
3
|
+
* the same starter route, `example.support_summarize` (console
|
|
4
|
+
* STARTER_ROUTE_YAML, www /get-started, quickstart §3), and that YAML references
|
|
5
|
+
* `./schemas/support_summarize.schema.json` and
|
|
6
|
+
* `./prompts/support_summarize.system.md`. Neither shipped in the npm tarball,
|
|
7
|
+
* so a customer who pasted the route got "schema file not found" from
|
|
8
|
+
* `modelrig validate`. `modelrig init` now writes both next to the routes dir
|
|
9
|
+
* (never clobbering), and `surf1-setup.test.ts` asserts these constants equal the
|
|
10
|
+
* package's own committed example files and that the starter validates.
|
|
11
|
+
*
|
|
12
|
+
* They are support files, not routes: the loader reads only top-level *.yaml,
|
|
13
|
+
* so writing them can never change what a rig serves.
|
|
14
|
+
*/
|
|
15
|
+
/** Path of each companion file, relative to the routes directory. */
|
|
16
|
+
export declare const STARTER_SCHEMA_PATH = "schemas/support_summarize.schema.json";
|
|
17
|
+
export declare const STARTER_PROMPT_PATH = "prompts/support_summarize.system.md";
|
|
18
|
+
export declare const STARTER_SCHEMA_JSON = "{\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n \"title\": \"support_summarize\",\n \"type\": \"object\",\n \"additionalProperties\": false,\n \"required\": [\"summary\", \"handoff\"],\n \"properties\": {\n \"summary\": {\n \"type\": \"string\",\n \"minLength\": 40,\n \"description\": \"One paragraph a human agent can act on without reading the thread.\"\n },\n \"severity\": { \"type\": \"string\", \"enum\": [\"low\", \"normal\", \"high\", \"urgent\"] },\n \"handoff\": {\n \"type\": \"object\",\n \"additionalProperties\": false,\n \"required\": [\"team\", \"reason\"],\n \"properties\": {\n \"team\": { \"type\": \"string\", \"enum\": [\"billing\", \"technical\", \"account\", \"none\"] },\n \"reason\": { \"type\": \"string\", \"minLength\": 10 }\n }\n }\n }\n}\n";
|
|
19
|
+
export declare const STARTER_PROMPT_MD = "You summarise a customer support ticket for the agent who picks it up next.\n\nProduct: {{product}}\n\nEarlier context on this customer (may be \"none\"):\n{{priorContext}}\n\nTicket:\n{{ticket}}\n\nWrite one actionable paragraph, judge severity, and name the team it should go\nto (or `none` if the summary closes it).\n\n{{#unless capability.structured_native}}\nReturn ONLY a JSON object matching this shape \u2014 no prose, no code fence:\n{\"summary\": string, \"severity\": \"low\"|\"normal\"|\"high\"|\"urgent\",\n \"handoff\": {\"team\": \"billing\"|\"technical\"|\"account\"|\"none\", \"reason\": string}}\n{{/unless}}\n";
|
|
20
|
+
export interface StarterFs {
|
|
21
|
+
existsSync: (p: string) => boolean;
|
|
22
|
+
mkdirSync: (p: string, o: {
|
|
23
|
+
recursive: boolean;
|
|
24
|
+
}) => void;
|
|
25
|
+
writeFileSync: (p: string, c: string, e: "utf8") => void;
|
|
26
|
+
}
|
|
27
|
+
/** Write the starter's schema and prompt under `routesDir`, leaving any file that
|
|
28
|
+
* already exists alone (it is the customer's). Returns what was written/skipped. */
|
|
29
|
+
export declare function writeStarterFiles(routesDir: string, fs: StarterFs, path: {
|
|
30
|
+
join: (...parts: string[]) => string;
|
|
31
|
+
dirname: (p: string) => string;
|
|
32
|
+
}): {
|
|
33
|
+
written: string[];
|
|
34
|
+
skipped: string[];
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=starter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"starter.d.ts","sourceRoot":"","sources":["../../src/init/starter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,qEAAqE;AACrE,eAAO,MAAM,mBAAmB,0CAA0C,CAAC;AAC3E,eAAO,MAAM,mBAAmB,wCAAwC,CAAC;AAEzE,eAAO,MAAM,mBAAmB,w2BAwB/B,CAAC;AAEF,eAAO,MAAM,iBAAiB,0nBAkB7B,CAAC;AAEF,MAAM,WAAW,SAAS;IACxB,UAAU,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC;IACnC,SAAS,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE;QAAE,SAAS,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAC;IAC1D,aAAa,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;CAC1D;AAED;oFACoF;AACpF,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,MAAM,EACjB,EAAE,EAAE,SAAS,EACb,IAAI,EAAE;IAAE,IAAI,EAAE,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,KAAK,MAAM,CAAC;IAAC,OAAO,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAA;CAAE,GAC7E;IAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,CAiB1C"}
|