llama-stack-client 0.0.35 → 0.1.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/LICENSE +22 -201
- package/README.md +60 -26
- package/core.d.ts +7 -7
- package/core.d.ts.map +1 -1
- package/core.js +35 -16
- package/core.js.map +1 -1
- package/core.mjs +32 -14
- package/core.mjs.map +1 -1
- package/error.d.ts +18 -24
- package/error.d.ts.map +1 -1
- package/error.js +1 -31
- package/error.js.map +1 -1
- package/error.mjs +1 -31
- package/error.mjs.map +1 -1
- package/index.d.mts +100 -121
- package/index.d.ts +100 -121
- package/index.d.ts.map +1 -1
- package/index.js +90 -44
- package/index.js.map +1 -1
- package/index.mjs +74 -43
- package/index.mjs.map +1 -1
- package/internal/decoders/jsonl.d.ts +12 -0
- package/internal/decoders/jsonl.d.ts.map +1 -0
- package/internal/decoders/jsonl.js +35 -0
- package/internal/decoders/jsonl.js.map +1 -0
- package/internal/decoders/jsonl.mjs +31 -0
- package/internal/decoders/jsonl.mjs.map +1 -0
- package/internal/decoders/line.d.ts +20 -0
- package/internal/decoders/line.d.ts.map +1 -0
- package/internal/decoders/line.js +88 -0
- package/internal/decoders/line.js.map +1 -0
- package/internal/decoders/line.mjs +84 -0
- package/internal/decoders/line.mjs.map +1 -0
- package/internal/qs/formats.d.ts +6 -0
- package/internal/qs/formats.d.ts.map +1 -0
- package/internal/qs/formats.js +11 -0
- package/internal/qs/formats.js.map +1 -0
- package/internal/qs/formats.mjs +8 -0
- package/internal/qs/formats.mjs.map +1 -0
- package/internal/qs/index.d.ts +10 -0
- package/internal/qs/index.d.ts.map +1 -0
- package/internal/qs/index.js +14 -0
- package/internal/qs/index.js.map +1 -0
- package/internal/qs/index.mjs +10 -0
- package/internal/qs/index.mjs.map +1 -0
- package/internal/qs/stringify.d.ts +3 -0
- package/internal/qs/stringify.d.ts.map +1 -0
- package/internal/qs/stringify.js +280 -0
- package/internal/qs/stringify.js.map +1 -0
- package/internal/qs/stringify.mjs +276 -0
- package/internal/qs/stringify.mjs.map +1 -0
- package/internal/qs/types.d.ts +57 -0
- package/internal/qs/types.d.ts.map +1 -0
- package/internal/qs/types.js +3 -0
- package/internal/qs/types.js.map +1 -0
- package/internal/qs/types.mjs +2 -0
- package/internal/qs/types.mjs.map +1 -0
- package/internal/qs/utils.d.ts +14 -0
- package/internal/qs/utils.d.ts.map +1 -0
- package/internal/qs/utils.js +229 -0
- package/internal/qs/utils.js.map +1 -0
- package/internal/qs/utils.mjs +217 -0
- package/internal/qs/utils.mjs.map +1 -0
- package/internal/stream-utils.d.ts +8 -0
- package/internal/stream-utils.d.ts.map +1 -0
- package/internal/stream-utils.js +39 -0
- package/internal/stream-utils.js.map +1 -0
- package/internal/stream-utils.mjs +35 -0
- package/internal/stream-utils.mjs.map +1 -0
- package/package.json +8 -6
- package/resources/agents/agents.d.ts +22 -187
- package/resources/agents/agents.d.ts.map +1 -1
- package/resources/agents/agents.js +15 -32
- package/resources/agents/agents.js.map +1 -1
- package/resources/agents/agents.mjs +15 -32
- package/resources/agents/agents.mjs.map +1 -1
- package/resources/agents/index.d.ts +4 -4
- package/resources/agents/index.d.ts.map +1 -1
- package/resources/agents/index.js +7 -7
- package/resources/agents/index.js.map +1 -1
- package/resources/agents/index.mjs +3 -3
- package/resources/agents/index.mjs.map +1 -1
- package/resources/agents/session.d.ts +28 -0
- package/resources/agents/session.d.ts.map +1 -0
- package/resources/agents/session.js +25 -0
- package/resources/agents/session.js.map +1 -0
- package/resources/agents/session.mjs +21 -0
- package/resources/agents/session.mjs.map +1 -0
- package/resources/agents/steps.d.ts +3 -24
- package/resources/agents/steps.d.ts.map +1 -1
- package/resources/agents/steps.js +2 -14
- package/resources/agents/steps.js.map +1 -1
- package/resources/agents/steps.mjs +2 -14
- package/resources/agents/steps.mjs.map +1 -1
- package/resources/agents/turn.d.ts +169 -0
- package/resources/agents/turn.d.ts.map +1 -0
- package/resources/agents/turn.js +19 -0
- package/resources/agents/turn.js.map +1 -0
- package/resources/agents/turn.mjs +15 -0
- package/resources/agents/turn.mjs.map +1 -0
- package/resources/batch-inference.d.ts +17 -64
- package/resources/batch-inference.d.ts.map +1 -1
- package/resources/batch-inference.js +4 -26
- package/resources/batch-inference.js.map +1 -1
- package/resources/batch-inference.mjs +4 -26
- package/resources/batch-inference.mjs.map +1 -1
- package/resources/datasetio.d.ts +25 -0
- package/resources/datasetio.d.ts.map +1 -0
- package/resources/datasetio.js +19 -0
- package/resources/datasetio.js.map +1 -0
- package/resources/datasetio.mjs +15 -0
- package/resources/datasetio.mjs.map +1 -0
- package/resources/datasets.d.ts +45 -46
- package/resources/datasets.d.ts.map +1 -1
- package/resources/datasets.js +11 -35
- package/resources/datasets.js.map +1 -1
- package/resources/datasets.mjs +11 -35
- package/resources/datasets.mjs.map +1 -1
- package/resources/eval/eval.d.ts +59 -0
- package/resources/eval/eval.d.ts.map +1 -0
- package/resources/{inference/embeddings.js → eval/eval.js} +16 -20
- package/resources/eval/eval.js.map +1 -0
- package/resources/eval/eval.mjs +18 -0
- package/resources/eval/eval.mjs.map +1 -0
- package/resources/eval/index.d.ts +3 -0
- package/resources/eval/index.d.ts.map +1 -0
- package/resources/eval/index.js +9 -0
- package/resources/eval/index.js.map +1 -0
- package/resources/eval/index.mjs +4 -0
- package/resources/eval/index.mjs.map +1 -0
- package/resources/eval/jobs.d.ts +13 -0
- package/resources/eval/jobs.d.ts.map +1 -0
- package/resources/eval/jobs.js +21 -0
- package/resources/eval/jobs.js.map +1 -0
- package/resources/eval/jobs.mjs +17 -0
- package/resources/eval/jobs.mjs.map +1 -0
- package/resources/eval-tasks.d.ts +32 -0
- package/resources/eval-tasks.d.ts.map +1 -0
- package/resources/eval-tasks.js +22 -0
- package/resources/eval-tasks.js.map +1 -0
- package/resources/eval-tasks.mjs +18 -0
- package/resources/eval-tasks.mjs.map +1 -0
- package/resources/index.d.ts +23 -15
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +33 -17
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +19 -11
- package/resources/index.mjs.map +1 -1
- package/resources/inference.d.ts +241 -0
- package/resources/inference.d.ts.map +1 -0
- package/resources/inference.js +29 -0
- package/resources/inference.js.map +1 -0
- package/resources/inference.mjs +25 -0
- package/resources/inference.mjs.map +1 -0
- package/resources/inspect.d.ts +26 -0
- package/resources/inspect.d.ts.map +1 -0
- package/resources/inspect.js +15 -0
- package/resources/inspect.js.map +1 -0
- package/resources/inspect.mjs +11 -0
- package/resources/inspect.mjs.map +1 -0
- package/resources/models.d.ts +21 -36
- package/resources/models.d.ts.map +1 -1
- package/resources/models.js +11 -27
- package/resources/models.js.map +1 -1
- package/resources/models.mjs +11 -27
- package/resources/models.mjs.map +1 -1
- package/resources/post-training/index.d.ts +2 -2
- package/resources/post-training/index.d.ts.map +1 -1
- package/resources/post-training/index.js +3 -3
- package/resources/post-training/index.js.map +1 -1
- package/resources/post-training/index.mjs +1 -1
- package/resources/post-training/index.mjs.map +1 -1
- package/resources/post-training/job.d.ts +40 -0
- package/resources/post-training/job.d.ts.map +1 -0
- package/resources/post-training/job.js +25 -0
- package/resources/post-training/job.js.map +1 -0
- package/resources/post-training/job.mjs +21 -0
- package/resources/post-training/job.mjs.map +1 -0
- package/resources/post-training/post-training.d.ts +95 -142
- package/resources/post-training/post-training.d.ts.map +1 -1
- package/resources/post-training/post-training.js +8 -29
- package/resources/post-training/post-training.js.map +1 -1
- package/resources/post-training/post-training.mjs +8 -29
- package/resources/post-training/post-training.mjs.map +1 -1
- package/resources/providers.d.ts +14 -0
- package/resources/providers.d.ts.map +1 -0
- package/resources/providers.js +12 -0
- package/resources/providers.js.map +1 -0
- package/resources/providers.mjs +8 -0
- package/resources/providers.mjs.map +1 -0
- package/resources/routes.d.ts +14 -0
- package/resources/routes.d.ts.map +1 -0
- package/resources/routes.js +12 -0
- package/resources/routes.js.map +1 -0
- package/resources/routes.mjs +8 -0
- package/resources/routes.mjs.map +1 -0
- package/resources/safety.d.ts +6 -29
- package/resources/safety.d.ts.map +1 -1
- package/resources/safety.js +2 -14
- package/resources/safety.js.map +1 -1
- package/resources/safety.mjs +2 -14
- package/resources/safety.mjs.map +1 -1
- package/resources/scoring-functions.d.ts +53 -0
- package/resources/scoring-functions.d.ts.map +1 -0
- package/resources/scoring-functions.js +22 -0
- package/resources/scoring-functions.js.map +1 -0
- package/resources/scoring-functions.mjs +18 -0
- package/resources/scoring-functions.mjs.map +1 -0
- package/resources/scoring.d.ts +28 -0
- package/resources/scoring.d.ts.map +1 -0
- package/resources/scoring.js +15 -0
- package/resources/scoring.js.map +1 -0
- package/resources/scoring.mjs +11 -0
- package/resources/scoring.mjs.map +1 -0
- package/resources/shared.d.ts +338 -14
- package/resources/shared.d.ts.map +1 -1
- package/resources/shields.d.ts +18 -32
- package/resources/shields.d.ts.map +1 -1
- package/resources/shields.js +7 -29
- package/resources/shields.js.map +1 -1
- package/resources/shields.mjs +7 -29
- package/resources/shields.mjs.map +1 -1
- package/resources/synthetic-data-generation.d.ts +7 -24
- package/resources/synthetic-data-generation.d.ts.map +1 -1
- package/resources/synthetic-data-generation.js +5 -17
- package/resources/synthetic-data-generation.js.map +1 -1
- package/resources/synthetic-data-generation.mjs +3 -15
- package/resources/synthetic-data-generation.mjs.map +1 -1
- package/resources/telemetry.d.ts +95 -35
- package/resources/telemetry.d.ts.map +1 -1
- package/resources/telemetry.js +29 -22
- package/resources/telemetry.js.map +1 -1
- package/resources/telemetry.mjs +29 -22
- package/resources/telemetry.mjs.map +1 -1
- package/resources/tool-runtime/index.d.ts +3 -0
- package/resources/tool-runtime/index.d.ts.map +1 -0
- package/resources/tool-runtime/index.js +9 -0
- package/resources/tool-runtime/index.js.map +1 -0
- package/resources/tool-runtime/index.mjs +4 -0
- package/resources/tool-runtime/index.mjs.map +1 -0
- package/resources/tool-runtime/rag-tool.d.ts +27 -0
- package/resources/tool-runtime/rag-tool.d.ts.map +1 -0
- package/resources/tool-runtime/rag-tool.js +25 -0
- package/resources/tool-runtime/rag-tool.js.map +1 -0
- package/resources/tool-runtime/rag-tool.mjs +21 -0
- package/resources/tool-runtime/rag-tool.mjs.map +1 -0
- package/resources/tool-runtime/tool-runtime.d.ts +48 -0
- package/resources/tool-runtime/tool-runtime.d.ts.map +1 -0
- package/resources/{evaluate/evaluate.js → tool-runtime/tool-runtime.js} +29 -18
- package/resources/tool-runtime/tool-runtime.js.map +1 -0
- package/resources/tool-runtime/tool-runtime.mjs +33 -0
- package/resources/tool-runtime/tool-runtime.mjs.map +1 -0
- package/resources/toolgroups.d.ts +40 -0
- package/resources/toolgroups.d.ts.map +1 -0
- package/resources/toolgroups.js +37 -0
- package/resources/toolgroups.js.map +1 -0
- package/resources/toolgroups.mjs +33 -0
- package/resources/toolgroups.mjs.map +1 -0
- package/resources/tools.d.ts +41 -0
- package/resources/tools.d.ts.map +1 -0
- package/resources/tools.js +19 -0
- package/resources/tools.js.map +1 -0
- package/resources/tools.mjs +15 -0
- package/resources/tools.mjs.map +1 -0
- package/resources/vector-dbs.d.ts +59 -0
- package/resources/vector-dbs.d.ts.map +1 -0
- package/resources/vector-dbs.js +24 -0
- package/resources/vector-dbs.js.map +1 -0
- package/resources/vector-dbs.mjs +20 -0
- package/resources/vector-dbs.mjs.map +1 -0
- package/resources/vector-io.d.ts +37 -0
- package/resources/vector-io.d.ts.map +1 -0
- package/resources/vector-io.js +19 -0
- package/resources/vector-io.js.map +1 -0
- package/resources/vector-io.mjs +15 -0
- package/resources/vector-io.mjs.map +1 -0
- package/src/core.ts +46 -24
- package/src/error.ts +25 -41
- package/src/index.ts +437 -155
- package/src/internal/decoders/jsonl.ts +41 -0
- package/src/internal/decoders/line.ts +114 -0
- package/src/internal/qs/LICENSE.md +13 -0
- package/src/internal/qs/README.md +3 -0
- package/src/internal/qs/formats.ts +9 -0
- package/src/internal/qs/index.ts +13 -0
- package/src/internal/qs/stringify.ts +388 -0
- package/src/internal/qs/types.ts +71 -0
- package/src/internal/qs/utils.ts +265 -0
- package/src/internal/stream-utils.ts +32 -0
- package/src/resources/agents/agents.ts +72 -299
- package/src/resources/agents/index.ts +24 -27
- package/src/resources/agents/session.ts +73 -0
- package/src/resources/agents/steps.ts +14 -40
- package/src/resources/agents/turn.ts +292 -0
- package/src/resources/batch-inference.ts +30 -95
- package/src/resources/datasetio.ts +53 -0
- package/src/resources/datasets.ts +87 -81
- package/src/resources/eval/eval.ts +104 -0
- package/src/resources/eval/index.ts +12 -0
- package/src/resources/eval/jobs.ts +36 -0
- package/src/resources/eval-tasks.ts +69 -0
- package/src/resources/index.ts +141 -65
- package/src/resources/inference.ts +346 -0
- package/src/resources/inspect.ts +47 -0
- package/src/resources/models.ts +46 -66
- package/src/resources/post-training/index.ts +14 -14
- package/src/resources/post-training/job.ts +84 -0
- package/src/resources/post-training/post-training.ts +151 -182
- package/src/resources/providers.ts +26 -0
- package/src/resources/routes.ts +23 -0
- package/src/resources/safety.ts +8 -47
- package/src/resources/scoring-functions.ts +108 -0
- package/src/resources/scoring.ts +52 -0
- package/src/resources/shared.ts +462 -14
- package/src/resources/shields.ts +37 -64
- package/src/resources/synthetic-data-generation.ts +13 -40
- package/src/resources/telemetry.ts +229 -65
- package/src/resources/tool-runtime/index.ts +10 -0
- package/src/resources/tool-runtime/rag-tool.ts +45 -0
- package/src/resources/tool-runtime/tool-runtime.ts +106 -0
- package/src/resources/toolgroups.ts +80 -0
- package/src/resources/tools.ts +81 -0
- package/src/resources/vector-dbs.ts +121 -0
- package/src/resources/vector-io.ts +65 -0
- package/src/streaming.ts +6 -148
- package/src/version.ts +1 -1
- package/streaming.d.ts +0 -7
- package/streaming.d.ts.map +1 -1
- package/streaming.js +8 -123
- package/streaming.js.map +1 -1
- package/streaming.mjs +4 -118
- package/streaming.mjs.map +1 -1
- package/version.d.ts +1 -1
- package/version.d.ts.map +1 -1
- package/version.js +1 -1
- package/version.js.map +1 -1
- package/version.mjs +1 -1
- package/version.mjs.map +1 -1
- package/resources/agents/sessions.d.ts +0 -76
- package/resources/agents/sessions.d.ts.map +0 -1
- package/resources/agents/sessions.js +0 -52
- package/resources/agents/sessions.js.map +0 -1
- package/resources/agents/sessions.mjs +0 -48
- package/resources/agents/sessions.mjs.map +0 -1
- package/resources/agents/turns.d.ts +0 -133
- package/resources/agents/turns.d.ts.map +0 -1
- package/resources/agents/turns.js +0 -38
- package/resources/agents/turns.js.map +0 -1
- package/resources/agents/turns.mjs +0 -34
- package/resources/agents/turns.mjs.map +0 -1
- package/resources/evaluate/evaluate.d.ts +0 -29
- package/resources/evaluate/evaluate.d.ts.map +0 -1
- package/resources/evaluate/evaluate.js.map +0 -1
- package/resources/evaluate/evaluate.mjs +0 -22
- package/resources/evaluate/evaluate.mjs.map +0 -1
- package/resources/evaluate/index.d.ts +0 -6
- package/resources/evaluate/index.d.ts.map +0 -1
- package/resources/evaluate/index.js +0 -15
- package/resources/evaluate/index.js.map +0 -1
- package/resources/evaluate/index.mjs +0 -7
- package/resources/evaluate/index.mjs.map +0 -1
- package/resources/evaluate/jobs/artifacts.d.ts +0 -22
- package/resources/evaluate/jobs/artifacts.d.ts.map +0 -1
- package/resources/evaluate/jobs/artifacts.js +0 -24
- package/resources/evaluate/jobs/artifacts.js.map +0 -1
- package/resources/evaluate/jobs/artifacts.mjs +0 -20
- package/resources/evaluate/jobs/artifacts.mjs.map +0 -1
- package/resources/evaluate/jobs/index.d.ts +0 -5
- package/resources/evaluate/jobs/index.d.ts.map +0 -1
- package/resources/evaluate/jobs/index.js +0 -13
- package/resources/evaluate/jobs/index.js.map +0 -1
- package/resources/evaluate/jobs/index.mjs +0 -6
- package/resources/evaluate/jobs/index.mjs.map +0 -1
- package/resources/evaluate/jobs/jobs.d.ts +0 -56
- package/resources/evaluate/jobs/jobs.d.ts.map +0 -1
- package/resources/evaluate/jobs/jobs.js +0 -76
- package/resources/evaluate/jobs/jobs.js.map +0 -1
- package/resources/evaluate/jobs/jobs.mjs +0 -49
- package/resources/evaluate/jobs/jobs.mjs.map +0 -1
- package/resources/evaluate/jobs/logs.d.ts +0 -22
- package/resources/evaluate/jobs/logs.d.ts.map +0 -1
- package/resources/evaluate/jobs/logs.js +0 -24
- package/resources/evaluate/jobs/logs.js.map +0 -1
- package/resources/evaluate/jobs/logs.mjs +0 -20
- package/resources/evaluate/jobs/logs.mjs.map +0 -1
- package/resources/evaluate/jobs/status.d.ts +0 -22
- package/resources/evaluate/jobs/status.d.ts.map +0 -1
- package/resources/evaluate/jobs/status.js +0 -24
- package/resources/evaluate/jobs/status.js.map +0 -1
- package/resources/evaluate/jobs/status.mjs +0 -20
- package/resources/evaluate/jobs/status.mjs.map +0 -1
- package/resources/evaluate/question-answering.d.ts +0 -22
- package/resources/evaluate/question-answering.d.ts.map +0 -1
- package/resources/evaluate/question-answering.js +0 -24
- package/resources/evaluate/question-answering.js.map +0 -1
- package/resources/evaluate/question-answering.mjs +0 -20
- package/resources/evaluate/question-answering.mjs.map +0 -1
- package/resources/evaluate/summarization.d.ts +0 -4
- package/resources/evaluate/summarization.d.ts.map +0 -1
- package/resources/evaluate/summarization.js +0 -9
- package/resources/evaluate/summarization.js.map +0 -1
- package/resources/evaluate/summarization.mjs +0 -5
- package/resources/evaluate/summarization.mjs.map +0 -1
- package/resources/evaluate/text-generation.d.ts +0 -4
- package/resources/evaluate/text-generation.d.ts.map +0 -1
- package/resources/evaluate/text-generation.js +0 -9
- package/resources/evaluate/text-generation.js.map +0 -1
- package/resources/evaluate/text-generation.mjs +0 -5
- package/resources/evaluate/text-generation.mjs.map +0 -1
- package/resources/evaluations.d.ts +0 -35
- package/resources/evaluations.d.ts.map +0 -1
- package/resources/evaluations.js +0 -37
- package/resources/evaluations.js.map +0 -1
- package/resources/evaluations.mjs +0 -33
- package/resources/evaluations.mjs.map +0 -1
- package/resources/inference/embeddings.d.ts +0 -29
- package/resources/inference/embeddings.d.ts.map +0 -1
- package/resources/inference/embeddings.js.map +0 -1
- package/resources/inference/embeddings.mjs +0 -22
- package/resources/inference/embeddings.mjs.map +0 -1
- package/resources/inference/index.d.ts +0 -3
- package/resources/inference/index.d.ts.map +0 -1
- package/resources/inference/index.js +0 -9
- package/resources/inference/index.js.map +0 -1
- package/resources/inference/index.mjs +0 -4
- package/resources/inference/index.mjs.map +0 -1
- package/resources/inference/inference.d.ts +0 -172
- package/resources/inference/inference.d.ts.map +0 -1
- package/resources/inference/inference.js +0 -67
- package/resources/inference/inference.js.map +0 -1
- package/resources/inference/inference.mjs +0 -40
- package/resources/inference/inference.mjs.map +0 -1
- package/resources/memory/documents.d.ts +0 -49
- package/resources/memory/documents.d.ts.map +0 -1
- package/resources/memory/documents.js +0 -39
- package/resources/memory/documents.js.map +0 -1
- package/resources/memory/documents.mjs +0 -35
- package/resources/memory/documents.mjs.map +0 -1
- package/resources/memory/index.d.ts +0 -3
- package/resources/memory/index.d.ts.map +0 -1
- package/resources/memory/index.js +0 -9
- package/resources/memory/index.js.map +0 -1
- package/resources/memory/index.mjs +0 -4
- package/resources/memory/index.mjs.map +0 -1
- package/resources/memory/memory.d.ts +0 -158
- package/resources/memory/memory.d.ts.map +0 -1
- package/resources/memory/memory.js +0 -137
- package/resources/memory/memory.js.map +0 -1
- package/resources/memory/memory.mjs +0 -110
- package/resources/memory/memory.mjs.map +0 -1
- package/resources/memory-banks.d.ts +0 -42
- package/resources/memory-banks.d.ts.map +0 -1
- package/resources/memory-banks.js +0 -40
- package/resources/memory-banks.js.map +0 -1
- package/resources/memory-banks.mjs +0 -36
- package/resources/memory-banks.mjs.map +0 -1
- package/resources/post-training/jobs.d.ts +0 -91
- package/resources/post-training/jobs.d.ts.map +0 -1
- package/resources/post-training/jobs.js +0 -80
- package/resources/post-training/jobs.js.map +0 -1
- package/resources/post-training/jobs.mjs +0 -76
- package/resources/post-training/jobs.mjs.map +0 -1
- package/resources/reward-scoring.d.ts +0 -47
- package/resources/reward-scoring.d.ts.map +0 -1
- package/resources/reward-scoring.js +0 -24
- package/resources/reward-scoring.js.map +0 -1
- package/resources/reward-scoring.mjs +0 -20
- package/resources/reward-scoring.mjs.map +0 -1
- package/src/resources/agents/sessions.ts +0 -135
- package/src/resources/agents/turns.ts +0 -231
- package/src/resources/evaluate/evaluate.ts +0 -35
- package/src/resources/evaluate/index.ts +0 -14
- package/src/resources/evaluate/jobs/artifacts.ts +0 -42
- package/src/resources/evaluate/jobs/index.ts +0 -13
- package/src/resources/evaluate/jobs/jobs.ts +0 -99
- package/src/resources/evaluate/jobs/logs.ts +0 -42
- package/src/resources/evaluate/jobs/status.ts +0 -42
- package/src/resources/evaluate/question-answering.ts +0 -42
- package/src/resources/evaluate/summarization.ts +0 -5
- package/src/resources/evaluate/text-generation.ts +0 -5
- package/src/resources/evaluations.ts +0 -73
- package/src/resources/inference/embeddings.ts +0 -48
- package/src/resources/inference/index.ts +0 -15
- package/src/resources/inference/inference.ts +0 -268
- package/src/resources/memory/documents.ts +0 -92
- package/src/resources/memory/index.ts +0 -23
- package/src/resources/memory/memory.ts +0 -297
- package/src/resources/memory-banks.ts +0 -84
- package/src/resources/post-training/jobs.ts +0 -192
- package/src/resources/reward-scoring.ts +0 -82
package/LICENSE
CHANGED
|
@@ -1,201 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
-
exercising permissions granted by this License.
|
|
25
|
-
|
|
26
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
-
including but not limited to software source code, documentation
|
|
28
|
-
source, and configuration files.
|
|
29
|
-
|
|
30
|
-
"Object" form shall mean any form resulting from mechanical
|
|
31
|
-
transformation or translation of a Source form, including but
|
|
32
|
-
not limited to compiled object code, generated documentation,
|
|
33
|
-
and conversions to other media types.
|
|
34
|
-
|
|
35
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
-
Object form, made available under the License, as indicated by a
|
|
37
|
-
copyright notice that is included in or attached to the work
|
|
38
|
-
(an example is provided in the Appendix below).
|
|
39
|
-
|
|
40
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
-
form, that is based on (or derived from) the Work and for which the
|
|
42
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
-
of this License, Derivative Works shall not include works that remain
|
|
45
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
-
the Work and Derivative Works thereof.
|
|
47
|
-
|
|
48
|
-
"Contribution" shall mean any work of authorship, including
|
|
49
|
-
the original version of the Work and any modifications or additions
|
|
50
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
-
means any form of electronic, verbal, or written communication sent
|
|
55
|
-
to the Licensor or its representatives, including but not limited to
|
|
56
|
-
communication on electronic mailing lists, source code control systems,
|
|
57
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
-
excluding communication that is conspicuously marked or otherwise
|
|
60
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
-
|
|
62
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
-
subsequently incorporated within the Work.
|
|
65
|
-
|
|
66
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
-
Work and such Derivative Works in Source or Object form.
|
|
72
|
-
|
|
73
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
-
(except as stated in this section) patent license to make, have made,
|
|
77
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
-
where such license applies only to those patent claims licensable
|
|
79
|
-
by such Contributor that are necessarily infringed by their
|
|
80
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
-
institute patent litigation against any entity (including a
|
|
83
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
-
or contributory patent infringement, then any patent licenses
|
|
86
|
-
granted to You under this License for that Work shall terminate
|
|
87
|
-
as of the date such litigation is filed.
|
|
88
|
-
|
|
89
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
-
modifications, and in Source or Object form, provided that You
|
|
92
|
-
meet the following conditions:
|
|
93
|
-
|
|
94
|
-
(a) You must give any other recipients of the Work or
|
|
95
|
-
Derivative Works a copy of this License; and
|
|
96
|
-
|
|
97
|
-
(b) You must cause any modified files to carry prominent notices
|
|
98
|
-
stating that You changed the files; and
|
|
99
|
-
|
|
100
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
-
that You distribute, all copyright, patent, trademark, and
|
|
102
|
-
attribution notices from the Source form of the Work,
|
|
103
|
-
excluding those notices that do not pertain to any part of
|
|
104
|
-
the Derivative Works; and
|
|
105
|
-
|
|
106
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
-
distribution, then any Derivative Works that You distribute must
|
|
108
|
-
include a readable copy of the attribution notices contained
|
|
109
|
-
within such NOTICE file, excluding those notices that do not
|
|
110
|
-
pertain to any part of the Derivative Works, in at least one
|
|
111
|
-
of the following places: within a NOTICE text file distributed
|
|
112
|
-
as part of the Derivative Works; within the Source form or
|
|
113
|
-
documentation, if provided along with the Derivative Works; or,
|
|
114
|
-
within a display generated by the Derivative Works, if and
|
|
115
|
-
wherever such third-party notices normally appear. The contents
|
|
116
|
-
of the NOTICE file are for informational purposes only and
|
|
117
|
-
do not modify the License. You may add Your own attribution
|
|
118
|
-
notices within Derivative Works that You distribute, alongside
|
|
119
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
-
that such additional attribution notices cannot be construed
|
|
121
|
-
as modifying the License.
|
|
122
|
-
|
|
123
|
-
You may add Your own copyright statement to Your modifications and
|
|
124
|
-
may provide additional or different license terms and conditions
|
|
125
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
-
the conditions stated in this License.
|
|
129
|
-
|
|
130
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
-
this License, without any additional terms or conditions.
|
|
134
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
-
the terms of any separate license agreement you may have executed
|
|
136
|
-
with Licensor regarding such Contributions.
|
|
137
|
-
|
|
138
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
-
except as required for reasonable and customary use in describing the
|
|
141
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
-
|
|
143
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
-
implied, including, without limitation, any warranties or conditions
|
|
148
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
-
appropriateness of using or redistributing the Work and assume any
|
|
151
|
-
risks associated with Your exercise of permissions under this License.
|
|
152
|
-
|
|
153
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
-
unless required by applicable law (such as deliberate and grossly
|
|
156
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
-
liable to You for damages, including any direct, indirect, special,
|
|
158
|
-
incidental, or consequential damages of any character arising as a
|
|
159
|
-
result of this License or out of the use or inability to use the
|
|
160
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
-
other commercial damages or losses), even if such Contributor
|
|
163
|
-
has been advised of the possibility of such damages.
|
|
164
|
-
|
|
165
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
-
or other liability obligations and/or rights consistent with this
|
|
169
|
-
License. However, in accepting such obligations, You may act only
|
|
170
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
-
defend, and hold each Contributor harmless for any liability
|
|
173
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
-
of your accepting any such warranty or additional liability.
|
|
175
|
-
|
|
176
|
-
END OF TERMS AND CONDITIONS
|
|
177
|
-
|
|
178
|
-
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
-
|
|
180
|
-
To apply the Apache License to your work, attach the following
|
|
181
|
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
-
replaced with your own identifying information. (Don't include
|
|
183
|
-
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
-
comment syntax for the file format. We also recommend that a
|
|
185
|
-
file or class name and description of purpose be included on the
|
|
186
|
-
same "printed page" as the copyright notice for easier
|
|
187
|
-
identification within third-party archives.
|
|
188
|
-
|
|
189
|
-
Copyright 2024 Llama Stack Client
|
|
190
|
-
|
|
191
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
-
you may not use this file except in compliance with the License.
|
|
193
|
-
You may obtain a copy of the License at
|
|
194
|
-
|
|
195
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
-
|
|
197
|
-
Unless required by applicable law or agreed to in writing, software
|
|
198
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
-
See the License for the specific language governing permissions and
|
|
201
|
-
limitations under the License.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Meta Platforms, Inc. and affiliates
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
# Llama Stack Client
|
|
1
|
+
# Llama Stack Client TypeScript and JavaScript API Library
|
|
2
2
|
|
|
3
|
-
[](https://npmjs.org/package/llama-stack-client) 
|
|
3
|
+
[](https://npmjs.org/package/llama-stack-client)  [](https://discord.gg/llama-stack)
|
|
4
4
|
|
|
5
5
|
This library provides convenient access to the Llama Stack Client REST API from server-side TypeScript or JavaScript.
|
|
6
6
|
|
|
7
|
-
The REST API documentation can be found on [llama-stack](https://
|
|
7
|
+
The REST API documentation can be found on [https://llama-stack.readthedocs.io/en/latest/references/api_reference/index.html](https://llama-stack.readthedocs.io/en/latest/references/api_reference/index.html). The full API of this library can be found in [api.md](api.md).
|
|
8
8
|
|
|
9
9
|
It is generated with [Stainless](https://www.stainlessapi.com/).
|
|
10
10
|
|
|
@@ -14,7 +14,6 @@ It is generated with [Stainless](https://www.stainlessapi.com/).
|
|
|
14
14
|
npm install llama-stack-client
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
|
|
18
17
|
## Usage
|
|
19
18
|
|
|
20
19
|
The full API of this library can be found in [api.md](api.md).
|
|
@@ -24,18 +23,40 @@ The full API of this library can be found in [api.md](api.md).
|
|
|
24
23
|
import LlamaStackClient from 'llama-stack-client';
|
|
25
24
|
|
|
26
25
|
const client = new LlamaStackClient({
|
|
27
|
-
|
|
26
|
+
baseURL: 'http://localhost:8321'
|
|
28
27
|
});
|
|
29
28
|
|
|
30
29
|
async function main() {
|
|
31
|
-
const
|
|
30
|
+
const models = await client.models.list();
|
|
32
31
|
|
|
33
|
-
console.log(
|
|
32
|
+
console.log(models);
|
|
34
33
|
}
|
|
35
34
|
|
|
36
35
|
main();
|
|
37
36
|
```
|
|
38
37
|
|
|
38
|
+
## Streaming responses
|
|
39
|
+
|
|
40
|
+
We provide support for streaming responses using Server Sent Events (SSE).
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
import LlamaStackClient from 'llama-stack-client';
|
|
44
|
+
|
|
45
|
+
const client = new LlamaStackClient();
|
|
46
|
+
|
|
47
|
+
const stream = await client.inference.chatCompletion({
|
|
48
|
+
messages: [{ content: 'string', role: 'user' }],
|
|
49
|
+
model_id: 'meta-llama/Llama-3.2-3B-Instruct',
|
|
50
|
+
stream: true,
|
|
51
|
+
});
|
|
52
|
+
for await (const inferenceChatCompletionResponse of stream) {
|
|
53
|
+
process.stdout.write(inferenceChatCompletionResponse.event.delta.text || '');
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
If you need to cancel a stream, you can `break` from the loop
|
|
58
|
+
or call `stream.controller.abort()`.
|
|
59
|
+
|
|
39
60
|
### Request & Response types
|
|
40
61
|
|
|
41
62
|
This library includes TypeScript definitions for all request params and response fields. You may import and use them like so:
|
|
@@ -44,16 +65,16 @@ This library includes TypeScript definitions for all request params and response
|
|
|
44
65
|
```ts
|
|
45
66
|
import LlamaStackClient from 'llama-stack-client';
|
|
46
67
|
|
|
47
|
-
const client = new LlamaStackClient(
|
|
48
|
-
environment: 'sandbox', // defaults to 'production'
|
|
49
|
-
});
|
|
68
|
+
const client = new LlamaStackClient();
|
|
50
69
|
|
|
51
70
|
async function main() {
|
|
52
|
-
const params: LlamaStackClient.
|
|
53
|
-
|
|
54
|
-
|
|
71
|
+
const params: LlamaStackClient.InferenceChatCompletionParams = {
|
|
72
|
+
messages: [{ content: 'string', role: 'user' }],
|
|
73
|
+
model_id: 'model_id',
|
|
55
74
|
};
|
|
56
|
-
const
|
|
75
|
+
const response: LlamaStackClient.InferenceChatCompletionResponse = await client.inference.chatCompletion(
|
|
76
|
+
params,
|
|
77
|
+
);
|
|
57
78
|
}
|
|
58
79
|
|
|
59
80
|
main();
|
|
@@ -70,8 +91,8 @@ a subclass of `APIError` will be thrown:
|
|
|
70
91
|
<!-- prettier-ignore -->
|
|
71
92
|
```ts
|
|
72
93
|
async function main() {
|
|
73
|
-
const
|
|
74
|
-
.
|
|
94
|
+
const response = await client.inference
|
|
95
|
+
.chatCompletion({ messages: [{ content: 'string', role: 'user' }], model_id: 'model_id' })
|
|
75
96
|
.catch(async (err) => {
|
|
76
97
|
if (err instanceof LlamaStackClient.APIError) {
|
|
77
98
|
console.log(err.status); // 400
|
|
@@ -115,7 +136,7 @@ const client = new LlamaStackClient({
|
|
|
115
136
|
});
|
|
116
137
|
|
|
117
138
|
// Or, configure per-request:
|
|
118
|
-
await client.
|
|
139
|
+
await client.inference.chatCompletion({ messages: [{ content: 'string', role: 'user' }], model_id: 'model_id' }, {
|
|
119
140
|
maxRetries: 5,
|
|
120
141
|
});
|
|
121
142
|
```
|
|
@@ -132,7 +153,7 @@ const client = new LlamaStackClient({
|
|
|
132
153
|
});
|
|
133
154
|
|
|
134
155
|
// Override per-request:
|
|
135
|
-
await client.
|
|
156
|
+
await client.inference.chatCompletion({ messages: [{ content: 'string', role: 'user' }], model_id: 'model_id' }, {
|
|
136
157
|
timeout: 5 * 1000,
|
|
137
158
|
});
|
|
138
159
|
```
|
|
@@ -153,17 +174,17 @@ You can also use the `.withResponse()` method to get the raw `Response` along wi
|
|
|
153
174
|
```ts
|
|
154
175
|
const client = new LlamaStackClient();
|
|
155
176
|
|
|
156
|
-
const response = await client.
|
|
157
|
-
.
|
|
177
|
+
const response = await client.inference
|
|
178
|
+
.chatCompletion({ messages: [{ content: 'string', role: 'user' }], model_id: 'model_id' })
|
|
158
179
|
.asResponse();
|
|
159
180
|
console.log(response.headers.get('X-My-Header'));
|
|
160
181
|
console.log(response.statusText); // access the underlying Response object
|
|
161
182
|
|
|
162
|
-
const { data:
|
|
163
|
-
.
|
|
183
|
+
const { data: response, response: raw } = await client.inference
|
|
184
|
+
.chatCompletion({ messages: [{ content: 'string', role: 'user' }], model_id: 'model_id' })
|
|
164
185
|
.withResponse();
|
|
165
186
|
console.log(raw.headers.get('X-My-Header'));
|
|
166
|
-
console.log(
|
|
187
|
+
console.log(response);
|
|
167
188
|
```
|
|
168
189
|
|
|
169
190
|
### Making custom/undocumented requests
|
|
@@ -267,8 +288,8 @@ const client = new LlamaStackClient({
|
|
|
267
288
|
});
|
|
268
289
|
|
|
269
290
|
// Override per-request:
|
|
270
|
-
await client.
|
|
271
|
-
{
|
|
291
|
+
await client.inference.chatCompletion(
|
|
292
|
+
{ messages: [{ content: 'string', role: 'user' }], model_id: 'model_id' },
|
|
272
293
|
{
|
|
273
294
|
httpAgent: new http.Agent({ keepAlive: false }),
|
|
274
295
|
},
|
|
@@ -280,7 +301,7 @@ await client.agents.sessions.create(
|
|
|
280
301
|
This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:
|
|
281
302
|
|
|
282
303
|
1. Changes that only affect static types, without breaking runtime behavior.
|
|
283
|
-
2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals)_
|
|
304
|
+
2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_
|
|
284
305
|
3. Changes that we do not expect to impact the vast majority of users in practice.
|
|
285
306
|
|
|
286
307
|
We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
|
|
@@ -293,6 +314,19 @@ TypeScript >= 4.5 is supported.
|
|
|
293
314
|
|
|
294
315
|
The following runtimes are supported:
|
|
295
316
|
|
|
317
|
+
- Web browsers (Up-to-date Chrome, Firefox, Safari, Edge, and more)
|
|
318
|
+
- Node.js 18 LTS or later ([non-EOL](https://endoflife.date/nodejs)) versions.
|
|
319
|
+
- Deno v1.28.0 or higher.
|
|
320
|
+
- Bun 1.0 or later.
|
|
321
|
+
- Cloudflare Workers.
|
|
322
|
+
- Vercel Edge Runtime.
|
|
323
|
+
- Jest 28 or greater with the `"node"` environment (`"jsdom"` is not supported at this time).
|
|
324
|
+
- Nitro v2.6 or greater.
|
|
325
|
+
|
|
296
326
|
Note that React Native is not supported at this time.
|
|
297
327
|
|
|
298
328
|
If you are interested in other runtime environments, please open or upvote an issue on GitHub.
|
|
329
|
+
|
|
330
|
+
## Contributing
|
|
331
|
+
|
|
332
|
+
See [the contributing documentation](./CONTRIBUTING.md).
|
package/core.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export declare class APIPromise<T> extends Promise<T> {
|
|
|
22
22
|
private parseResponse;
|
|
23
23
|
private parsedPromise;
|
|
24
24
|
constructor(responsePromise: Promise<APIResponseProps>, parseResponse?: (props: APIResponseProps) => PromiseOrValue<T>);
|
|
25
|
-
_thenUnwrap<U>(transform: (data: T) => U): APIPromise<U>;
|
|
25
|
+
_thenUnwrap<U>(transform: (data: T, props: APIResponseProps) => U): APIPromise<U>;
|
|
26
26
|
/**
|
|
27
27
|
* Gets the raw `Response` instance instead of parsing the response
|
|
28
28
|
* data.
|
|
@@ -67,7 +67,7 @@ export declare abstract class APIClient {
|
|
|
67
67
|
private fetch;
|
|
68
68
|
protected idempotencyHeader?: string;
|
|
69
69
|
constructor({ baseURL, maxRetries, timeout, // 1 minute
|
|
70
|
-
httpAgent, fetch:
|
|
70
|
+
httpAgent, fetch: overriddenFetch, }: {
|
|
71
71
|
baseURL: string;
|
|
72
72
|
maxRetries?: number | undefined;
|
|
73
73
|
timeout: number | undefined;
|
|
@@ -128,7 +128,6 @@ export declare abstract class APIClient {
|
|
|
128
128
|
buildURL<Req>(path: string, query: Req | null | undefined): string;
|
|
129
129
|
protected stringifyQuery(query: Record<string, unknown>): string;
|
|
130
130
|
fetchWithTimeout(url: RequestInfo, init: RequestInit | undefined, ms: number, controller: AbortController): Promise<Response>;
|
|
131
|
-
protected getRequestClient(): RequestClient;
|
|
132
131
|
private shouldRetry;
|
|
133
132
|
private retryRequest;
|
|
134
133
|
private calculateDefaultRetryTimeoutMillis;
|
|
@@ -153,8 +152,8 @@ export declare abstract class AbstractPage<Item> implements AsyncIterable<Item>
|
|
|
153
152
|
abstract getPaginatedItems(): Item[];
|
|
154
153
|
hasNextPage(): boolean;
|
|
155
154
|
getNextPage(): Promise<this>;
|
|
156
|
-
iterPages(): AsyncGenerator<
|
|
157
|
-
[Symbol.asyncIterator](): AsyncGenerator<
|
|
155
|
+
iterPages(): AsyncGenerator<this>;
|
|
156
|
+
[Symbol.asyncIterator](): AsyncGenerator<Item>;
|
|
158
157
|
}
|
|
159
158
|
/**
|
|
160
159
|
* This subclass of Promise will resolve to an instantiated Page once the request completes.
|
|
@@ -174,7 +173,7 @@ export declare class PagePromise<PageClass extends AbstractPage<Item>, Item = Re
|
|
|
174
173
|
* console.log(item)
|
|
175
174
|
* }
|
|
176
175
|
*/
|
|
177
|
-
[Symbol.asyncIterator](): AsyncGenerator<
|
|
176
|
+
[Symbol.asyncIterator](): AsyncGenerator<Item>;
|
|
178
177
|
}
|
|
179
178
|
export declare const createResponseHeaders: (headers: Awaited<ReturnType<Fetch>>['headers']) => Record<string, string>;
|
|
180
179
|
type HTTPMethod = 'get' | 'post' | 'put' | 'patch' | 'delete';
|
|
@@ -234,7 +233,8 @@ export interface HeadersProtocol {
|
|
|
234
233
|
}
|
|
235
234
|
export type HeadersLike = Record<string, string | string[] | undefined> | HeadersProtocol;
|
|
236
235
|
export declare const isHeadersProtocol: (headers: any) => headers is HeadersProtocol;
|
|
237
|
-
export declare const getRequiredHeader: (headers: HeadersLike, header: string) => string;
|
|
236
|
+
export declare const getRequiredHeader: (headers: HeadersLike | Headers, header: string) => string;
|
|
237
|
+
export declare const getHeader: (headers: HeadersLike | Headers, header: string) => string | undefined;
|
|
238
238
|
/**
|
|
239
239
|
* Encodes a string to Base64 format.
|
|
240
240
|
*/
|
package/core.d.ts.map
CHANGED
|
@@ -1 +1 @@
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EAAE,QAInD;AAaD,eAAO,MAAM,kBAAkB,eAS9B,CAAC;AAEF,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;CACpD;AACD,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,GAAG,eAAe,CAAC;AAE1F,eAAO,MAAM,iBAAiB,YAAa,GAAG,+BAE7C,CAAC;AAEF,eAAO,MAAM,iBAAiB,YAAa,WAAW,GAAG,OAAO,UAAU,MAAM,KAAG,MAMlF,CAAC;AAEF,eAAO,MAAM,SAAS,YAAa,WAAW,GAAG,OAAO,UAAU,MAAM,KAAG,MAAM,GAAG,SA2BnF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,QAAQ,QAAS,MAAM,GAAG,IAAI,GAAG,SAAS,KAAG,MAWzD,CAAC;AAEF,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAElE"}
|
package/core.js
CHANGED
|
@@ -12,7 +12,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
12
12
|
};
|
|
13
13
|
var _AbstractPage_client;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.isObj = exports.toBase64 = exports.getRequiredHeader = exports.isHeadersProtocol = exports.isRunningInBrowser = exports.debug = exports.hasOwn = exports.isEmptyObj = exports.maybeCoerceBoolean = exports.maybeCoerceFloat = exports.maybeCoerceInteger = exports.coerceBoolean = exports.coerceFloat = exports.coerceInteger = exports.readEnv = exports.ensurePresent = exports.castToError = exports.sleep = exports.safeJSON = exports.isRequestOptions = exports.createResponseHeaders = exports.PagePromise = exports.AbstractPage = exports.APIClient = exports.APIPromise = exports.createForm = exports.multipartFormRequestOptions = exports.maybeMultipartFormRequestOptions = void 0;
|
|
15
|
+
exports.isObj = exports.toBase64 = exports.getHeader = exports.getRequiredHeader = exports.isHeadersProtocol = exports.isRunningInBrowser = exports.debug = exports.hasOwn = exports.isEmptyObj = exports.maybeCoerceBoolean = exports.maybeCoerceFloat = exports.maybeCoerceInteger = exports.coerceBoolean = exports.coerceFloat = exports.coerceInteger = exports.readEnv = exports.ensurePresent = exports.castToError = exports.sleep = exports.safeJSON = exports.isRequestOptions = exports.createResponseHeaders = exports.PagePromise = exports.AbstractPage = exports.APIClient = exports.APIPromise = exports.createForm = exports.multipartFormRequestOptions = exports.maybeMultipartFormRequestOptions = void 0;
|
|
16
16
|
const version_1 = require("./version.js");
|
|
17
17
|
const streaming_1 = require("./streaming.js");
|
|
18
18
|
const error_1 = require("./error.js");
|
|
@@ -68,7 +68,7 @@ class APIPromise extends Promise {
|
|
|
68
68
|
this.parseResponse = parseResponse;
|
|
69
69
|
}
|
|
70
70
|
_thenUnwrap(transform) {
|
|
71
|
-
return new APIPromise(this.responsePromise, async (props) => transform(await this.parseResponse(props)));
|
|
71
|
+
return new APIPromise(this.responsePromise, async (props) => transform(await this.parseResponse(props), props));
|
|
72
72
|
}
|
|
73
73
|
/**
|
|
74
74
|
* Gets the raw `Response` instance instead of parsing the response
|
|
@@ -122,12 +122,12 @@ class APIPromise extends Promise {
|
|
|
122
122
|
exports.APIPromise = APIPromise;
|
|
123
123
|
class APIClient {
|
|
124
124
|
constructor({ baseURL, maxRetries = 2, timeout = 60000, // 1 minute
|
|
125
|
-
httpAgent, fetch:
|
|
125
|
+
httpAgent, fetch: overriddenFetch, }) {
|
|
126
126
|
this.baseURL = baseURL;
|
|
127
127
|
this.maxRetries = validatePositiveInteger('maxRetries', maxRetries);
|
|
128
128
|
this.timeout = validatePositiveInteger('timeout', timeout);
|
|
129
129
|
this.httpAgent = httpAgent;
|
|
130
|
-
this.fetch =
|
|
130
|
+
this.fetch = overriddenFetch ?? index_1.fetch;
|
|
131
131
|
}
|
|
132
132
|
authHeaders(opts) {
|
|
133
133
|
return {};
|
|
@@ -251,7 +251,13 @@ class APIClient {
|
|
|
251
251
|
if ((0, uploads_1.isMultipartBody)(options.body) && index_1.kind !== 'node') {
|
|
252
252
|
delete reqHeaders['content-type'];
|
|
253
253
|
}
|
|
254
|
-
|
|
254
|
+
// Don't set the retry count header if it was already set or removed through default headers or by the
|
|
255
|
+
// caller. We check `defaultHeaders` and `headers`, which can contain nulls, instead of `reqHeaders` to
|
|
256
|
+
// account for the removal case.
|
|
257
|
+
if ((0, exports.getHeader)(defaultHeaders, 'x-stainless-retry-count') === undefined &&
|
|
258
|
+
(0, exports.getHeader)(headers, 'x-stainless-retry-count') === undefined) {
|
|
259
|
+
reqHeaders['x-stainless-retry-count'] = String(retryCount);
|
|
260
|
+
}
|
|
255
261
|
this.validateHeaders(reqHeaders, headers);
|
|
256
262
|
return reqHeaders;
|
|
257
263
|
}
|
|
@@ -358,16 +364,21 @@ class APIClient {
|
|
|
358
364
|
if (signal)
|
|
359
365
|
signal.addEventListener('abort', () => controller.abort());
|
|
360
366
|
const timeout = setTimeout(() => controller.abort(), ms);
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
367
|
+
const fetchOptions = {
|
|
368
|
+
signal: controller.signal,
|
|
369
|
+
...options,
|
|
370
|
+
};
|
|
371
|
+
if (fetchOptions.method) {
|
|
372
|
+
// Custom methods like 'patch' need to be uppercased
|
|
373
|
+
// See https://github.com/nodejs/undici/issues/2294
|
|
374
|
+
fetchOptions.method = fetchOptions.method.toUpperCase();
|
|
375
|
+
}
|
|
376
|
+
return (
|
|
377
|
+
// use undefined this binding; fetch errors if bound to something else in browser/cloudflare
|
|
378
|
+
this.fetch.call(undefined, url, fetchOptions).finally(() => {
|
|
365
379
|
clearTimeout(timeout);
|
|
366
380
|
}));
|
|
367
381
|
}
|
|
368
|
-
getRequestClient() {
|
|
369
|
-
return { fetch: this.fetch };
|
|
370
|
-
}
|
|
371
382
|
shouldRetry(response) {
|
|
372
383
|
// Note this is not a standard header.
|
|
373
384
|
const shouldRetryHeader = response.headers.get('x-should-retry');
|
|
@@ -689,8 +700,8 @@ const safeJSON = (text) => {
|
|
|
689
700
|
}
|
|
690
701
|
};
|
|
691
702
|
exports.safeJSON = safeJSON;
|
|
692
|
-
// https://
|
|
693
|
-
const startsWithSchemeRegexp =
|
|
703
|
+
// https://url.spec.whatwg.org/#url-scheme-string
|
|
704
|
+
const startsWithSchemeRegexp = /^[a-z][a-z0-9+.-]*:/i;
|
|
694
705
|
const isAbsoluteURL = (url) => {
|
|
695
706
|
return startsWithSchemeRegexp.test(url);
|
|
696
707
|
};
|
|
@@ -852,6 +863,14 @@ const isHeadersProtocol = (headers) => {
|
|
|
852
863
|
};
|
|
853
864
|
exports.isHeadersProtocol = isHeadersProtocol;
|
|
854
865
|
const getRequiredHeader = (headers, header) => {
|
|
866
|
+
const foundHeader = (0, exports.getHeader)(headers, header);
|
|
867
|
+
if (foundHeader === undefined) {
|
|
868
|
+
throw new Error(`Could not find ${header} header`);
|
|
869
|
+
}
|
|
870
|
+
return foundHeader;
|
|
871
|
+
};
|
|
872
|
+
exports.getRequiredHeader = getRequiredHeader;
|
|
873
|
+
const getHeader = (headers, header) => {
|
|
855
874
|
const lowerCasedHeader = header.toLowerCase();
|
|
856
875
|
if ((0, exports.isHeadersProtocol)(headers)) {
|
|
857
876
|
// to deal with the case where the header looks like Stainless-Event-Id
|
|
@@ -875,9 +894,9 @@ const getRequiredHeader = (headers, header) => {
|
|
|
875
894
|
return value;
|
|
876
895
|
}
|
|
877
896
|
}
|
|
878
|
-
|
|
897
|
+
return undefined;
|
|
879
898
|
};
|
|
880
|
-
exports.
|
|
899
|
+
exports.getHeader = getHeader;
|
|
881
900
|
/**
|
|
882
901
|
* Encodes a string to Base64 format.
|
|
883
902
|
*/
|