@ogygie/core 0.21.0 → 0.22.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ogygie/core",
3
- "version": "0.21.0",
3
+ "version": "0.22.0",
4
4
  "description": "Ogygie framework core: manifest/spec/error schemas, generic tenancy and gate tooling. Ships TypeScript sources — Ogygie products run tsx/vitest by construction (D1).",
5
5
  "license": "MIT",
6
6
  "repository": {
package/src/model.test.ts CHANGED
@@ -21,6 +21,17 @@ function fakeApi(answer: { status?: number; body: unknown }) {
21
21
  const OK = { content: [{ type: "text", text: "hello" }, { type: "thinking", thinking: "" }], stop_reason: "end_turn", model: "claude-opus-5-5", usage: { input_tokens: 12, output_tokens: 3 } };
22
22
 
23
23
  describe("createMessagesClient", () => {
24
+ it("ÉTANT DONNÉ un message en blocs (texte puis document PDF) ALORS il part tel quel : le modèle lit le document nativement", async () => {
25
+ const api = fakeApi({ body: OK });
26
+ const client = createMessagesClient({ apiKey: "k", fetchImpl: api.fetchImpl });
27
+ const content = [
28
+ { type: "text" as const, text: "lis la pièce" },
29
+ { type: "document" as const, source: { type: "base64" as const, media_type: "application/pdf" as const, data: "JVBERi0=" }, title: "cahier.pdf" },
30
+ ];
31
+ await client.complete({ model: "m", system: "s", messages: [{ role: "user", content }] });
32
+ expect(api.calls[0]?.body["messages"]).toEqual([{ role: "user", content }]);
33
+ });
34
+
24
35
  it("ÉTANT DONNÉ une complétion ALORS la requête porte clé, version, modèle, bloc system mis en cache, messages, effort ; le texte, le stop et l'usage reviennent", async () => {
25
36
  const api = fakeApi({ body: OK });
26
37
  const client = createMessagesClient({ apiKey: "sk-test", fetchImpl: api.fetchImpl });
package/src/model.ts CHANGED
@@ -15,9 +15,25 @@
15
15
  */
16
16
  import { throwOgygieError } from "./error.schema.js";
17
17
 
18
+ /** A text part of a message. */
19
+ export interface ModelTextBlock {
20
+ type: "text";
21
+ text: string;
22
+ }
23
+
24
+ /** A document the model reads natively — a PDF, passed as it was received, never written anywhere. */
25
+ export interface ModelDocumentBlock {
26
+ type: "document";
27
+ source: { type: "base64"; media_type: "application/pdf"; data: string };
28
+ title?: string;
29
+ }
30
+
31
+ export type ModelContentBlock = ModelTextBlock | ModelDocumentBlock;
32
+
18
33
  export interface ModelMessage {
19
34
  role: "user" | "assistant";
20
- content: string;
35
+ /** Plain text, or blocks when a message carries documents; passed to the API as is. */
36
+ content: string | ModelContentBlock[];
21
37
  }
22
38
 
23
39
  export interface ModelCompletionInput {