chore: import upstream snapshot with attribution
Publish CLI Package / publish-npm (push) Waiting to run
Publish Python SDK / publish-pypi (push) Waiting to run
Publish TypeScript SDK / publish-npm (push) Waiting to run
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled

This commit is contained in:
wehub-resource-sync
2026-07-13 13:20:55 +08:00
commit d25d482dc2
13754 changed files with 4996608 additions and 0 deletions
+133
View File
@@ -0,0 +1,133 @@
import { generateId } from '@sim/utils/id'
import { filterUndefined } from '@sim/utils/object'
import type {
LangsmithCreateFeedbackParams,
LangsmithCreateFeedbackResponse,
} from '@/tools/langsmith/types'
import type { ToolConfig } from '@/tools/types'
export const langsmithCreateFeedbackTool: ToolConfig<
LangsmithCreateFeedbackParams,
LangsmithCreateFeedbackResponse
> = {
id: 'langsmith_create_feedback',
name: 'LangSmith Create Feedback',
description: 'Attach a score, correction, or comment to a LangSmith run.',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'LangSmith API key',
},
runId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'ID of the run to attach feedback to',
},
key: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Feedback metric name (e.g. "correctness", "user_score")',
},
score: {
type: 'number',
required: false,
visibility: 'user-or-llm',
description: 'Numeric score for the feedback metric',
},
value: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Categorical value for the feedback metric',
},
comment: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Free-text comment explaining the feedback',
},
correction: {
type: 'json',
required: false,
visibility: 'user-or-llm',
description: 'Corrected output for the run',
},
feedbackSourceType: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Origin of the feedback (api, app, or model)',
},
},
request: {
url: () => 'https://api.smith.langchain.com/feedback',
method: 'POST',
headers: (params) => ({
'X-Api-Key': params.apiKey,
'Content-Type': 'application/json',
}),
body: (params) => {
const payload: Record<string, unknown> = {
id: generateId(),
run_id: params.runId.trim(),
key: params.key,
score: params.score,
value: params.value,
comment: params.comment,
correction: params.correction,
feedback_source: params.feedbackSourceType
? { type: params.feedbackSourceType }
: undefined,
}
return filterUndefined(payload)
},
},
transformResponse: async (response) => {
if (!response.ok) {
const errorText = await response.text()
throw new Error(`LangSmith create feedback failed (${response.status}): ${errorText}`)
}
const data = (await response.json()) as Record<string, unknown>
return {
success: true,
output: {
id: data.id as string,
key: data.key as string,
runId: (data.run_id as string) ?? null,
score: (data.score as number) ?? null,
value: (data.value as string | number | boolean) ?? null,
comment: (data.comment as string) ?? null,
createdAt: (data.created_at as string) ?? null,
},
}
},
outputs: {
id: { type: 'string', description: 'Feedback ID' },
key: { type: 'string', description: 'Feedback metric name' },
runId: {
type: 'string',
description: 'ID of the run the feedback was attached to',
optional: true,
},
score: { type: 'number', description: 'Score recorded for the feedback', optional: true },
value: {
type: 'string',
description: 'Categorical value recorded for the feedback',
optional: true,
},
comment: { type: 'string', description: 'Comment recorded for the feedback', optional: true },
createdAt: {
type: 'string',
description: 'When the feedback was created (ISO)',
optional: true,
},
},
}
+187
View File
@@ -0,0 +1,187 @@
import { filterUndefined } from '@sim/utils/object'
import type { LangsmithCreateRunParams, LangsmithCreateRunResponse } from '@/tools/langsmith/types'
import { normalizeLangsmithRunPayload } from '@/tools/langsmith/utils'
import type { ToolConfig } from '@/tools/types'
export const langsmithCreateRunTool: ToolConfig<
LangsmithCreateRunParams,
LangsmithCreateRunResponse
> = {
id: 'langsmith_create_run',
name: 'LangSmith Create Run',
description: 'Forward a single run to LangSmith for ingestion.',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'LangSmith API key',
},
id: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Unique run identifier',
},
name: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Run name',
},
run_type: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Run type (tool, chain, llm, retriever, embedding, prompt, parser)',
},
start_time: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Run start time in ISO-8601 format',
},
end_time: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Run end time in ISO-8601 format',
},
inputs: {
type: 'json',
required: false,
visibility: 'user-or-llm',
description: 'Inputs payload',
},
run_outputs: {
type: 'json',
required: false,
visibility: 'user-or-llm',
description: 'Outputs payload',
},
extra: {
type: 'json',
required: false,
visibility: 'user-or-llm',
description: 'Additional metadata (extra)',
},
tags: {
type: 'json',
required: false,
visibility: 'user-or-llm',
description: 'Array of tag strings',
},
parent_run_id: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Parent run ID',
},
trace_id: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Trace ID',
},
session_id: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Session ID',
},
session_name: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Session name',
},
status: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Run status',
},
error: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Error details',
},
dotted_order: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Dotted order string',
},
events: {
type: 'json',
required: false,
visibility: 'user-or-llm',
description: 'Structured events array',
},
},
request: {
url: () => 'https://api.smith.langchain.com/runs',
method: 'POST',
headers: (params) => ({
'X-Api-Key': params.apiKey,
'Content-Type': 'application/json',
}),
body: (params) => {
const { payload } = normalizeLangsmithRunPayload(params)
const normalizedPayload: Record<string, unknown> = {
...payload,
name: payload.name?.trim(),
inputs: params.inputs,
outputs: params.run_outputs,
extra: params.extra,
tags: params.tags,
status: params.status,
error: params.error,
events: params.events,
}
return filterUndefined(normalizedPayload)
},
},
transformResponse: async (response, params) => {
const runId = params ? normalizeLangsmithRunPayload(params).runId : null
const data = (await response.json()) as Record<string, unknown>
const directMessage =
typeof (data as { message?: unknown }).message === 'string'
? (data as { message: string }).message
: null
const nestedPayload =
runId && typeof data[runId] === 'object' && data[runId] !== null
? (data[runId] as Record<string, unknown>)
: null
const nestedMessage =
nestedPayload && typeof nestedPayload.message === 'string' ? nestedPayload.message : null
return {
success: true,
output: {
accepted: true,
runId: runId ?? null,
message: directMessage ?? nestedMessage ?? null,
},
}
},
outputs: {
accepted: {
type: 'boolean',
description: 'Whether the run was accepted for ingestion',
},
runId: {
type: 'string',
description: 'Run identifier provided in the request',
optional: true,
},
message: {
type: 'string',
description: 'Response message from LangSmith',
optional: true,
},
},
}
@@ -0,0 +1,113 @@
import { filterUndefined } from '@sim/utils/object'
import type {
LangsmithCreateRunsBatchParams,
LangsmithCreateRunsBatchResponse,
LangsmithRunPayload,
} from '@/tools/langsmith/types'
import { normalizeLangsmithRunPayload } from '@/tools/langsmith/utils'
import type { ToolConfig } from '@/tools/types'
export const langsmithCreateRunsBatchTool: ToolConfig<
LangsmithCreateRunsBatchParams,
LangsmithCreateRunsBatchResponse
> = {
id: 'langsmith_create_runs_batch',
name: 'LangSmith Create Runs Batch',
description: 'Forward multiple runs to LangSmith in a single batch.',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'LangSmith API key',
},
post: {
type: 'json',
required: false,
visibility: 'user-or-llm',
description: 'Array of new runs to ingest',
},
patch: {
type: 'json',
required: false,
visibility: 'user-or-llm',
description: 'Array of runs to update/patch',
},
},
request: {
url: () => 'https://api.smith.langchain.com/runs/batch',
method: 'POST',
headers: (params) => ({
'X-Api-Key': params.apiKey,
'Content-Type': 'application/json',
}),
body: (params) => {
const payload: Record<string, unknown> = {
post: params.post
? params.post.map((run) => normalizeLangsmithRunPayload(run).payload)
: undefined,
patch: params.patch
? params.patch.map((run) => normalizeLangsmithRunPayload(run).payload)
: undefined,
}
return filterUndefined(payload)
},
},
transformResponse: async (response, params) => {
const data = (await response.json()) as Record<string, unknown>
const directMessage =
typeof (data as { message?: unknown }).message === 'string'
? (data as { message: string }).message
: null
const messages = Object.values(data)
.map((value) => {
if (typeof value !== 'object' || value === null) {
return null
}
const messageValue = (value as Record<string, unknown>).message
return typeof messageValue === 'string' ? messageValue : null
})
.filter((value): value is string => Boolean(value))
const collectRunIds = (runs?: LangsmithRunPayload[]) =>
runs?.map((run) => normalizeLangsmithRunPayload(run).runId) ?? []
return {
success: true,
output: {
accepted: true,
runIds: [...collectRunIds(params?.post), ...collectRunIds(params?.patch)],
message: directMessage ?? null,
messages: messages.length ? messages : undefined,
},
}
},
outputs: {
accepted: {
type: 'boolean',
description: 'Whether the batch was accepted for ingestion',
},
runIds: {
type: 'array',
description: 'Run identifiers provided in the request',
items: {
type: 'string',
},
},
message: {
type: 'string',
description: 'Response message from LangSmith',
optional: true,
},
messages: {
type: 'array',
description: 'Per-run response messages, when provided',
optional: true,
items: {
type: 'string',
},
},
},
}
+92
View File
@@ -0,0 +1,92 @@
import type { LangsmithGetRunParams, LangsmithGetRunResponse } from '@/tools/langsmith/types'
import type { ToolConfig } from '@/tools/types'
export const langsmithGetRunTool: ToolConfig<LangsmithGetRunParams, LangsmithGetRunResponse> = {
id: 'langsmith_get_run',
name: 'LangSmith Get Run',
description: 'Retrieve a single LangSmith run by ID.',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'LangSmith API key',
},
runId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'ID of the run to retrieve',
},
},
request: {
url: (params) => `https://api.smith.langchain.com/runs/${params.runId.trim()}`,
method: 'GET',
headers: (params) => ({
'X-Api-Key': params.apiKey,
}),
},
transformResponse: async (response) => {
if (!response.ok) {
const errorText = await response.text()
throw new Error(`LangSmith get run failed (${response.status}): ${errorText}`)
}
const data = (await response.json()) as Record<string, unknown>
return {
success: true,
output: {
id: data.id as string,
runId: data.id as string,
name: data.name as string,
runType: data.run_type as string,
status: (data.status as string) ?? null,
startTime: (data.start_time as string) ?? null,
endTime: (data.end_time as string) ?? null,
inputs: (data.inputs as Record<string, unknown>) ?? null,
outputs: (data.outputs as Record<string, unknown>) ?? null,
error: (data.error as string) ?? null,
tags: (data.tags as string[]) ?? [],
sessionId: (data.session_id as string) ?? null,
traceId: (data.trace_id as string) ?? null,
parentRunId: (data.parent_run_id as string) ?? null,
totalTokens: (data.total_tokens as number) ?? null,
totalCost: (data.total_cost as string) ?? null,
},
}
},
outputs: {
id: { type: 'string', description: 'Run ID' },
runId: {
type: 'string',
description: 'Run ID (alias of id, for consistency with other operations)',
},
name: { type: 'string', description: 'Run name' },
runType: {
type: 'string',
description: 'Run type (tool, chain, llm, retriever, embedding, prompt, parser)',
},
status: { type: 'string', description: 'Run status', optional: true },
startTime: { type: 'string', description: 'Run start time (ISO)', optional: true },
endTime: { type: 'string', description: 'Run end time (ISO)', optional: true },
inputs: { type: 'json', description: 'Run inputs payload', optional: true },
outputs: { type: 'json', description: 'Run outputs payload', optional: true },
error: { type: 'string', description: 'Error details, if the run failed', optional: true },
tags: { type: 'array', description: 'Tags attached to the run', items: { type: 'string' } },
sessionId: {
type: 'string',
description: 'Project (session) ID the run belongs to',
optional: true,
},
traceId: { type: 'string', description: 'Trace ID', optional: true },
parentRunId: { type: 'string', description: 'Parent run ID', optional: true },
totalTokens: {
type: 'number',
description: 'Total tokens consumed by the run',
optional: true,
},
totalCost: { type: 'string', description: 'Total cost of the run', optional: true },
},
}
+5
View File
@@ -0,0 +1,5 @@
export { langsmithCreateFeedbackTool } from '@/tools/langsmith/create_feedback'
export { langsmithCreateRunTool } from '@/tools/langsmith/create_run'
export { langsmithCreateRunsBatchTool } from '@/tools/langsmith/create_runs_batch'
export { langsmithGetRunTool } from '@/tools/langsmith/get_run'
export { langsmithUpdateRunTool } from '@/tools/langsmith/update_run'
+137
View File
@@ -0,0 +1,137 @@
import type { ToolResponse } from '@/tools/types'
export type LangsmithRunType =
| 'tool'
| 'chain'
| 'llm'
| 'retriever'
| 'embedding'
| 'prompt'
| 'parser'
export interface LangsmithRunPayload {
id?: string
name: string
run_type: LangsmithRunType
start_time?: string
end_time?: string
inputs?: Record<string, unknown>
outputs?: Record<string, unknown>
extra?: Record<string, unknown>
tags?: string[]
parent_run_id?: string
trace_id?: string
session_id?: string
session_name?: string
status?: string
error?: string
dotted_order?: string
events?: Record<string, unknown>[]
}
export interface LangsmithCreateRunParams extends Omit<LangsmithRunPayload, 'outputs'> {
apiKey: string
run_outputs?: Record<string, unknown>
}
export interface LangsmithCreateRunsBatchParams {
apiKey: string
post?: LangsmithRunPayload[]
patch?: LangsmithRunPayload[]
}
export interface LangsmithCreateRunResponse extends ToolResponse {
output: {
accepted: boolean
runId: string | null
message: string | null
}
}
export interface LangsmithCreateRunsBatchResponse extends ToolResponse {
output: {
accepted: boolean
runIds: string[]
message: string | null
messages?: string[]
}
}
export interface LangsmithUpdateRunParams {
apiKey: string
runId: string
name?: string
end_time?: string
outputs?: Record<string, unknown>
extra?: Record<string, unknown>
tags?: string[]
status?: string
error?: string
events?: Record<string, unknown>[]
}
export interface LangsmithUpdateRunResponse extends ToolResponse {
output: {
accepted: boolean
runId: string
message: string | null
}
}
export interface LangsmithGetRunParams {
apiKey: string
runId: string
}
export interface LangsmithGetRunResponse extends ToolResponse {
output: {
id: string
runId: string
name: string
runType: string
status: string | null
startTime: string | null
endTime: string | null
inputs: Record<string, unknown> | null
outputs: Record<string, unknown> | null
error: string | null
tags: string[]
sessionId: string | null
traceId: string | null
parentRunId: string | null
totalTokens: number | null
totalCost: string | null
}
}
export type LangsmithFeedbackSourceType = 'api' | 'app' | 'model'
export interface LangsmithCreateFeedbackParams {
apiKey: string
runId: string
key: string
score?: number
value?: string
comment?: string
correction?: Record<string, unknown>
feedbackSourceType?: LangsmithFeedbackSourceType
}
export interface LangsmithCreateFeedbackResponse extends ToolResponse {
output: {
id: string
key: string
runId: string | null
score: number | null
value: string | number | boolean | null
comment: string | null
createdAt: string | null
}
}
export type LangsmithResponse =
| LangsmithCreateRunResponse
| LangsmithCreateRunsBatchResponse
| LangsmithUpdateRunResponse
| LangsmithGetRunResponse
| LangsmithCreateFeedbackResponse
+145
View File
@@ -0,0 +1,145 @@
import { filterUndefined } from '@sim/utils/object'
import type { LangsmithUpdateRunParams, LangsmithUpdateRunResponse } from '@/tools/langsmith/types'
import type { ToolConfig } from '@/tools/types'
export const langsmithUpdateRunTool: ToolConfig<
LangsmithUpdateRunParams,
LangsmithUpdateRunResponse
> = {
id: 'langsmith_update_run',
name: 'LangSmith Update Run',
description: 'Patch an existing LangSmith run with outputs, status, or timing once it completes.',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'LangSmith API key',
},
runId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'ID of the run to update',
},
name: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Corrected run name',
},
end_time: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Run end time in ISO-8601 format',
},
outputs: {
type: 'json',
required: false,
visibility: 'user-or-llm',
description: 'Outputs payload',
},
extra: {
type: 'json',
required: false,
visibility: 'user-or-llm',
description: 'Additional metadata (extra)',
},
tags: {
type: 'json',
required: false,
visibility: 'user-or-llm',
description: 'Array of tag strings',
},
status: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Run status',
},
error: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Error details',
},
events: {
type: 'json',
required: false,
visibility: 'user-or-llm',
description: 'Structured events array',
},
},
request: {
url: (params) => `https://api.smith.langchain.com/runs/${params.runId.trim()}`,
method: 'PATCH',
headers: (params) => ({
'X-Api-Key': params.apiKey,
'Content-Type': 'application/json',
}),
body: (params) => {
const emptyToUndefined = (value?: string) => (value === '' ? undefined : value)
const payload: Record<string, unknown> = {
name: emptyToUndefined(params.name),
end_time: emptyToUndefined(params.end_time),
outputs: params.outputs,
extra: params.extra,
tags: params.tags,
status: emptyToUndefined(params.status),
error: emptyToUndefined(params.error),
events: params.events,
}
const filtered = filterUndefined(payload)
if (Object.keys(filtered).length === 0) {
throw new Error('Provide at least one field to update')
}
return filtered
},
},
transformResponse: async (response, params) => {
if (!response.ok) {
const errorText = await response.text()
throw new Error(`LangSmith update run failed (${response.status}): ${errorText}`)
}
const responseText = await response.text()
let message: string | null = null
if (responseText) {
try {
const data = JSON.parse(responseText) as Record<string, unknown>
message = typeof data.message === 'string' ? data.message : null
} catch {
// Response body isn't JSON (e.g. empty object or plain text) — no message to surface
}
}
return {
success: true,
output: {
accepted: true,
runId: params?.runId.trim() ?? '',
message,
},
}
},
outputs: {
accepted: {
type: 'boolean',
description: 'Whether the run update was accepted',
},
runId: {
type: 'string',
description: 'ID of the run that was updated',
},
message: {
type: 'string',
description: 'Response message from LangSmith, if provided',
optional: true,
},
},
}
+39
View File
@@ -0,0 +1,39 @@
import { generateId } from '@sim/utils/id'
import type { LangsmithRunPayload } from '@/tools/langsmith/types'
interface NormalizedRunPayload {
payload: LangsmithRunPayload
runId: string
}
const toCompactTimestamp = (startTime?: string): string => {
const parsed = startTime ? new Date(startTime) : new Date()
const date = Number.isNaN(parsed.getTime()) ? new Date() : parsed
const pad = (value: number, length: number) => value.toString().padStart(length, '0')
const year = date.getUTCFullYear()
const month = pad(date.getUTCMonth() + 1, 2)
const day = pad(date.getUTCDate(), 2)
const hours = pad(date.getUTCHours(), 2)
const minutes = pad(date.getUTCMinutes(), 2)
const seconds = pad(date.getUTCSeconds(), 2)
const micros = pad(date.getUTCMilliseconds() * 1000, 6)
return `${year}${month}${day}T${hours}${minutes}${seconds}${micros}`
}
export const normalizeLangsmithRunPayload = (run: LangsmithRunPayload): NormalizedRunPayload => {
const runId = run.id ?? generateId()
const traceId = run.trace_id ?? runId
const startTime = run.start_time ?? new Date().toISOString()
const dottedOrder = run.dotted_order ?? `${toCompactTimestamp(startTime)}Z${runId}`
return {
runId,
payload: {
...run,
id: runId,
trace_id: traceId,
start_time: startTime,
dotted_order: dottedOrder,
},
}
}