@prismshadow/penguin-library-trace · library/trace/src/trace.ts:999

Traces

interface

Traces: the mechanism TraceService implements.

API

@Interface()
export abstract class Traces {
  abstract observeShardRead?: ((path: string) => void) | undefined;
  abstract ownedSubagents(parent: {
      projectId: string;
      agentId: string;
      sessionId: string;
      createdAt: string;
    }): Promise<OwnedSubagent[]>;
  abstract subagentChildren(
      projectId: string,
      agentId: string,
      sessionId: string,
    ): Promise<Array<{ sessionId: string; agentId: string | null; spawnedAt: string }>>;
  abstract deleteSessionTraces(
      projectId: string,
      agentId: string,
      sessionId: string,
    ): Promise<void>;
  abstract readMessages(
      projectId: string,
      agentId: string,
      sessionId: string,
    ): Promise<HistoryMessage[]>;
  abstract readMessagesPage(
      projectId: string,
      agentId: string,
      sessionId: string,
      req: MessagesPageRequest,
    ): Promise<MessagesPageResult>;
  abstract readHistoryWindow(
      projectId: string,
      agentId: string,
      sessionId: string,
      req: MessagesPageRequest | { kind: "full" },
    ): Promise<HistoryWindowRead>;
  abstract historyTraceFiles(
      projectId: string,
      agentId: string,
      sessionId: string,
    ): Promise<HistoryTraceFile[]>;
  abstract forkSessionTrace(
      projectId: string,
      agentId: string,
      sourceSessionId: string,
      position: TracePosition,
    ): Promise<ForkTraceResult>;
  abstract contextBreakdown(
      projectId: string,
      agentId: string,
      sessionId: string,
    ): Promise<SessionContextParts>;
  abstract listTraceFiles(
      projectId: string,
      agentId: string,
      sessionId: string,
    ): Promise<TraceFileInfo[]>;
  abstract readEvents(
      projectId: string,
      agentId: string,
      sessionId: string,
      index: number,
      offset: number,
      limit: number,
    ): Promise<TraceEventsResponse>;
  abstract readTraceImage(
      projectId: string,
      agentId: string,
      sessionId: string,
      fileIndex: number,
      ordinal: number,
      slot: number | undefined,
    ): Promise<{ mime: string; bytes: Buffer }>;
  abstract analyze(
      projectId: string,
      agentId: string,
      sessionId: string,
      index: number,
    ): Promise<TraceAnalysisResponse>;
  abstract analyzeRecords(
      projectId: string,
      messages: readonly AmspRecord[],
    ): Promise<TraceAnalysisResponse>;
  abstract agentTraces(
      projectId: string,
      agentId: string,
      paging: { offset: number; limit: number } | null,
      opts?: { category?: SessionCategory },
    ): Promise<AgentTracesResponse>;
  abstract readFileRaw(
      projectId: string,
      agentId: string,
      sessionId: string,
      index: number,
    ): Promise<Buffer<ArrayBufferLike>>;
  abstract importTraceFile(
      projectId: string,
      agentId: string,
      content: string,
    ): Promise<TraceImportResponse>;
  abstract importSessions(
      projectId: string,
      agentId: string,
      sessions: readonly ImportedSession[],
    ): Promise<{ imported: number; skipped: string[] }>;
}

Contract Topology

Static AST wiring across @Module / @Provide / @Use

Members (19)

observeShardRead

observeShardRead?: ((path: string) => void) | undefined

ownedSubagents

ownedSubagents(parent: { projectId: string; agentId: string; sessionId: string; createdAt: string; }): Promise<OwnedSubagent[]>
@paramparent{ projectId: string; agentId: string; sessionId: string; createdAt: string; }
@returnsPromise<OwnedSubagent[]>

subagentChildren

subagentChildren(projectId: string, agentId: string, sessionId: string): Promise<Array<{ sessionId: string; agentId: string | null; spawnedAt: string }>>
@paramprojectIdstring
@paramagentIdstring
@paramsessionIdstring
@returnsPromise<Array<{ sessionId: string; agentId: string | null; spawnedAt: string }>>

deleteSessionTraces

deleteSessionTraces(projectId: string, agentId: string, sessionId: string): Promise<void>
@paramprojectIdstring
@paramagentIdstring
@paramsessionIdstring
@returnsPromise<void>

readMessages

readMessages(projectId: string, agentId: string, sessionId: string): Promise<HistoryMessage[]>
@paramprojectIdstring
@paramagentIdstring
@paramsessionIdstring
@returnsPromise<HistoryMessage[]>

readMessagesPage

readMessagesPage(projectId: string, agentId: string, sessionId: string, req: MessagesPageRequest): Promise<MessagesPageResult>
@paramprojectIdstring
@paramagentIdstring
@paramsessionIdstring
@paramreqMessagesPageRequest
@returnsPromise<MessagesPageResult>

readHistoryWindow

readHistoryWindow(projectId: string, agentId: string, sessionId: string, req: MessagesPageRequest | { kind: "full" }): Promise<HistoryWindowRead>
@paramprojectIdstring
@paramagentIdstring
@paramsessionIdstring
@paramreqMessagesPageRequest | { kind: "full" }
@returnsPromise<HistoryWindowRead>

historyTraceFiles

historyTraceFiles(projectId: string, agentId: string, sessionId: string): Promise<HistoryTraceFile[]>
@paramprojectIdstring
@paramagentIdstring
@paramsessionIdstring
@returnsPromise<HistoryTraceFile[]>

forkSessionTrace

forkSessionTrace(projectId: string, agentId: string, sourceSessionId: string, position: TracePosition): Promise<ForkTraceResult>
@paramprojectIdstring
@paramagentIdstring
@paramsourceSessionIdstring
@parampositionTracePosition
@returnsPromise<ForkTraceResult>

contextBreakdown

contextBreakdown(projectId: string, agentId: string, sessionId: string): Promise<SessionContextParts>
@paramprojectIdstring
@paramagentIdstring
@paramsessionIdstring
@returnsPromise<SessionContextParts>

listTraceFiles

listTraceFiles(projectId: string, agentId: string, sessionId: string): Promise<TraceFileInfo[]>
@paramprojectIdstring
@paramagentIdstring
@paramsessionIdstring
@returnsPromise<TraceFileInfo[]>

readEvents

readEvents(projectId: string, agentId: string, sessionId: string, index: number, offset: number, limit: number): Promise<TraceEventsResponse>
@paramprojectIdstring
@paramagentIdstring
@paramsessionIdstring
@paramindexnumber
@paramoffsetnumber
@paramlimitnumber
@returnsPromise<TraceEventsResponse>

readTraceImage

readTraceImage(projectId: string, agentId: string, sessionId: string, fileIndex: number, ordinal: number, slot: number | undefined): Promise<{ mime: string; bytes: Buffer }>
@paramprojectIdstring
@paramagentIdstring
@paramsessionIdstring
@paramfileIndexnumber
@paramordinalnumber
@paramslotnumber | undefined
@returnsPromise<{ mime: string; bytes: Buffer }>

analyze

analyze(projectId: string, agentId: string, sessionId: string, index: number): Promise<TraceAnalysisResponse>
@paramprojectIdstring
@paramagentIdstring
@paramsessionIdstring
@paramindexnumber
@returnsPromise<TraceAnalysisResponse>

analyzeRecords

analyzeRecords(projectId: string, messages: readonly AmspRecord[]): Promise<TraceAnalysisResponse>

The same analysis of one Trace file's records read elsewhere — a machine's file from the hub's copy (machines/history-routes.ts) — priced with projectId's rates.

@paramprojectIdstring
@parammessagesreadonly AmspRecord[]
@returnsPromise<TraceAnalysisResponse>

agentTraces

agentTraces(projectId: string, agentId: string, paging: { offset: number; limit: number } | null, opts?: { category?: SessionCategory }): Promise<AgentTracesResponse>
@paramprojectIdstring
@paramagentIdstring
@parampaging{ offset: number; limit: number } | null
@paramopts?{ category?: SessionCategory }
@returnsPromise<AgentTracesResponse>

readFileRaw

readFileRaw(projectId: string, agentId: string, sessionId: string, index: number): Promise<Buffer<ArrayBufferLike>>
@paramprojectIdstring
@paramagentIdstring
@paramsessionIdstring
@paramindexnumber
@returnsPromise<Buffer<ArrayBufferLike>>

importTraceFile

importTraceFile(projectId: string, agentId: string, content: string): Promise<TraceImportResponse>
@paramprojectIdstring
@paramagentIdstring
@paramcontentstring
@returnsPromise<TraceImportResponse>

importSessions

importSessions(projectId: string, agentId: string, sessions: readonly ImportedSession[]): Promise<{ imported: number; skipped: string[] }>
@paramprojectIdstring
@paramagentIdstring
@paramsessionsreadonly ImportedSession[]
@returnsPromise<{ imported: number; skipped: string[] }>