@prismshadow/penguin-server 0.1.2 → 0.1.4

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.
@@ -186,6 +186,13 @@ interface ModelsResponse {
186
186
  defaultModel?: ModelRefDto;
187
187
  /** Vision model used as a proxy reader for read_image (describes images when the session model has vision=false). */
188
188
  visionModel?: ModelRefDto;
189
+ /**
190
+ * When the Project's model/credential config last changed (ISO; the config file's mtime,
191
+ * so it survives restarts). The web's auth-dead gate compares it against the last auth
192
+ * abort: an abort OLDER than the last credential update no longer disables the composer
193
+ * (the key was fixed since). Absent when the Project has no config file yet.
194
+ */
195
+ updatedAt?: string;
189
196
  models: ModelInfo[];
190
197
  }
191
198
  /** PUT full-table replace semantics: models not present are deleted; omitting apiKey = keep existing value. Key = (provider, modelId). */
@@ -467,9 +474,41 @@ interface SessionPatchRequest {
467
474
  /** Manual rename; non-empty string, overrides the auto-generated title. */
468
475
  title?: string;
469
476
  }
477
+ /**
478
+ * Live in-progress tail of a running Session, carried by `MessagesResponse.live`.
479
+ *
480
+ * Contract (see runtime/live-tail.ts and the GET /messages route): the server captures
481
+ * `cursor` and `fragments` atomically — in one synchronous tick, before starting the
482
+ * trace read — while the Session is running/compacting.
483
+ * - `cursor`: the Session channel's most recently assigned SSE event id
484
+ * (`<epoch>-<seq>`); every event published up to and including this id is already
485
+ * reflected in `fragments`.
486
+ * - `fragments`: one synthetic `partial_* start` OmniMessage per open streaming
487
+ * fragment, whose payload carries the full accumulated content so far (text/thinking
488
+ * prefix, tool-call name + accumulated arguments, tool-output prefix + images), with
489
+ * the original `origin` chain preserved.
490
+ *
491
+ * Client usage (the bundled Web App's connect-first flow): after applying `messages`,
492
+ * when the cursor's epoch matches the epoch of the SSE events seen on the current
493
+ * connection, drop every buffered **partial** event with seq <= cursor (its content is
494
+ * already inside `fragments`), feed `fragments` through the normal reducer path, then
495
+ * replay the rest of the buffer. Buffered **complete** messages are never dropped by the
496
+ * cursor — the regular overlap dedup decides for them — so nothing is lost even when a
497
+ * complete message's trace append is still in flight at read time.
498
+ */
499
+ interface MessagesLiveTail {
500
+ cursor: string;
501
+ fragments: OmniMessage[];
502
+ }
470
503
  /** Message history: the full messages and events from concatenating all of this Session's Trace files in order (excludes partial_*). */
471
504
  interface MessagesResponse {
472
505
  messages: OmniMessage[];
506
+ /**
507
+ * Present only while the Session is running/compacting: the in-progress stream tail
508
+ * (open streaming fragments + the channel cursor they cover), so a client joining
509
+ * mid-stream can render the currently streaming message. Omitted when idle.
510
+ */
511
+ live?: MessagesLiveTail;
473
512
  }
474
513
  /**
475
514
  * A single Prompt's input parts: text or image (data: / http(s) URL).
@@ -497,6 +536,29 @@ interface TaskCreateRequest {
497
536
  * (in queue order, one at a time). The response then carries `queued: true`.
498
537
  */
499
538
  queueIfBusy?: boolean;
539
+ /**
540
+ * Present = goal mode: the input's text becomes the objective (leading `[use_skills]`
541
+ * blocks and the like are stripped from the recorded objective; the round-1 message keeps
542
+ * them) and the server loops the Session until the goal reaches a terminal state.
543
+ * `budget` is the token budget (uncached input + output); omitted or -1 = unlimited.
544
+ */
545
+ goal?: {
546
+ budget?: number;
547
+ };
548
+ }
549
+ /** Goal-mode run state (from goal_state; the chat page's banner restores from the latest row). */
550
+ interface GoalStateView {
551
+ objective: string;
552
+ status: "active" | "complete" | "blocked" | "budget_limited" | "aborted";
553
+ /** Token budget; -1 = unlimited. */
554
+ budget: number;
555
+ used: number;
556
+ rounds: number;
557
+ updatedAt: string;
558
+ }
559
+ interface GoalResponse {
560
+ /** The Session's most recent goal run; null if it never ran one. */
561
+ goal: GoalStateView | null;
500
562
  }
501
563
  interface TaskCreateResponse {
502
564
  /** Current actual session_id: a Trace-less invalid Session self-heals and returns a new id; the frontend updates its route accordingly. */
@@ -517,6 +579,15 @@ interface SteerRequest {
517
579
  interface ApprovalDecisionRequest {
518
580
  decision: "allow" | "deny";
519
581
  }
582
+ /**
583
+ * POST /api/sessions/:sessionId/retry-now — skip the in-progress reconnect backoff and
584
+ * fire the next retry immediately (the "retry now" button on the reconnect countdown).
585
+ * `skipped: false` is the benign "no reconnect wait in progress" case (idle session, or
586
+ * the wait elapsed in a timing race), not an error.
587
+ */
588
+ interface RetryNowResponse {
589
+ skipped: boolean;
590
+ }
520
591
  /** Docs: /docs/server-api § "Streaming (SSE)". */
521
592
  type ServerEvent =
522
593
  /**
@@ -544,6 +615,16 @@ type ServerEvent =
544
615
  | {
545
616
  type: "resync_required";
546
617
  }
618
+ /**
619
+ * The Project's model credentials changed (PUT /models): cached runtimes have been
620
+ * invalidated server-side, so an auth-dead Session can continue — the frontend clears
621
+ * its auth-dead composer state immediately. Published to every existing Session channel
622
+ * of the Project; tabs without a live channel learn the same fact from the models
623
+ * response's `updatedAt` on their next load.
624
+ */
625
+ | {
626
+ type: "credentials_updated";
627
+ }
547
628
  /** Placeholder handshake on the user channel (reserved for automated task notifications). */
548
629
  | {
549
630
  type: "hello";
@@ -555,7 +636,32 @@ type ServerEvent =
555
636
  agentId: string;
556
637
  sessionId: string;
557
638
  source: SessionSource;
558
- } | ScheduleServerEvent;
639
+ } | ScheduleServerEvent | GoalServerEvent;
640
+ /** Goal-mode progress on the session channel (the chat page drives its goal banner from these). */
641
+ type GoalServerEvent =
642
+ /** A goal run began (published before the first round). */
643
+ {
644
+ type: "goal_started";
645
+ sessionId: string;
646
+ objective: string;
647
+ budget: number;
648
+ }
649
+ /** A round is starting; `used` is the runner's accounting up to this point. */
650
+ | {
651
+ type: "goal_round";
652
+ sessionId: string;
653
+ round: number;
654
+ used: number;
655
+ budget: number;
656
+ }
657
+ /** The goal reached a terminal state. */
658
+ | {
659
+ type: "goal_finished";
660
+ sessionId: string;
661
+ outcome: "complete" | "blocked" | "budget_limited" | "aborted";
662
+ rounds: number;
663
+ used: number;
664
+ };
559
665
  /** Schedule notification (user-level event stream; firing and delivery are notified via /api/events). */
560
666
  type ScheduleServerEvent =
561
667
  /** Fired and sent (sessionId is the session that received the Prompt; a new session under new-Session mode). */
@@ -790,6 +896,18 @@ interface AgentTraceDateGroup {
790
896
  interface AgentTracesResponse {
791
897
  dates: AgentTraceDateGroup[];
792
898
  }
899
+ interface TraceImportRequest {
900
+ /** Base64 of the Trace file content (JSON Lines; the first record must be `session_meta`). */
901
+ dataBase64: string;
902
+ }
903
+ interface TraceImportResponse {
904
+ /** Session id taken from the imported file's `session_meta`. */
905
+ sessionId: string;
906
+ /** Allocated file index: always 1 — an import creates a new Session (a duplicate session id is rejected with 409 `trace_session_exists`). */
907
+ index: number;
908
+ /** Date directory the file landed in (local yyyy-mm-dd from the first record's timestamp, matching the Trace Writer's convention). */
909
+ date: string;
910
+ }
793
911
  type UsageGroupBy = "date" | "agent" | "model" | "session";
794
912
  interface UsageBucket {
795
913
  total: number;
@@ -1045,5 +1163,53 @@ interface AgentSkillsResponse {
1045
1163
  interface SkillInstallRequest {
1046
1164
  names: string[];
1047
1165
  }
1166
+ /** GET /api/version: the running server's release identity (from core's VERSION / BUILD_DATE). */
1167
+ interface VersionResponse {
1168
+ version: string;
1169
+ /**
1170
+ * The **running** version's release date (UTC yyyy-mm-dd), stamped into core's
1171
+ * BUILD_DATE at build time by the release workflow — the web's "last updated" date
1172
+ * needs no network. Null for a dev/source build and for releases that predate the
1173
+ * stamping (v0.1.2 and earlier): the UI then shows the version alone.
1174
+ */
1175
+ buildDate: string | null;
1176
+ }
1177
+ /**
1178
+ * GET /api/version/update-check: newest published release vs the running version.
1179
+ * Always HTTP 200 (fail-soft): a lookup failure sets `error` and leaves `latestVersion`
1180
+ * null rather than failing the request; results are cached server-side.
1181
+ */
1182
+ interface UpdateCheckResponse {
1183
+ currentVersion: string;
1184
+ /** Same as VersionResponse.buildDate: the running version's release date, stamped at build time. */
1185
+ buildDate: string | null;
1186
+ /** Newest published release (normalized, no leading `v`); null when the lookup failed or checks are disabled. */
1187
+ latestVersion: string | null;
1188
+ updateAvailable: boolean;
1189
+ /** Release page of the newest release (for the "release notes" link). */
1190
+ releaseUrl: string | null;
1191
+ /** Publish timestamp of the newest release (ISO 8601). */
1192
+ publishedAt: string | null;
1193
+ /** When this result was produced (ISO 8601) — a cached result keeps its original timestamp. */
1194
+ checkedAt: string;
1195
+ /** Present (true) when update checks are turned off via PENGUIN_UPDATE_CHECK=off; no network call was made. */
1196
+ disabled?: true;
1197
+ /** Why the lookup failed: unreachable network / GitHub rate limit / unusable response. */
1198
+ error?: "network" | "rate_limited" | "bad_response";
1199
+ }
1200
+ /**
1201
+ * POST /api/version/update (admin only): runs the CLI self-update (`penguin update --yes`)
1202
+ * on the server host. `unsupported` covers both a server not launched via the CLI and the
1203
+ * CLI's own refusals (source checkout, unrecognized install layout, Windows).
1204
+ */
1205
+ interface UpdateRunResponse {
1206
+ status: "updated" | "failed" | "unsupported";
1207
+ /** Set when the server cannot run the CLI at all (started without `penguin server|web`). */
1208
+ reason?: "not_launched_via_cli";
1209
+ /** Tail of the update command's combined stdout+stderr (capped; empty when nothing ran). */
1210
+ output: string;
1211
+ /** True when the install changed (or was already current): restart the service to run the new version. */
1212
+ needsRestart: boolean;
1213
+ }
1048
1214
 
1049
- export type { AdminPasswordResetRequest, AdminUserCreateRequest, AdminUserCreateResponse, AdminUsersResponse, AgentCompactionConfigDto, AgentConfigDto, AgentConfigResponse, AgentConfigUpdateRequest, AgentCreateRequest, AgentCreateResponse, AgentImportRequest, AgentImportResponse, AgentModelConfigDto, AgentSkillsResponse, AgentSummary, AgentTraceDateGroup, AgentTraceFileRef, AgentTraceSessionGroup, AgentTracesResponse, AgentsResponse, ApprovalDecisionRequest, ApprovalMode, AuthLoginRequest, AuthResponse, BenchmarkCaseScore, BenchmarkEvaluation, BenchmarkRunScore, BenchmarkSummary, BenchmarksResponse, CredentialInfo, DirEntryInfo, DirListResponse, ErrorBody, FilesStatRequest, FilesStatResponse, MeResponse, MemberAddRequest, MemberAddResponse, MemberInfo, MembersResponse, MessagesResponse, ModelInfo, ModelPricingDto, ModelRefDto, ModelTestRequest, ModelTestResponse, ModelUpdateEntry, ModelsResponse, ModelsUpdateRequest, PasswordChangeRequest, PrefsResponse, ProjectCreateRequest, ProjectCreateResponse, ProjectRole, ProjectSummary, ProjectsResponse, RequestSpan, ScheduleItem, ScheduleServerEvent, ScheduleStatus, ScheduleUpsertRequest, SchedulesResponse, ServerEvent, SessionCategory, SessionCategoryCounts, SessionCreateRequest, SessionCreateResponse, SessionInfo, SessionPatchRequest, SessionResponse, SessionSource, SessionStatus, SessionTracesResponse, SessionsResponse, SkillGroupItem, SkillInstallRequest, SkillLibraryResponse, SkillMetadataItem, SteerRequest, TaskCreateRequest, TaskCreateResponse, TaskInputPart, ToolCallSpan, TraceAnalysisResponse, TraceEventsResponse, TraceFileInfo, TraceModelSegment, TraceTaskStats, TraceToolSpan, UiPrefs, UsageAgentCount, UsageBucket, UsageErrorCount, UsageErrorItem, UsageErrors, UsageGroupBy, UsageGroupRow, UsageResponse, UsageSuccessRate, UsageTrendPoint, UsageTrendPointInTrace, UserInfo, VaultEntryInfo, VaultEntryUpdate, VaultResponse, VaultUpdateRequest, WorkspaceFileEntry, WorkspaceFilesResponse };
1215
+ export type { AdminPasswordResetRequest, AdminUserCreateRequest, AdminUserCreateResponse, AdminUsersResponse, AgentCompactionConfigDto, AgentConfigDto, AgentConfigResponse, AgentConfigUpdateRequest, AgentCreateRequest, AgentCreateResponse, AgentImportRequest, AgentImportResponse, AgentModelConfigDto, AgentSkillsResponse, AgentSummary, AgentTraceDateGroup, AgentTraceFileRef, AgentTraceSessionGroup, AgentTracesResponse, AgentsResponse, ApprovalDecisionRequest, ApprovalMode, AuthLoginRequest, AuthResponse, BenchmarkCaseScore, BenchmarkEvaluation, BenchmarkRunScore, BenchmarkSummary, BenchmarksResponse, CredentialInfo, DirEntryInfo, DirListResponse, ErrorBody, FilesStatRequest, FilesStatResponse, GoalResponse, GoalServerEvent, GoalStateView, MeResponse, MemberAddRequest, MemberAddResponse, MemberInfo, MembersResponse, MessagesLiveTail, MessagesResponse, ModelInfo, ModelPricingDto, ModelRefDto, ModelTestRequest, ModelTestResponse, ModelUpdateEntry, ModelsResponse, ModelsUpdateRequest, PasswordChangeRequest, PrefsResponse, ProjectCreateRequest, ProjectCreateResponse, ProjectRole, ProjectSummary, ProjectsResponse, RequestSpan, RetryNowResponse, ScheduleItem, ScheduleServerEvent, ScheduleStatus, ScheduleUpsertRequest, SchedulesResponse, ServerEvent, SessionCategory, SessionCategoryCounts, SessionCreateRequest, SessionCreateResponse, SessionInfo, SessionPatchRequest, SessionResponse, SessionSource, SessionStatus, SessionTracesResponse, SessionsResponse, SkillGroupItem, SkillInstallRequest, SkillLibraryResponse, SkillMetadataItem, SteerRequest, TaskCreateRequest, TaskCreateResponse, TaskInputPart, ToolCallSpan, TraceAnalysisResponse, TraceEventsResponse, TraceFileInfo, TraceImportRequest, TraceImportResponse, TraceModelSegment, TraceTaskStats, TraceToolSpan, UiPrefs, UpdateCheckResponse, UpdateRunResponse, UsageAgentCount, UsageBucket, UsageErrorCount, UsageErrorItem, UsageErrors, UsageGroupBy, UsageGroupRow, UsageResponse, UsageSuccessRate, UsageTrendPoint, UsageTrendPointInTrace, UserInfo, VaultEntryInfo, VaultEntryUpdate, VaultResponse, VaultUpdateRequest, VersionResponse, WorkspaceFileEntry, WorkspaceFilesResponse };