Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ inputs:
required: false

agent-version:
description: 'The version of the Agent. Must be a semver string (e.g., "2.0.65") or a SHA.'
required: true
description: 'For npm/pip agents, pins the installed package version (e.g., "2.1.123"). Not used for git or object agents.'
required: false

# Git source inputs
git-repository:
description: 'Git repository URL (optional override, defaults to current repository)'
required: false

git-ref:
description: 'Git ref (branch/tag/commit SHA). Defaults to current commit or release tag'
description: 'Git ref (branch or tag). Defaults to current ref or release tag'
required: false

# NPM source inputs
Expand Down
29 changes: 7 additions & 22 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions src/agent-deployer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ async function deployGitAgent(
const agent = await client.api.post<unknown, AgentResponse>('/v1/agents', {
body: {
name: agentName,
version: inputs.agentVersion,
...(inputs.agentVersion && { version: inputs.agentVersion }),
...(inputs.isPublic !== undefined && { is_public: inputs.isPublic }),
source: {
type: 'git',
Expand Down Expand Up @@ -139,7 +139,7 @@ async function deployTarAgent(
const agent = await client.api.post<unknown, AgentResponse>('/v1/agents', {
body: {
name: agentName,
version: inputs.agentVersion,
...(inputs.agentVersion && { version: inputs.agentVersion }),
...(inputs.isPublic !== undefined && { is_public: inputs.isPublic }),
source: {
type: 'object',
Expand Down Expand Up @@ -188,7 +188,7 @@ async function deployFileAgent(
const agent = await client.api.post<unknown, AgentResponse>('/v1/agents', {
body: {
name: agentName,
version: inputs.agentVersion,
...(inputs.agentVersion && { version: inputs.agentVersion }),
...(inputs.isPublic !== undefined && { is_public: inputs.isPublic }),
source: {
type: 'object',
Expand Down Expand Up @@ -234,7 +234,7 @@ async function deployNpmAgent(
const agent = await client.api.post<unknown, AgentResponse>('/v1/agents', {
body: {
name: agentName,
version: inputs.agentVersion,
...(inputs.agentVersion && { version: inputs.agentVersion }),
...(inputs.isPublic !== undefined && { is_public: inputs.isPublic }),
source: {
type: 'npm',
Expand Down Expand Up @@ -276,7 +276,7 @@ async function deployPipAgent(
const agent = await client.api.post<unknown, AgentResponse>('/v1/agents', {
body: {
name: agentName,
version: inputs.agentVersion,
...(inputs.agentVersion && { version: inputs.agentVersion }),
...(inputs.isPublic !== undefined && { is_public: inputs.isPublic }),
source: {
type: 'pip',
Expand Down
29 changes: 3 additions & 26 deletions src/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export interface ActionInputs {
apiKey: string;
sourceType: SourceType;
agentName?: string;
agentVersion: string;
agentVersion?: string;
gitRepository?: string;
gitRef?: string;
path?: string;
Expand Down Expand Up @@ -36,7 +36,7 @@ export function getInputs(): ActionInputs {
apiKey: core.getInput('api-key', { required: true }),
sourceType,
agentName: core.getInput('agent-name') || undefined,
agentVersion: core.getInput('agent-version', { required: true }),
agentVersion: core.getInput('agent-version') || undefined,
gitRepository: core.getInput('git-repository') || undefined,
gitRef: core.getInput('git-ref') || undefined,
path: core.getInput('path') || undefined,
Expand All @@ -57,7 +57,7 @@ export function getInputs(): ActionInputs {

// Hidden: if called from runloopai/runloop, set is_public based on "public:" version prefix
const { owner, repo } = github.context.repo;
if (owner === 'runloopai' && repo === 'runloop') {
if (owner === 'runloopai' && repo === 'runloop' && inputs.agentVersion) {
if (inputs.agentVersion.startsWith('public:')) {
inputs.agentVersion = inputs.agentVersion.slice('public:'.length);
inputs.isPublic = true;
Expand Down Expand Up @@ -132,9 +132,6 @@ export function validateInputs(inputs: ActionInputs): void {
throw new Error('api-key cannot be empty');
}

// Validate agentVersion format (semver or SHA)
validateAgentVersion(inputs.agentVersion);

// Validate objectTtlDays if provided
if (inputs.objectTtlDays !== undefined) {
if (isNaN(inputs.objectTtlDays) || inputs.objectTtlDays <= 0) {
Expand Down Expand Up @@ -170,23 +167,3 @@ export function resolvePath(inputPath: string): string {

return path.isAbsolute(inputPath) ? inputPath : path.join(workspace, inputPath);
}

// Semver pattern: major.minor.patch with optional pre-release and build metadata
const SEMVER_REGEX = /^\d+\.\d+\.\d+(-[\w.-]+)?(\+[\w.-]+)?$/;

// Git SHA pattern: 7-40 hex characters (short or full SHA)
const SHA_REGEX = /^[a-f0-9]{7,40}$/i;

function validateAgentVersion(version: string): void {
if (!version || version.trim().length === 0) {
throw new Error('agent-version cannot be empty');
}

const trimmed = version.trim();

if (!SEMVER_REGEX.test(trimmed) && !SHA_REGEX.test(trimmed)) {
throw new Error(
`Invalid agent-version: "${version}". Must be a semver string (e.g., "2.0.65") or a git SHA (7-40 hex characters).`
);
}
}
Loading