Skip to content

Commit bf42454

Browse files
committed
feat(tasks): add skill bundle artifact contracts and metadata types
1 parent 474b3c2 commit bf42454

5 files changed

Lines changed: 58 additions & 3 deletions

File tree

packages/api-client/src/posthog-client.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,10 +432,17 @@ export class FolderInstructionsConflictError extends Error {
432432

433433
export interface TaskArtifactUploadRequest {
434434
name: string;
435-
type: "user_attachment";
435+
type: "user_attachment" | "skill_bundle";
436436
size: number;
437437
content_type?: string;
438438
source?: string;
439+
metadata?: {
440+
skill_name: string;
441+
skill_source: "user" | "repo" | "marketplace" | "codex";
442+
content_sha256: string;
443+
bundle_format: "zip";
444+
schema_version: number;
445+
};
439446
}
440447

441448
export interface DirectUploadPresignedPost {
@@ -457,6 +464,7 @@ export interface FinalizedTaskArtifactUpload {
457464
source?: string;
458465
size?: number;
459466
content_type?: string;
467+
metadata?: TaskArtifactUploadRequest["metadata"];
460468
storage_path: string;
461469
uploaded_at?: string;
462470
}
@@ -2361,6 +2369,7 @@ export class PostHogAPIClient {
23612369
type: artifact.type,
23622370
source: artifact.source,
23632371
content_type: artifact.content_type,
2372+
metadata: artifact.metadata,
23642373
storage_path: artifact.storage_path,
23652374
})),
23662375
}),
@@ -2436,6 +2445,7 @@ export class PostHogAPIClient {
24362445
type: artifact.type,
24372446
source: artifact.source,
24382447
content_type: artifact.content_type,
2448+
metadata: artifact.metadata,
24392449
storage_path: artifact.storage_path,
24402450
})),
24412451
}),

packages/core/src/sessions/cloudArtifactIdentifiers.ts

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
1+
import type { UploadableSkillSource } from "@posthog/shared";
2+
13
export interface CloudArtifactUploadRequest {
24
name: string;
3-
type: "user_attachment";
5+
type: "user_attachment" | "skill_bundle";
46
size: number;
57
content_type?: string;
68
source?: string;
9+
metadata?: {
10+
skill_name: string;
11+
skill_source: UploadableSkillSource;
12+
content_sha256: string;
13+
bundle_format: "zip";
14+
schema_version: number;
15+
};
716
}
817

918
export interface CloudArtifactPresignedPost {
@@ -41,9 +50,32 @@ export interface CloudArtifactClient {
4150
): Promise<FinalizedCloudArtifact[]>;
4251
}
4352

53+
export interface CloudSkillBundleRef {
54+
name: string;
55+
source: UploadableSkillSource;
56+
path: string;
57+
}
58+
59+
export interface LocalSkillBundle {
60+
name: string;
61+
source: UploadableSkillSource;
62+
fileName: string;
63+
contentType: "application/zip";
64+
contentBase64: string;
65+
contentSha256: string;
66+
size: number;
67+
}
68+
69+
export type BundleLocalSkill = (
70+
skillBundleRef: CloudSkillBundleRef,
71+
) => Promise<LocalSkillBundle>;
72+
4473
export const CLOUD_ARTIFACT_SERVICE = Symbol.for(
4574
"posthog.core.sessions.cloudArtifactService",
4675
);
4776
export const CLOUD_ARTIFACT_READ_FILE_AS_BASE64 = Symbol.for(
4877
"posthog.core.sessions.cloudArtifactReadFileAsBase64",
4978
);
79+
export const CLOUD_ARTIFACT_BUNDLE_LOCAL_SKILL = Symbol.for(
80+
"posthog.core.sessions.cloudArtifactBundleLocalSkill",
81+
);

packages/shared/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,13 +169,15 @@ export type {
169169
SkillFileEntry,
170170
SkillInfo,
171171
SkillSource,
172+
UploadableSkillSource,
172173
} from "./skills";
173174
export { SKILL_EXISTS_MARKER, stripFrontmatter } from "./skills";
174175
export type {
175176
ArtifactType,
176177
PostHogAPIConfig,
177178
TaskRun,
178179
TaskRunArtifact,
180+
TaskRunArtifactMetadata,
179181
TaskRunEnvironment,
180182
TaskRunStatus,
181183
} from "./task";

packages/shared/src/skills.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export type SkillSource = "bundled" | "user" | "repo" | "marketplace" | "codex";
2+
export type UploadableSkillSource = Exclude<SkillSource, "bundled">;
23

34
export interface SkillInfo {
45
name: string;

packages/shared/src/task.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,16 @@ export type ArtifactType =
3737
| "reference"
3838
| "output"
3939
| "artifact"
40-
| "user_attachment";
40+
| "user_attachment"
41+
| "skill_bundle";
42+
43+
export interface TaskRunArtifactMetadata {
44+
skill_name: string;
45+
skill_source: "user" | "repo" | "marketplace" | "codex";
46+
content_sha256: string;
47+
bundle_format: "zip";
48+
schema_version: number;
49+
}
4150

4251
export interface TaskRunArtifact {
4352
id?: string;
@@ -46,6 +55,7 @@ export interface TaskRunArtifact {
4655
source?: string;
4756
size?: number;
4857
content_type?: string;
58+
metadata?: TaskRunArtifactMetadata;
4959
storage_path?: string;
5060
uploaded_at?: string;
5161
}

0 commit comments

Comments
 (0)