mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 10:21:52 +00:00
* add documentation for ai agents * docs: consolidate CLAUDE.md and CONTRIBUTING.md, add style guidelines - Refactor CLAUDE.md to reference CONTRIBUTING.md for build/test/format info - Expand CONTRIBUTING.md with comprehensive build targets, env vars, and testing - Add code style guidelines section with conventional commits - Standardize SDK prettier config to use single quotes (matching web) - Add project-level Claude Code settings to disable co-author attribution * style(sdk): apply prettier with single quotes Run prettier across sdk/base and sdk/package to apply the standardized quote style (single quotes matching web). * docs: add USER.md for per-developer TODO filtering - Add agents/USER.md to .gitignore (contains user identifier) - Document session startup flow in CLAUDE.md: - Create USER.md if missing, prompting for identifier - Filter TODOs by @username tags - Offer relevant TODOs on session start * docs: add i18n documentation task to agent TODOs * docs: document i18n ID patterns in core/ Add agents/i18n-patterns.md covering rust-i18n setup, translation file format, t!() macro usage, key naming conventions, and locale selection. Remove completed TODO item and add reference in CLAUDE.md. * chore: clarify that all builds work on any OS with Docker
97 lines
2.6 KiB
TypeScript
97 lines
2.6 KiB
TypeScript
import * as T from '../types'
|
|
import * as IST from '../actions/input/inputSpecTypes'
|
|
import { Action, ActionInfo } from './setupActions'
|
|
import { ExtractInputSpecType } from './input/builder/inputSpec'
|
|
|
|
export type RunActionInput<Input> =
|
|
| Input
|
|
| ((prev?: { spec: IST.InputSpec; value: Input | null }) => Input)
|
|
|
|
export const runAction = async <
|
|
Input extends Record<string, unknown>,
|
|
>(options: {
|
|
effects: T.Effects
|
|
// packageId?: T.PackageId
|
|
actionId: T.ActionId
|
|
input?: RunActionInput<Input>
|
|
}) => {
|
|
if (options.input) {
|
|
if (options.input instanceof Function) {
|
|
const prev = await options.effects.action.getInput({
|
|
// packageId: options.packageId,
|
|
actionId: options.actionId,
|
|
})
|
|
const input = options.input(
|
|
prev
|
|
? { spec: prev.spec as IST.InputSpec, value: prev.value as Input }
|
|
: undefined,
|
|
)
|
|
return options.effects.action.run({
|
|
// packageId: options.packageId,
|
|
actionId: options.actionId,
|
|
input,
|
|
})
|
|
} else {
|
|
return options.effects.action.run({
|
|
// packageId: options.packageId,
|
|
actionId: options.actionId,
|
|
input: options.input,
|
|
})
|
|
}
|
|
} else {
|
|
return options.effects.action.run({
|
|
// packageId: options.packageId,
|
|
actionId: options.actionId,
|
|
})
|
|
}
|
|
}
|
|
type GetActionInputType<A extends ActionInfo<T.ActionId, any>> =
|
|
A extends Action<T.ActionId, infer I> ? I : never
|
|
|
|
type TaskBase = {
|
|
reason?: string
|
|
replayId?: string
|
|
}
|
|
type TaskInput<T extends ActionInfo<T.ActionId, any>> = {
|
|
kind: 'partial'
|
|
value: T.DeepPartial<GetActionInputType<T>>
|
|
}
|
|
export type TaskOptions<T extends ActionInfo<T.ActionId, any>> = TaskBase &
|
|
(
|
|
| {
|
|
when?: Exclude<T.TaskTrigger, { condition: 'input-not-matches' }>
|
|
input?: TaskInput<T>
|
|
}
|
|
| {
|
|
when: T.TaskTrigger & { condition: 'input-not-matches' }
|
|
input: TaskInput<T>
|
|
}
|
|
)
|
|
|
|
const _validate: T.Task = {} as TaskOptions<any> & {
|
|
actionId: string
|
|
packageId: string
|
|
severity: T.TaskSeverity
|
|
}
|
|
|
|
export const createTask = <T extends ActionInfo<T.ActionId, any>>(options: {
|
|
effects: T.Effects
|
|
packageId: T.PackageId
|
|
action: T
|
|
severity: T.TaskSeverity
|
|
options?: TaskOptions<T>
|
|
}) => {
|
|
const request = options.options || {}
|
|
const actionId = options.action.id
|
|
const req = {
|
|
...request,
|
|
actionId,
|
|
packageId: options.packageId,
|
|
action: undefined,
|
|
severity: options.severity,
|
|
replayId: request.replayId || `${options.packageId}:${actionId}`,
|
|
}
|
|
delete req.action
|
|
return options.effects.action.createTask(req)
|
|
}
|