@inixiative/archive 0.12.1 → 0.14.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.
package/src/index.ts CHANGED
@@ -3,6 +3,8 @@ import { getEncoding } from 'js-tiktoken';
3
3
  import { z } from 'zod';
4
4
 
5
5
  const identifier = z.string().min(1).max(256);
6
+ /** The projectId a catch-all collector gives sessions no other collector claims. It never leaves the machine. */
7
+ export const UNROUTED = 'unrouted';
6
8
  export const archiveEntrySchema = z.strictObject({
7
9
  id: identifier,
8
10
  turnId: identifier.optional(),
@@ -28,6 +30,26 @@ export const archiveReferenceSchema = z.strictObject({
28
30
  integration: z.string().regex(/^[a-z0-9-]{1,64}$/),
29
31
  ref: z.string().min(1).max(300),
30
32
  });
33
+ /**
34
+ * How the session reached its model: the provider, and whether it ran on a subscription or an API
35
+ * key. `evidence` says where the access path came from: the transcript itself, or the harness's
36
+ * login when the transcript is silent (its state at capture).
37
+ */
38
+ export const archiveRuntimeSchema = z.strictObject({
39
+ provider: z.string().regex(/^[a-z0-9][a-z0-9_-]{0,63}$/),
40
+ accessPath: z.enum(['subscription', 'api', 'unknown']),
41
+ evidence: z.enum(['transcript', 'harness']).optional(),
42
+ });
43
+ /** The session that started this one: a subagent's parent, or the thread a fork copied. */
44
+ export const archiveLineageSchema = z.strictObject({
45
+ kind: z.enum(['subagent', 'fork']),
46
+ parentSessionId: identifier,
47
+ agentType: z.string().min(1).max(200).optional(),
48
+ agentName: z.string().min(1).max(200).optional(),
49
+ description: z.string().min(1).max(500).optional(),
50
+ toolUseId: identifier.optional(),
51
+ depth: z.number().int().nonnegative().max(100).optional(),
52
+ });
31
53
  export const archiveSnapshotSchema = z
32
54
  .strictObject({
33
55
  schemaVersion: z.literal(1),
@@ -37,6 +59,8 @@ export const archiveSnapshotSchema = z
37
59
  title: z.string().min(1).max(500),
38
60
  projectId: identifier.optional(),
39
61
  actor: archiveActorSchema.optional(),
62
+ runtime: archiveRuntimeSchema.optional(),
63
+ lineage: archiveLineageSchema.optional(),
40
64
  /** Recorded references, such as the session's repository and branch. Linked ones are found in the text. */
41
65
  references: z.array(archiveReferenceSchema).max(100).optional(),
42
66
  tags: z.array(z.string().min(1).max(120)).max(100),
@@ -60,6 +84,8 @@ export type ArchiveSnapshot = z.infer<typeof archiveSnapshotSchema>;
60
84
  export type ArchiveEntry = z.infer<typeof archiveEntrySchema>;
61
85
  export type ArchiveActor = z.infer<typeof archiveActorSchema>;
62
86
  export type ArchiveReference = z.infer<typeof archiveReferenceSchema>;
87
+ export type ArchiveRuntime = z.infer<typeof archiveRuntimeSchema>;
88
+ export type ArchiveLineage = z.infer<typeof archiveLineageSchema>;
63
89
  export interface ArchiveChunk {
64
90
  id: string;
65
91
  entryId: string;
package/src/schemas.ts CHANGED
@@ -37,4 +37,6 @@ export interface ArchiveFilter {
37
37
  reference?: { integration: string; ref: string };
38
38
  model?: string;
39
39
  effort?: string;
40
+ provider?: string;
41
+ accessPath?: 'subscription' | 'api' | 'unknown';
40
42
  }
package/src/server.ts CHANGED
@@ -29,6 +29,8 @@ const filterFields = {
29
29
  reference: archiveReferenceSchema.optional(),
30
30
  model: z.string().min(1).max(200).optional(),
31
31
  effort: z.string().min(1).max(40).optional(),
32
+ provider: z.string().min(1).max(64).optional(),
33
+ accessPath: z.enum(['subscription', 'api', 'unknown']).optional(),
32
34
  limit: z.number().int().min(1).max(100).default(20),
33
35
  beforeId: archiveId.optional(),
34
36
  };
@@ -145,6 +147,8 @@ export function createArchiveHandler(
145
147
  title: a.title,
146
148
  projectId: a.projectId,
147
149
  actor: a.actor,
150
+ runtime: a.runtime,
151
+ lineage: a.lineage,
148
152
  models: a.models,
149
153
  tags: a.tags,
150
154
  suggestedTags: a.suggestedTags,
package/src/store.ts CHANGED
@@ -144,6 +144,8 @@ export class ArchiveStore {
144
144
  source: snapshot.source,
145
145
  projectId: snapshot.projectId ?? null,
146
146
  actorId: snapshot.actor?.id ?? null,
147
+ provider: snapshot.runtime?.provider ?? null,
148
+ accessPath: snapshot.runtime?.accessPath ?? null,
147
149
  capturedAt: snapshot.capturedAt,
148
150
  summary: summarize(snapshot, settings) as Prisma.InputJsonValue,
149
151
  };
@@ -217,6 +219,8 @@ export class ArchiveStore {
217
219
  ...(filter.projectId ? { projectId: filter.projectId } : {}),
218
220
  ...(filter.source ? { source: filter.source } : {}),
219
221
  ...(filter.actorId ? { actorId: filter.actorId } : {}),
222
+ ...(filter.provider ? { provider: filter.provider } : {}),
223
+ ...(filter.accessPath ? { accessPath: filter.accessPath } : {}),
220
224
  ...(cursor === undefined ? {} : { seq: { lt: cursor } }),
221
225
  },
222
226
  include: { tagEdits: true },