@artinet/sdk
Version:
A TypeScript SDK for building collaborative AI agents.
85 lines (84 loc) • 1.73 kB
JavaScript
/**
* Copyright 2025 The Artinet Project
* SPDX-License-Identifier: Apache-2.0
*/
import { A2A } from "../types/index.js";
export class TextPart {
_part;
constructor(params) {
this._part = {
text: params,
kind: A2A.Kind.text,
};
}
get part() {
return this._part;
}
static create(params) {
return new TextPart(params).part;
}
}
export class FilePart {
_part;
constructor(params) {
this._part = {
kind: A2A.Kind.file,
file: params,
};
}
get part() {
return this._part;
}
static create(params) {
if (typeof params === "string") {
return new FilePart({ uri: params }).part;
}
return new FilePart(params).part;
}
}
export const filePart = FilePart.create;
export class DataPart {
_part;
constructor(params) {
this._part = {
data: params,
kind: A2A.Kind.data,
};
}
get part() {
return this._part;
}
static create(params) {
return new DataPart(params).part;
}
}
/**
* Namespace for {@link A2A.Part} creation utilities.
*
* @example
* ```typescript
* const t = part.text("Hello");
* const f = part.file("https://example.com/file.pdf");
* const d = part.data({ key: "value" });
* ```
*
* @public
* @since 0.6.0
*/
export const part = {
/**
* Create a text part.
* @see {@link A2A.TextPart}
*/
text: TextPart.create,
/**
* Create a file part.
* @see {@link A2A.FilePart}
*/
file: FilePart.create,
/**
* Create a data part.
* @see {@link A2A.DataPart}
*/
data: DataPart.create,
};