axiom 0.1.6 → 1.0.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.
Files changed (97) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +61 -123
  3. package/dist/bin.cjs +486 -0
  4. package/dist/bin.cjs.map +1 -0
  5. package/dist/bin.d.cts +1 -0
  6. package/dist/bin.d.ts +1 -0
  7. package/dist/bin.js +410 -0
  8. package/dist/bin.js.map +1 -0
  9. package/dist/chunk-CKSTM4QJ.js +25 -0
  10. package/dist/chunk-CKSTM4QJ.js.map +1 -0
  11. package/dist/chunk-KEXKKQVW.js +41 -0
  12. package/dist/chunk-KEXKKQVW.js.map +1 -0
  13. package/dist/chunk-P444X2AY.js +45 -0
  14. package/dist/chunk-P444X2AY.js.map +1 -0
  15. package/dist/chunk-VJQQJFVJ.js +311 -0
  16. package/dist/chunk-VJQQJFVJ.js.map +1 -0
  17. package/dist/evals.cjs +646 -0
  18. package/dist/evals.cjs.map +1 -0
  19. package/dist/evals.d.cts +143 -0
  20. package/dist/evals.d.ts +143 -0
  21. package/dist/evals.js +267 -0
  22. package/dist/evals.js.map +1 -0
  23. package/dist/handlebars-4NZUZGZE.js +5865 -0
  24. package/dist/handlebars-4NZUZGZE.js.map +1 -0
  25. package/dist/index.cjs +7895 -0
  26. package/dist/index.cjs.map +1 -0
  27. package/dist/index.d.cts +268 -0
  28. package/dist/index.d.ts +268 -0
  29. package/dist/index.js +1669 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/reporter-B9Ly79ok.d.cts +18 -0
  32. package/dist/reporter-B9Ly79ok.d.ts +18 -0
  33. package/package.json +96 -31
  34. package/.npmignore +0 -1
  35. package/LICENSE +0 -20
  36. package/bin/axiom +0 -3
  37. package/index.js +0 -2
  38. package/lib/bus.coffee +0 -3
  39. package/lib/cli.coffee +0 -56
  40. package/lib/core/delegate.coffee +0 -109
  41. package/lib/core/init.coffee +0 -52
  42. package/lib/core/internal.coffee +0 -66
  43. package/lib/core/link.coffee +0 -28
  44. package/lib/core/listen.coffee +0 -12
  45. package/lib/core/load.coffee +0 -81
  46. package/lib/core/loadProcess.coffee +0 -64
  47. package/lib/core/log.coffee +0 -18
  48. package/lib/core/logLevels.coffee +0 -16
  49. package/lib/core/request.coffee +0 -106
  50. package/lib/core/reset.coffee +0 -7
  51. package/lib/core/respond.coffee +0 -54
  52. package/lib/core/respondOnce.coffee +0 -17
  53. package/lib/core/send.coffee +0 -27
  54. package/lib/core/wireUpLoggers.coffee +0 -29
  55. package/lib/core.coffee +0 -11
  56. package/lib/errorTypes.coffee +0 -56
  57. package/lib/findProjectRoot.coffee +0 -20
  58. package/lib/getSafeCore.coffee +0 -22
  59. package/lib/getSafeRetriever.coffee +0 -11
  60. package/lib/helpers/ns-replace.coffee +0 -8
  61. package/lib/retriever.coffee +0 -29
  62. package/sample/project1/a1/package.json +0 -0
  63. package/sample/project1/appExtensions/doStuff.coffee +0 -4
  64. package/sample/project1/b1/b2/b3/.gitinclude +0 -0
  65. package/sample/project1/config/sample.coffee +0 -2
  66. package/sample/project1/index.js +0 -2
  67. package/sample/project1/main.coffee +0 -4
  68. package/sample/project1/package.json +0 -3
  69. package/sample/project2/index.js +0 -2
  70. package/sample/project2/main.coffee +0 -12
  71. package/sample/project2/package.json +0 -1
  72. package/sample/protocol/config/connect.coffee +0 -13
  73. package/sample/protocol/extensions/workInProgress.coffee +0 -11
  74. package/sample/protocol/index.js +0 -2
  75. package/sample/protocol/main.coffee +0 -20
  76. package/sample/protocol/package.json +0 -10
  77. package/test/cli.coffee +0 -141
  78. package/test/config.coffee +0 -77
  79. package/test/core.coffee +0 -472
  80. package/test/findProjectRoot.coffee +0 -31
  81. package/test/helpers/mockRetriever.coffee +0 -38
  82. package/test/init.coffee +0 -118
  83. package/test/internal.coffee +0 -41
  84. package/test/link.coffee +0 -66
  85. package/test/load.coffee +0 -300
  86. package/test/log.coffee +0 -94
  87. package/test/mocha.opts +0 -5
  88. package/test/retriever.coffee +0 -35
  89. package/tmp/README.md +0 -45
  90. package/tmp/app.coffee +0 -37
  91. package/tmp/axiom +0 -28
  92. package/tmp/cli_usage.md +0 -69
  93. package/tmp/createServer.coffee +0 -42
  94. package/tmp/err.stack.test.coffee +0 -50
  95. package/tmp/err.stack.test.js +0 -64
  96. package/tmp/hello.coffee +0 -2
  97. package/tmp/message.coffee +0 -26
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Axiom, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,139 +1,77 @@
1
- # Axiom
1
+ # Axiom AI
2
2
 
3
- Axiom is a system for formalizing productive workflows, and defining the runtime of your application in a decoupled, extensible way.
3
+ Axiom AI SDK provides an API to wrap your AI calls with observability instrumentation.
4
4
 
5
- At its core, Axiom is:
5
+ ## Model Wrapping
6
6
 
7
- * A protocol for sub-system communication
8
- * A standard for sub-system definition
7
+ ```ts
8
+ import { createOpenAI } from '@ai-sdk/openai';
9
+ import { axiomAIMiddleware } from 'axiom';
10
+ import { wrapLanguageModel } from 'ai';
9
11
 
10
- Sub-systems are stored as NPM modules, and may include:
12
+ const openai = createOpenAI({
13
+ apiKey: process.env.OPENAI_API_KEY!,
14
+ compatibility: 'strict',
15
+ });
11
16
 
12
- * A configuration
13
- * Processes for:
14
- * Install/Uninstall
15
- * Build
16
- * Test
17
- * Runtime
18
- * Feature Scaffolding
17
+ const model = openai('gpt-4o-mini');
19
18
 
20
- These processes can extend existing life-cycles or define their own.
21
-
22
- # Alternatives
23
-
24
- * Yeoman - Used for formalizing workflows, workflows are not extensible, there is no standard for organizing/extending the application runtime.
25
- * FireShell - Ditto.
26
- * Anvil.js - Very similar design goals to Axiom, and in fact we use the same underlying message bus (Postal.js). Whereas Anvil.js decided to bake in the lifecycles, we wanted these to be extensible and therefore we have a more lightweight core than Anvil ships with. We also wanted to extend the decoupled approach of tasks to building out the application runtime.
27
-
28
- # Installation
29
-
30
- ```bash
31
- npm install -g axiom
19
+ export const gpt4oMini = wrapLanguageModel({
20
+ model,
21
+ middleware: [axiomAIMiddleware({ model })],
22
+ });
32
23
  ```
33
24
 
34
- # Usage
35
-
36
- ```bash
37
- axiom core create
38
- # Creates a new app (creates the directory as well).
39
- # This is the only command designed to be run outside the project directory.
40
- # If you already have a directory that you would like to start with, running any
41
- # install (or install with no args) should check all required baseline artifacts
42
- # and install them if they don't exist.
43
-
44
- axiom [module] install
45
- # Automatically does the following:
46
- # 1) npm install axiom-[module] --save
47
- # 2) require axiom-[module]
48
- # 3) run 'install' if it exists
49
-
50
- axiom [module] uninstall
51
- # Automatically does the following:
52
- # 1) require axiom-[module]
53
- # 2) run 'uninstall' if it exists
54
- # 3) npm uninstall axiom-[module] --save
55
-
56
- axiom [module] [task]
57
- axiom client build
58
- # If you have installed an axiom named "client" and it has a task called "build", this
59
- # will run that task.
60
-
61
- axiom client test
62
- axiom server test
63
- # Again, these assume axioms/tasks that exist with those names.
25
+ ## Tool Wrapping
26
+
27
+ ```ts
28
+ import { tool } from 'ai';
29
+ import { wrapTool } from 'axiom';
30
+ import { z } from 'zod';
31
+
32
+ const getWeather = tool({
33
+ description: 'Get current weather for a city',
34
+ parameters: z.object({
35
+ city: z.string().describe('The city name'),
36
+ country: z.string().describe('The country code'),
37
+ }),
38
+ execute: async ({ city, country }) => {
39
+ // Your tool implementation
40
+ return {
41
+ city,
42
+ country,
43
+ temperature: 22,
44
+ condition: 'sunny',
45
+ };
46
+ },
47
+ });
48
+
49
+ // Wrap the tool for observability
50
+ const wrappedWeatherTool = wrapTool('weatherTool', weatherTool);
64
51
  ```
65
52
 
66
- # Building Axioms
67
-
68
- Simply publish on npm a module with the name format 'axiom-yourname'. This will then be discovered by `axiom install`, and once installed will be automatically referanceable from the Axiom CLI.
69
-
70
- Your module should export an object containing the keys:
71
-
72
- * config - A javascript object describing how to wire up the services in this module.
73
- * services - Functions of a standard signature which implement your intended functionality.
74
-
75
- Services should contain:
76
-
77
- * install - A function to install the axiom. Include any generation code here.
78
- * uninstall - A function to uninstall the axiom. Remove all the generated code and directories/files that would have resulted from the installation.
79
- * [anything_else] - A function to generate some files, deploy something, start a server, or run a task.
80
-
81
- Services are in the format of:
82
-
83
- ```coffee-script
84
- (args, done) ->
85
- {foo, bar} = args
86
- done null, {message: 'hello'}
53
+ ## Making AI Calls
54
+ ```ts
55
+ const result = await withSpan(
56
+ { capability: 'weather_bot', step: 'get_weather' },
57
+ (span) => {
58
+ return generateText({
59
+ model: gpt4oMini,
60
+ messages: [{ role: 'user', content: 'What is the weather in London?' }],
61
+ tools: {
62
+ getWeather: wrappedWeatherTool,
63
+ },
64
+ })
65
+ }
66
+ )
87
67
  ```
88
68
 
89
- These conform to the specification for Law services, so if you want some middleware to help you out (argument validations, access controls, filters for common functionality), check out the Law documentation:
90
-
91
- https://github.com/torchlightsoftware/law
92
-
93
- Here's an example module definition using Law:
94
-
95
- ```coffee-script
96
- law = require 'law'
97
- serviceDefs = law.load './services'
98
-
99
- module.exports =
100
- config:
101
- test:
102
- base: 'task'
103
- stages: ['prepare', 'test', 'cleanup']
104
-
105
- services: law.create {
106
- services: serviceDefs
107
- policy: require './policy'
108
- }
69
+ ## Install
109
70
 
71
+ ```bash
72
+ npm install axiom
110
73
  ```
111
74
 
112
- ## DISCLAIMER
113
-
114
- Modules in the Axiom ecosystem are the property of their respective authors. We make no guarantee for the quality, usefulness, or intent of any module.
115
-
116
- ## LICENSE
117
-
118
- (MIT License)
119
-
120
- Copyright (c) 2013 Torchlight Software <info@torchlightsoftware.com>
121
-
122
- Permission is hereby granted, free of charge, to any person obtaining
123
- a copy of this software and associated documentation files (the
124
- "Software"), to deal in the Software without restriction, including
125
- without limitation the rights to use, copy, modify, merge, publish,
126
- distribute, sublicense, and/or sell copies of the Software, and to
127
- permit persons to whom the Software is furnished to do so, subject to
128
- the following conditions:
129
-
130
- The above copyright notice and this permission notice shall be
131
- included in all copies or substantial portions of the Software.
75
+ ## Documentation
132
76
 
133
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
134
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
135
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
136
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
137
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
138
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
139
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
77
+ For more information about how to set up and use the Axiom JavaScript SDK, read documentation on [axiom.co/docs/ai-engineering/quickstart](https://axiom.co/docs/ai-engineering/quickstart).