@pstdio/sdk 0.1.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.
Files changed (71) hide show
  1. package/dist/api/actions.d.ts +12 -0
  2. package/dist/api/agents.d.ts +1 -0
  3. package/dist/api/index.d.ts +9 -0
  4. package/dist/api/index.js +0 -0
  5. package/dist/api/projects.d.ts +1 -0
  6. package/dist/api/sessions.d.ts +1 -0
  7. package/dist/api/statuses.d.ts +1 -0
  8. package/dist/api/tags.d.ts +1 -0
  9. package/dist/api/templates.d.ts +1 -0
  10. package/dist/api/tickets.d.ts +23 -0
  11. package/dist/api/workspaces.d.ts +1 -0
  12. package/dist/client/actions.d.ts +8 -0
  13. package/dist/client/agents.d.ts +13 -0
  14. package/dist/client/client.d.ts +24 -0
  15. package/dist/client/index.d.ts +12 -0
  16. package/dist/client/index.js +215 -0
  17. package/dist/client/projects.d.ts +13 -0
  18. package/dist/client/request.d.ts +16 -0
  19. package/dist/client/sessions.d.ts +15 -0
  20. package/dist/client/skills.d.ts +8 -0
  21. package/dist/client/statuses.d.ts +22 -0
  22. package/dist/client/tags.d.ts +13 -0
  23. package/dist/client/templates.d.ts +11 -0
  24. package/dist/client/tickets.d.ts +17 -0
  25. package/dist/client/workspaces.d.ts +12 -0
  26. package/dist/hooks/attempt.d.ts +14 -0
  27. package/dist/hooks/base.d.ts +17 -0
  28. package/dist/hooks/entities.d.ts +8 -0
  29. package/dist/hooks/index.d.ts +5 -0
  30. package/dist/hooks/index.js +0 -0
  31. package/dist/hooks/session.d.ts +13 -0
  32. package/dist/hooks/ticket.d.ts +23 -0
  33. package/dist/hooks/worktree.d.ts +52 -0
  34. package/dist/plugins/define-plugin.d.ts +2 -0
  35. package/dist/plugins/helpers/context.d.ts +24 -0
  36. package/dist/plugins/helpers/create-attempt.d.ts +5 -0
  37. package/dist/plugins/helpers/create-session.d.ts +20 -0
  38. package/dist/plugins/helpers/create-workspace.d.ts +5 -0
  39. package/dist/plugins/helpers/find-ticket-by-ref.d.ts +6 -0
  40. package/dist/plugins/helpers/find-workspace-by-ref.d.ts +5 -0
  41. package/dist/plugins/helpers/followup-session.d.ts +22 -0
  42. package/dist/plugins/helpers/get-attempts-for-ticket.d.ts +17 -0
  43. package/dist/plugins/helpers/index.d.ts +15 -0
  44. package/dist/plugins/helpers/remove-all-worktrees-for-ticket.d.ts +2 -0
  45. package/dist/plugins/helpers/run-command.d.ts +9 -0
  46. package/dist/plugins/helpers/set-ticket-status.d.ts +7 -0
  47. package/dist/plugins/helpers/set-workspace-attempt-status.d.ts +7 -0
  48. package/dist/plugins/helpers/ticket-pull.d.ts +18 -0
  49. package/dist/plugins/helpers/update-ticket-when-all-attempts-match.d.ts +7 -0
  50. package/dist/plugins/helpers/workspaces-for-ticket.d.ts +17 -0
  51. package/dist/plugins/helpers/worktree-bootstrap.d.ts +8 -0
  52. package/dist/plugins/hooks.d.ts +42 -0
  53. package/dist/plugins/index.d.ts +5 -0
  54. package/dist/plugins/index.js +464 -0
  55. package/dist/plugins/types.d.ts +89 -0
  56. package/dist/prompts/index.d.ts +1 -0
  57. package/dist/prompts/index.js +6 -0
  58. package/dist/prompts/render-prompt.d.ts +1 -0
  59. package/dist/resources/agent.d.ts +1 -0
  60. package/dist/resources/file.d.ts +1 -0
  61. package/dist/resources/index.d.ts +11 -0
  62. package/dist/resources/index.js +0 -0
  63. package/dist/resources/project.d.ts +1 -0
  64. package/dist/resources/session.d.ts +1 -0
  65. package/dist/resources/skill.d.ts +1 -0
  66. package/dist/resources/status.d.ts +1 -0
  67. package/dist/resources/tag.d.ts +1 -0
  68. package/dist/resources/template.d.ts +1 -0
  69. package/dist/resources/ticket.d.ts +1 -0
  70. package/dist/resources/workspace.d.ts +1 -0
  71. package/package.json +61 -0
@@ -0,0 +1,2 @@
1
+ import type { PluginDefinition } from "./types";
2
+ export declare const definePlugin: (plugin: PluginDefinition) => PluginDefinition;
@@ -0,0 +1,24 @@
1
+ import type { BaseHookContext } from "../../hooks/base";
2
+ import type { ActionTriggerContext } from "../types";
3
+ export type PluginHelperContext = Pick<BaseHookContext, "client" | "projectId"> | ActionTriggerContext;
4
+ export type TicketRef = {
5
+ ticketId?: string;
6
+ };
7
+ export type WorkspaceRef = {
8
+ workspaceId?: string;
9
+ };
10
+ type TicketLike = {
11
+ id: string;
12
+ shorthand: string;
13
+ };
14
+ type WorkspaceLike = {
15
+ id: string;
16
+ workspace_shorthand: string;
17
+ };
18
+ export declare const firstMatch: <T extends {
19
+ id: string;
20
+ }>(values: T[], ref: string | undefined, readName: (value: T) => string) => T | null;
21
+ export declare const readTicketFromContext: (ctx: PluginHelperContext, ref: string | undefined) => TicketLike | null;
22
+ export declare const readWorkspaceFromContext: (ctx: PluginHelperContext, ref: string | undefined) => WorkspaceLike | null;
23
+ export declare const resolveSessionIdFromContext: (ctx: PluginHelperContext) => string | null;
24
+ export {};
@@ -0,0 +1,5 @@
1
+ import type { CreateTicketAttemptInput } from "../../api/tickets";
2
+ import type { PluginHelperContext, TicketRef } from "./context";
3
+ type CreateAttemptHelperInput = TicketRef & Omit<CreateTicketAttemptInput, "start_session">;
4
+ export declare const createAttempt: (ctx: PluginHelperContext, input: CreateAttemptHelperInput) => Promise<import("../../api").TicketAttemptResponse | null>;
5
+ export {};
@@ -0,0 +1,20 @@
1
+ import type { CreateSessionInput } from "../../api/sessions";
2
+ import type { PluginHelperContext } from "./context";
3
+ type CreateSessionHelperInput = Omit<CreateSessionInput, "project_id">;
4
+ export declare const createSession: (ctx: PluginHelperContext, input: CreateSessionHelperInput) => Promise<{
5
+ id: string;
6
+ project_id: string | null;
7
+ title: string;
8
+ status: "in_progress" | "awaiting_input" | "completed" | "failed" | "cancelled";
9
+ archived: boolean;
10
+ last_request_started: string | null;
11
+ last_request_ended: string | null;
12
+ agent: string | null;
13
+ agent_session_id: string | null;
14
+ session_file_id: string | null;
15
+ original_session_id: string | null;
16
+ cwd: string | null;
17
+ created_at: string;
18
+ updated_at: string;
19
+ }>;
20
+ export {};
@@ -0,0 +1,5 @@
1
+ import type { CreateTicketAttemptInput } from "../../api/tickets";
2
+ import type { PluginHelperContext, TicketRef } from "./context";
3
+ type CreateWorkspaceHelperInput = TicketRef & Omit<CreateTicketAttemptInput, "agent" | "model" | "prompt" | "start_session">;
4
+ export declare const createWorkspace: (ctx: PluginHelperContext, input: CreateWorkspaceHelperInput) => Promise<import("../../api").TicketAttemptResponse | null>;
5
+ export {};
@@ -0,0 +1,6 @@
1
+ import { type PluginHelperContext, type TicketRef } from "./context";
2
+ export declare const findTicketByRef: (ctx: PluginHelperContext, input: TicketRef) => Promise<{
3
+ id: string;
4
+ shorthand: string;
5
+ } | null>;
6
+ export declare const resolveTicketShorthand: (ctx: PluginHelperContext, input: TicketRef) => Promise<string | null>;
@@ -0,0 +1,5 @@
1
+ import { type PluginHelperContext, type WorkspaceRef } from "./context";
2
+ export declare const findWorkspaceByRef: (ctx: PluginHelperContext, input: WorkspaceRef) => Promise<{
3
+ id: string;
4
+ workspace_shorthand: string;
5
+ } | null>;
@@ -0,0 +1,22 @@
1
+ import type { FollowUpInput } from "../../api/sessions";
2
+ import { type PluginHelperContext } from "./context";
3
+ type FollowupSessionHelperInput = FollowUpInput & {
4
+ sessionId?: string;
5
+ };
6
+ export declare const followupSession: (ctx: PluginHelperContext, input: FollowupSessionHelperInput) => Promise<{
7
+ id: string;
8
+ project_id: string | null;
9
+ title: string;
10
+ status: "in_progress" | "awaiting_input" | "completed" | "failed" | "cancelled";
11
+ archived: boolean;
12
+ last_request_started: string | null;
13
+ last_request_ended: string | null;
14
+ agent: string | null;
15
+ agent_session_id: string | null;
16
+ session_file_id: string | null;
17
+ original_session_id: string | null;
18
+ cwd: string | null;
19
+ created_at: string;
20
+ updated_at: string;
21
+ }>;
22
+ export {};
@@ -0,0 +1,17 @@
1
+ import type { PluginHelperContext, TicketRef } from "./context";
2
+ export declare const getAttemptsForTicket: (ctx: PluginHelperContext, input: TicketRef) => Promise<{
3
+ id: string;
4
+ project_id: string;
5
+ name: string;
6
+ branch: string | null;
7
+ worktree_path: string | null;
8
+ attempt_status_id: string | null;
9
+ archived: boolean;
10
+ workspace_shorthand: string;
11
+ startup_log_file_id: string | null;
12
+ created_at: string;
13
+ updated_at: string;
14
+ deleted_at: string | null;
15
+ ticket_shorthand: string;
16
+ attempt_status_name: string | null;
17
+ }[]>;
@@ -0,0 +1,15 @@
1
+ export { createAttempt } from "./create-attempt";
2
+ export { createSession } from "./create-session";
3
+ export { createWorkspace } from "./create-workspace";
4
+ export { findTicketByRef } from "./find-ticket-by-ref";
5
+ export { findWorkspaceByRef } from "./find-workspace-by-ref";
6
+ export { followupSession } from "./followup-session";
7
+ export { getAttemptsForTicket } from "./get-attempts-for-ticket";
8
+ export { removeAllWorktreesForTicket } from "./remove-all-worktrees-for-ticket";
9
+ export { runCommand } from "./run-command";
10
+ export { setTicketStatus } from "./set-ticket-status";
11
+ export { setWorkspaceAttemptStatus } from "./set-workspace-attempt-status";
12
+ export { type PullTicketsInput, type PullTicketsResult, pullTickets } from "./ticket-pull";
13
+ export { updateTicketWhenAllAttemptsMatch } from "./update-ticket-when-all-attempts-match";
14
+ export { workspacesForTicket } from "./workspaces-for-ticket";
15
+ export { bootstrapWorktree } from "./worktree-bootstrap";
@@ -0,0 +1,2 @@
1
+ import type { PluginHelperContext, TicketRef } from "./context";
2
+ export declare const removeAllWorktreesForTicket: (ctx: PluginHelperContext, input: TicketRef) => Promise<number>;
@@ -0,0 +1,9 @@
1
+ type CommandOutputOptions = {
2
+ quiet?: boolean;
3
+ };
4
+ export declare const runCommand: (cwd: string, command: string[], options?: CommandOutputOptions) => Promise<{
5
+ exitCode: number;
6
+ stdout: string;
7
+ stderr: string;
8
+ }>;
9
+ export {};
@@ -0,0 +1,7 @@
1
+ import type { PluginHelperContext } from "./context";
2
+ type TicketStatusUpdateInput = {
3
+ ticket: string;
4
+ status: string;
5
+ };
6
+ export declare const setTicketStatus: (ctx: PluginHelperContext, input: TicketStatusUpdateInput) => Promise<boolean>;
7
+ export {};
@@ -0,0 +1,7 @@
1
+ import type { PluginHelperContext, WorkspaceRef } from "./context";
2
+ type WorkspaceAttemptStatusInput = WorkspaceRef & {
3
+ statusName: string;
4
+ sessionId?: string;
5
+ };
6
+ export declare const setWorkspaceAttemptStatus: (ctx: PluginHelperContext, input: WorkspaceAttemptStatusInput) => Promise<boolean>;
7
+ export {};
@@ -0,0 +1,18 @@
1
+ import type { PluginHelperContext } from "./context";
2
+ type TicketPullRef = {
3
+ ticketId?: string;
4
+ };
5
+ type PullTicketsInput = TicketPullRef & {
6
+ rootPath: string;
7
+ force?: boolean;
8
+ log?: (message: string) => void;
9
+ };
10
+ type PullTicketsResult = {
11
+ pulledTicketShorthands: string[];
12
+ downloadedFileCount: number;
13
+ };
14
+ export declare const pullTickets: (ctx: PluginHelperContext, input: PullTicketsInput) => Promise<{
15
+ pulledTicketShorthands: string[];
16
+ downloadedFileCount: number;
17
+ }>;
18
+ export type { PullTicketsInput, PullTicketsResult };
@@ -0,0 +1,7 @@
1
+ import type { PluginHelperContext, TicketRef } from "./context";
2
+ type TicketAttemptStatusTransitionInput = TicketRef & {
3
+ allAttemptsStatus: string;
4
+ setStatus: string;
5
+ };
6
+ export declare const updateTicketWhenAllAttemptsMatch: (ctx: PluginHelperContext, input: TicketAttemptStatusTransitionInput) => Promise<boolean>;
7
+ export {};
@@ -0,0 +1,17 @@
1
+ import type { PluginHelperContext, TicketRef } from "./context";
2
+ export declare const workspacesForTicket: (ctx: PluginHelperContext, input: TicketRef) => Promise<{
3
+ id: string;
4
+ project_id: string;
5
+ name: string;
6
+ branch: string | null;
7
+ worktree_path: string | null;
8
+ attempt_status_id: string | null;
9
+ archived: boolean;
10
+ workspace_shorthand: string;
11
+ startup_log_file_id: string | null;
12
+ created_at: string;
13
+ updated_at: string;
14
+ deleted_at: string | null;
15
+ ticket_shorthand: string;
16
+ attempt_status_name: string | null;
17
+ }[]>;
@@ -0,0 +1,8 @@
1
+ import type { PluginHelperContext } from "./context";
2
+ type BootstrapWorktreeInput = {
3
+ repoPath: string;
4
+ worktreePath: string;
5
+ ticketId?: string;
6
+ };
7
+ export declare const bootstrapWorktree: (ctx: PluginHelperContext, input: BootstrapWorktreeInput) => Promise<void>;
8
+ export {};
@@ -0,0 +1,42 @@
1
+ import type { AttemptStatusChangeContext } from "../hooks/attempt";
2
+ import type { SessionHookContext } from "../hooks/session";
3
+ import type { TicketContext, TicketCreationContext, TicketStatusChangeContext } from "../hooks/ticket";
4
+ import type { CommitContext, ConflictContext, MergeContext, RebaseContext, WorktreeContext, WorktreeCreateContext, WorktreeRemoveContext } from "../hooks/worktree";
5
+ export type HookResponse = {
6
+ reject?: boolean;
7
+ reason?: string;
8
+ data?: Record<string, unknown>;
9
+ };
10
+ export type PreHookReturn = HookResponse | undefined | Promise<HookResponse | undefined>;
11
+ export type PostHookReturn = void | Promise<void>;
12
+ export type PrePluginHooks = {
13
+ preTicketCreation?: (ctx: TicketCreationContext) => PreHookReturn;
14
+ preTicketStatusChange?: (ctx: TicketStatusChangeContext) => PreHookReturn;
15
+ preTicketArchive?: (ctx: TicketContext) => PreHookReturn;
16
+ preTicketDeletion?: (ctx: TicketContext) => PreHookReturn;
17
+ preWorktreeCreate?: (ctx: WorktreeCreateContext) => PreHookReturn;
18
+ preWorktreeRemove?: (ctx: WorktreeRemoveContext) => PreHookReturn;
19
+ preCommit?: (ctx: CommitContext) => PreHookReturn;
20
+ preRebase?: (ctx: RebaseContext) => PreHookReturn;
21
+ preMerge?: (ctx: MergeContext) => PreHookReturn;
22
+ preAttemptStatusChange?: (ctx: AttemptStatusChangeContext) => PreHookReturn;
23
+ };
24
+ export type PostPluginHooks = {
25
+ postTicketCreation?: (ctx: TicketContext) => PostHookReturn;
26
+ postTicketStatusChange?: (ctx: TicketStatusChangeContext) => PostHookReturn;
27
+ postTicketArchive?: (ctx: TicketContext) => PostHookReturn;
28
+ postTicketDeletion?: (ctx: TicketContext) => PostHookReturn;
29
+ postSessionStart?: (ctx: SessionHookContext) => PostHookReturn;
30
+ postSessionSuccess?: (ctx: SessionHookContext) => PostHookReturn;
31
+ postSessionFail?: (ctx: SessionHookContext) => PostHookReturn;
32
+ postSessionResume?: (ctx: SessionHookContext) => PostHookReturn;
33
+ postSessionAwaitInput?: (ctx: SessionHookContext) => PostHookReturn;
34
+ postWorktreeCreate?: (ctx: WorktreeContext) => PostHookReturn;
35
+ postWorktreeRemove?: (ctx: WorktreeRemoveContext) => PostHookReturn;
36
+ postCommit?: (ctx: CommitContext) => PostHookReturn;
37
+ postRebase?: (ctx: RebaseContext) => PostHookReturn;
38
+ postMerge?: (ctx: MergeContext) => PostHookReturn;
39
+ onConflict?: (ctx: ConflictContext) => PostHookReturn;
40
+ postAttemptStatusChange?: (ctx: AttemptStatusChangeContext) => PostHookReturn;
41
+ };
42
+ export type PluginHooks = PrePluginHooks & PostPluginHooks;
@@ -0,0 +1,5 @@
1
+ export { renderPrompt } from "../prompts";
2
+ export { definePlugin } from "./define-plugin";
3
+ export { bootstrapWorktree, createAttempt, createSession, createWorkspace, findTicketByRef, findWorkspaceByRef, followupSession, getAttemptsForTicket, type PullTicketsInput, type PullTicketsResult, pullTickets, removeAllWorktreesForTicket, runCommand, setTicketStatus, setWorkspaceAttemptStatus, updateTicketWhenAllAttemptsMatch, workspacesForTicket, } from "./helpers";
4
+ export type { HookResponse, PluginHooks, PostHookReturn, PostPluginHooks, PreHookReturn, PrePluginHooks, } from "./hooks";
5
+ export type { ActionDefinition, ActionDescriptor, ActionInput, ActionParamDef, ActionParamValue, ActionPlacement, ActionTargetMap, ActionTriggerContext, AgentActionParam, AgentParamValue, LongTextActionParam, PluginDefinition, RepoActionParam, RepoParamValue, SelectActionParam, TargetType, TemplateSelectActionParam, TextActionParam, } from "./types";